-
Notifications
You must be signed in to change notification settings - Fork 43
/
remove_t3mujinpack.sh
executable file
·186 lines (148 loc) · 4.41 KB
/
remove_t3mujinpack.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/bash
# Removes all t3mujinpack styles from Darktable database.
#
# Author: João Almeida <[email protected]>
set -euo pipefail
# Initialize output colors
LIGHT_GREY='\033[0;37m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
LIGHT_BLUE='\033[1;34m'
NC='\033[0m' # No Color
echo ""
echo "----------------------------------------------------------------------"
echo -e "${LIGHT_BLUE}t3mujinpack - Film emulation presets for Darktable"
echo ""
echo -e "Presets Uninstall script${NC}"
echo "----------------------------------------------------------------------"
# Linux validate Darktable installation and SQLite installation
if [[ "$OSTYPE" == "linux-gnu" ]]; then
# Validate Darktable installation
if [ ! -x "`which "darktable"`" ]
then
echo ""
echo -e "${YELLOW}Darktable is not installed.${NC}"
echo ""
exit 1
fi
# Validate SQLite installation
if [ ! -x "`which "sqlite3"`" ]
then
echo ""
echo -e "${YELLOW}SQLite is not installed.${NC}"
echo ""
exit 1
fi
fi
# macOS validate Darktable installation and SQLite installation
if [[ "$OSTYPE" == "darwin"* ]]; then
# Validate Darktable installation
if [ ! -x "`mdfind kMDItemFSName = "darktable.app"`" ]
then
echo ""
echo -e "${YELLOW}Darktable is not installed.${NC}"
echo ""
exit 1
fi
# Validate SQLite installation
if [ ! -x "`which "sqlite3"`" ]
then
echo ""
echo -e "${YELLOW}SQLite is not installed.${NC}"
echo ""
exit 1
fi
fi
# Setup database file
if [ "${1:-}" = "" ]
then
echo ""
echo "Using default database files"
data_database_file="$HOME/.config/darktable/data.db"
library_database_file="/$HOME/.config/darktable/library.db"
if [ ! -f "$data_database_file" ]
then
data_database_file="/$HOME/.config/darktable/library.db"
fi
else
if [ "${2:-} " = "" ]
then
echo ""
echo -e "${YELLOW}You must also specify the library database file${NC}"
echo ""
exit
else
echo "Using given database files"
data_database_file="$1"
library_database_file="$2"
fi
if [ ! -f "$data_database_file" ]
then
echo ""
echo -e "${YELLOW}File $data_database_file does not exist${NC}"
echo ""
exit
fi
fi
# Validate Darktable model
echo "Current metadata database file: $data_database_file"
echo "Current library database file: $library_database_file"
output_data=$(sqlite3 $data_database_file "select count(1) from sqlite_master where name = 'styles' or name = 'style_items' or name = 'tags'")
if [ $output_data != 3 ]
then
echo ""
echo -e "${YELLOW}$data_database_file is not an Darktable 3.0.x metadata database${NC}"
echo "Execution has ended and presets have NOT been uninstalled!"
echo ""
exit 2
fi
output_library=$(sqlite3 $library_database_file "select count(1) from sqlite_master where name = 'tagged_images'")
if [ $output_library != 1 ]
then
echo ""
echo -e "${YELLOW}$library_database_file is not an Darktable 3.0.x library database${NC}"
echo "Execution has ended and presets have NOT been uninstalled!"
echo ""
exit 2
fi
# Validate t3mujinpack instalation (including older version)
styles_list=`sqlite3 $data_database_file "select name from styles where name like 't3mujin - %' or name like 't3mujinpack - %' order by name"`
if [ "$styles_list" = "" ]
then
echo ""
echo -e "${YELLOW}t3mujinpack is not installed${NC}"
echo ""
exit 3
fi
# Review current styles
echo ""
echo "Installed t3mujinpack styles:"
for styles_list_current in $styles_list; do
if [ "$styles_list_current" = "t3mujinpack" ] || [ "$styles_list_current" = "t3mujin" ]
then
echo ""
echo -ne "\t"
fi
echo -ne "${LIGHT_BLUE}$styles_list_current ${NC}"
done
echo ""
echo ""
while true; do
read -p "Do you wish to remove these styles? [y/n] " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) echo ""; echo "Styles removal cancelled"; echo ""; exit;;
* ) echo "Please answer [y]es or [n]o.";;
esac
done
# Execute uninstall
echo ""
echo -ne "\t Removing styles definitions... "
$(sqlite3 $data_database_file "delete from style_items where style_items.styleid in ( select id from styles where name like 't3mujin - %')")
$(sqlite3 $data_database_file "delete from style_items where style_items.styleid in ( select id from styles where name like 't3mujinpack - %')")
$(sqlite3 $data_database_file "delete from styles where name like 't3mujin - %'")
$(sqlite3 $data_database_file "delete from styles where name like 't3mujinpack - %'")
echo ""
echo ""
echo -ne "${GREEN}t3mujinpack presets have been uninstalled!${NC}"
echo ""