forked from andi34/photobooth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-booth.sh
162 lines (138 loc) · 4.17 KB
/
update-booth.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
#!/bin/bash
# Stop on the first sign of trouble
set -e
function info {
echo -e "\033[0;36m${1}\033[0m"
}
function error {
echo -e "\033[0;31m${1}\033[0m"
}
if [ $UID != 0 ]; then
error "[ERROR] Only root is allowed to execute the installer. Forgot sudo?"
exit 1
fi
options=("$@")
path=''
skip=false
for i in ${!options[@]}; do
option="${options[$i]}"
if [[ "$option" == --path=* ]]; then
path="$(echo $option | awk -F '=' '{print $2}')"
fi
if [[ "$option" == --skip ]]; then
skip=true
fi
done
if [[ ! -z $path ]]; then
booth_source=$path
info "[Info] Updating Photobooth located at: ${booth_source}"
else
error '[ERROR]
No Options specified for script execution!
Usage command is "sudo update-booth.sh [OPTION]".
See [OPTION] below:
=======================================================================
--path Mandatory field for installation: Set Photobooth path.
--skip Optional field for installation: Skips updating system
and skips checking for common package installations
-----------------------------------------------------------------------
'
info '[INFO]
Example update
-----------------------------------------------------------------------
sudo ./update-booth.sh --path="/var/www/html"
'
info '[INFO]
Example update skipping system updates and check for common packages
-----------------------------------------------------------------------
sudo ./update-booth.sh --path="/var/www/html" --skip
'
exit 2
fi
OLDFILES=(
'login.php'
'logout.php'
'admin/config.json'
'resources/fonts/style.css'
'resources/js/l10n.js'
'resources/lang/de.js'
'resources/lang/en.js'
'resources/lang/es.js'
'resources/lang/fr.js'
'resources/lang/gr.js'
)
OLDPATH=(
'node_modules/photoswipe'
'vendor/simple-translator'
)
WEBSERVER=(
'libapache2-mod-php'
'nginx'
'lighttpd'
)
COMMON_PACKAGES=(
'git'
'gphoto2'
'libimage-exiftool-perl'
'nodejs'
'php-gd'
'php-zip'
'yarn'
'rsync'
'udisks2'
)
if [[ ! -d "${booth_source}" ]]; then
mkdir -p "${booth_source}"
fi
if [[ ! $skip == true ]]; then
info "[Info] Updating system"
apt update
apt dist-upgrade -y
info "[Info] Checking for webserver..."
for server in "${WEBSERVER[@]}"; do
if [ $(dpkg-query -W -f='${Status}' ${server} 2>/dev/null | grep -c "ok installed") -eq 1 ]; then
info "[Webserver] ${server} used."
if [[ ${server} == "nginx" || ${server} == "lighttpd" ]]; then
info "[NOTE] You're using ${server} as your Webserver."
info "[NOTE] For a no-hassle-setup Apache2 Webserver is recommend!"
if [ $(dpkg-query -W -f='${Status}' ${server} 2>/dev/null | grep -c "ok installed") -eq 1 ]; then
info "[Package] php-fpm installed already"
else
info "[Package Install] Installing missing common package: ${server}"
apt install -y php-fpm
fi
fi
fi
done
info "[Info] Checking common software..."
for package in "${COMMON_PACKAGES[@]}"; do
if [ $(dpkg-query -W -f='${Status}' ${package} 2>/dev/null | grep -c "ok installed") -eq 1 ]; then
info "[Package] ${package} installed already"
else
info "[Package] Installing missing common package: ${package}"
if [[ ${package} == "yarn" ]]; then
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
apt update
fi
apt install -y ${package}
fi
done
else
info "[Info] Skipping common software checks..."
fi
cp -rf ./* "${booth_source}/"
chown -R www-data:www-data ${booth_source}
for file in "${OLDFILES[@]}"; do
if [ -f "${booth_source}/${file}" ]; then
info "[Info] Deleting unused file: ${booth_source}/${file}"
rm "${booth_source}/${file}"
fi
done
for path in "${OLDPATH[@]}"; do
if [ -d "${booth_source}/${path}" ]; then
info "[Info] Deleting deprecated directory: ${booth_source}/${path}"
rm -rf "${booth_source}/${path}"
fi
done
info "[Info] Updated Photobooth"