|
1 | 1 | #!/bin/sh |
2 | 2 |
|
3 | | -# Hestia Control Panel upgrade script for target version 1.2.0 |
| 3 | +# Hestia Control Panel upgrade script for target version 1.2.2 |
4 | 4 |
|
5 | 5 | ####################################################################################### |
6 | 6 | ####### Place additional commands below. ####### |
7 | 7 | ####################################################################################### |
8 | 8 |
|
9 | | -# Check iptables paths and add symlinks when necessary |
10 | | - |
11 | | -if [ ! -e "/sbin/iptables" ]; then |
12 | | - if which iptables; then |
13 | | - ln -s "$(which iptables)" /sbin/iptables |
14 | | - elif [ -e "/usr/sbin/iptables" ]; then |
15 | | - ln -s /usr/sbin/iptables /sbin/iptables |
16 | | - elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables; then |
17 | | - autoiptables=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables | cut -d '' -f 2) |
18 | | - if [ -x "$autoiptables" ]; then |
19 | | - ln -s "$autoiptables" /sbin/iptables |
20 | | - fi |
21 | | - fi |
22 | | -fi |
23 | | - |
24 | | -if [ ! -e "/sbin/iptables-save" ]; then |
25 | | - if which iptables-save; then |
26 | | - ln -s "$(which iptables-save)" /sbin/iptables-save |
27 | | - elif [ -e "/usr/sbin/iptables-save" ]; then |
28 | | - ln -s /usr/sbin/iptables-save /sbin/iptables-save |
29 | | - elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-save; then |
30 | | - autoiptables_save=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-save | cut -d '' -f 2) |
31 | | - if [ -x "$autoiptables_save" ]; then |
32 | | - ln -s "$autoiptables_save" /sbin/iptables-save |
33 | | - fi |
34 | | - fi |
35 | | -fi |
36 | | - |
37 | | -if [ ! -e "/sbin/iptables-restore" ]; then |
38 | | - if which iptables-restore; then |
39 | | - ln -s "$(which iptables-restore)" /sbin/iptables-restore |
40 | | - elif [ -e "/usr/sbin/iptables-restore" ]; then |
41 | | - ln -s /usr/sbin/iptables-restore /sbin/iptables-restore |
42 | | - elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-restore; then |
43 | | - autoiptables_restore=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-restore | cut -d '' -f 2) |
44 | | - if [ -x "$autoiptables_restore" ]; then |
45 | | - ln -s "$autoiptables_restore" /sbin/iptables-restore |
46 | | - fi |
47 | | - fi |
48 | | -fi |
49 | | - |
50 | | -if [ -e "/etc/apache2/mods-enabled/status.conf" ]; then |
51 | | - sed -i '/Allow from all/d' /etc/apache2/mods-enabled/status.conf |
52 | | -fi |
53 | | - |
54 | | -# Add sury apache2 repository |
55 | | -if [ "$WEB_SYSTEM" = "apache2" ] && [ ! -e "/etc/apt/sources.list.d/apache2.list" ]; then |
56 | | - echo "[ * ] Configuring sury.org Apache2 repository..." |
57 | | - |
58 | | - # Check OS and install related repository |
59 | | - if [ -e "/etc/os-release" ]; then |
60 | | - type=$(grep "^ID=" /etc/os-release | cut -f 2 -d '=') |
61 | | - if [ "$type" = "ubuntu" ]; then |
62 | | - codename="$(lsb_release -s -c)" |
63 | | - echo "deb http://ppa.launchpad.net/ondrej/apache2/ubuntu $codename main" > /etc/apt/sources.list.d/apache2.list |
64 | | - elif [ "$type" = "debian" ]; then |
65 | | - codename="$(cat /etc/os-release |grep VERSION= |cut -f 2 -d \(|cut -f 1 -d \))" |
66 | | - echo "deb https://packages.sury.org/apache2/ $codename main" > /etc/apt/sources.list.d/apache2.list |
67 | | - wget --quiet https://packages.sury.org/apache2/apt.gpg -O /tmp/apache2_signing.key |
68 | | - APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add /tmp/apache2_signing.key > /dev/null 2>&1 |
69 | | - fi |
70 | | - fi |
71 | | -fi |
72 | | - |
73 | | -# Roundcube fixes for PHP 7.4 compatibility |
74 | | -if [ -d /usr/share/roundcube ]; then |
75 | | - echo "[ * ] Updating Roundcube configuration..." |
76 | | - [ -f "/usr/share/roundcube/plugins/enigma/lib/enigma_ui.php" ] && sed -i 's/$identities, "\\n"/"\\n", $identities/g' /usr/share/roundcube/plugins/enigma/lib/enigma_ui.php |
77 | | - [ -f "/usr/share/roundcube/program/lib/Roundcube/rcube_contacts.php" ] && sed -i 's/(array_keys($post_search), \x27|\x27)/(\x27|\x27, array_keys($post_search))/g' /usr/share/roundcube/program/lib/Roundcube/rcube_contacts.php |
78 | | - [ -f "/usr/share/roundcube/program/lib/Roundcube/rcube_db.php" ] && sed -i 's/implode($name, \x27.\x27)/implode(\x27.\x27, $name)/g' /usr/share/roundcube/program/lib/Roundcube/rcube_db.php |
79 | | - [ -f "/usr/share/roundcube/program/steps/addressbook/search.inc" ] && sed -i 's/$fields, \x27,\x27/\x27,\x27, $fields/g' /usr/share/roundcube/program/steps/addressbook/search.inc |
80 | | - [ -f "/usr/share/roundcube/program/steps/addressbook/search.inc" ] && sed -i 's/implode($fields, \x27,\x27)/implode(\x27,\x27, $fields)/g' /usr/share/roundcube/program/steps/addressbook/search.inc |
81 | | - [ -f "/usr/share/roundcube/program/steps/mail/sendmail.inc" ] && sed -i 's/implode($bstyle, \x27; \x27)/implode(\x27; \x27, $bstyle)/g' /usr/share/roundcube/program/steps/mail/sendmail.inc |
82 | | -fi |
83 | | - |
84 | | -# Enable Roundcube plugins |
85 | | -if [ -d /usr/share/roundcube ]; then |
86 | | - cp -f $HESTIA_INSTALL_DIR/roundcube/plugins/config_newmail_notifier.inc.php /etc/roundcube/plugins/newmail_notifier/config.inc.php |
87 | | - cp -f $HESTIA_INSTALL_DIR/roundcube/plugins/config_zipdownload.inc.php /etc/roundcube/plugins/zipdownload/config.inc.php |
88 | | - [ -f "/etc/roundcube/config.inc.php" ] && sed -i "s/array('password')/array('password','newmail_notifier','zipdownload')/g" /etc/roundcube/config.inc.php |
89 | | -fi |
90 | | - |
91 | | -# HELO support for multiple domains and IPs |
92 | | -if [ -e "/etc/exim4/exim4.conf.template" ]; then |
93 | | - echo "[ * ] Updating exim4 configuration..." |
94 | | - sed -i 's|helo_data = ${primary_hostname}|helo_data = ${if exists {\/etc\/exim4\/mailhelo.conf}{${lookup{$sender_address_domain}lsearch*{\/etc\/exim4\/mailhelo.conf}{$value}{$primary_hostname}}}{$primary_hostname}}|g' /etc/exim4/exim4.conf.template |
95 | | -fi |
96 | | - |
97 | | -# Add daily midnight cron |
98 | | -if [ -z "$($BIN/v-list-cron-jobs admin | grep 'v-update-sys-queue daily')" ]; then |
99 | | - echo "[ * ] Updating cron jobs..." |
100 | | - command="sudo $BIN/v-update-sys-queue daily" |
101 | | - $BIN/v-add-cron-job 'admin' '01' '00' '*' '*' '*' "$command" |
102 | | -fi |
103 | | -[ ! -f "touch $HESTIA/data/queue/daily.pipe" ] && touch $HESTIA/data/queue/daily.pipe |
104 | | - |
105 | | -# Remove existing network-up hooks so they get regenerated when updating the firewall |
106 | | -# - network hook will also restore ipset config during start-up |
107 | | -if [ -f "/usr/lib/networkd-dispatcher/routable.d/50-ifup-hooks" ]; then |
108 | | - rm "/usr/lib/networkd-dispatcher/routable.d/50-ifup-hooks" |
109 | | - $BIN/v-update-firewall |
110 | | -fi |
111 | | -if [ -f "/etc/network/if-pre-up.d/iptables" ];then |
112 | | - rm "/etc/network/if-pre-up.d/iptables" |
113 | | - $BIN/v-update-firewall |
114 | | -fi |
115 | | - |
116 | | -# Add hestia-event.conf, if the server is running apache2 |
117 | | -if [ "$WEB_SYSTEM" = "apache2" ]; then |
118 | | - echo "[ * ] Updating Apache2 configuration..." |
119 | | - # Cleanup |
120 | | - rm --force /etc/apache2/mods-available/hestia-event.conf |
121 | | - rm --force /etc/apache2/mods-enabled/hestia-event.conf |
122 | | - rm --force /etc/apache2/conf-available/hestia-event.conf |
123 | | - rm --force /etc/apache2/conf-enabled/hestia-event.conf |
124 | | - |
125 | | - if [ $(a2query -M) = 'event' ] && [ ! -e "/etc/apache2/conf.d/hestia-event.conf" ]; then |
126 | | - cp -f $HESTIA_INSTALL_DIR/apache2/hestia-event.conf /etc/apache2/conf.d/ |
127 | | - fi |
128 | | - |
129 | | - # Move apache mod_status config to /mods-available and rename it to prevent losing changes on upgrade |
130 | | - cp -f $HESTIA_INSTALL_DIR/apache2/status.conf /etc/apache2/mods-available/hestia-status.conf |
131 | | - cp -f /etc/apache2/mods-available/status.load /etc/apache2/mods-available/hestia-status.load |
132 | | - a2dismod --quiet status > /dev/null 2>&1 |
133 | | - a2enmod --quiet hestia-status > /dev/null 2>&1 |
134 | | - rm --force /etc/apache2/mods-enabled/status.conf # a2dismod will not remove the file if it isn't a symlink |
135 | | -fi |
136 | | - |
137 | | -# Install File Manager during upgrade if environment variable oesn't already exist and isn't set to false |
138 | | -# so that we don't override preference |
139 | | -FILE_MANAGER_CHECK=$(cat $HESTIA/conf/hestia.conf | grep "FILE_MANAGER='false'") |
140 | | -if [ -z "$FILE_MANAGER_CHECK" ]; then |
141 | | - if [ ! -e "$HESTIA/web/fm/configuration.php" ]; then |
142 | | - echo "[ ! ] Installing File Manager..." |
143 | | - # Install the File Manager |
144 | | - $HESTIA/bin/v-add-sys-filemanager quiet |
145 | | - else |
146 | | - echo "[ * ] Updating File Manager configuration..." |
147 | | - # Update configuration.php |
148 | | - cp -f $HESTIA_INSTALL_DIR/filemanager/filegator/configuration.php $HESTIA/web/fm/configuration.php |
149 | | - # Set environment variable for interface |
150 | | - $HESTIA/bin/v-change-sys-config-value 'FILE_MANAGER' 'true' |
151 | | - fi |
152 | | -fi |
153 | | - |
154 | | -# Enable nginx module loading |
155 | | -if [ -f "/etc/nginx/nginx.conf" ]; then |
156 | | - echo "[ * ] Updating NGINX configuration..." |
157 | | - if [ ! -d "/etc/nginx/modules-enabled" ]; then |
158 | | - mkdir -p "/etc/nginx/modules-enabled" |
159 | | - fi |
160 | | - |
161 | | - if ! grep --silent "include /etc/nginx/modules-enabled" /etc/nginx/nginx.conf; then |
162 | | - sed -i '/^pid/ a include /etc/nginx/modules-enabled/*.conf;' /etc/nginx/nginx.conf |
163 | | - fi |
164 | | -fi |
165 | | - |
166 | | -# Fix public_(s)html group ownership |
167 | | -echo "[ * ] Updating public_(s)html ownership..." |
168 | | -for user in $($HESTIA/bin/v-list-sys-users plain); do |
169 | | - # skip users with missing home folder |
170 | | - [[ -d /home/${user}/ ]] || continue |
171 | | - |
172 | | - # skip users without web domains |
173 | | - ls /home/${user}/web/*/public_*html >/dev/null 2>&1 || continue |
174 | | - |
175 | | - chown --silent --no-dereference :www-data /home/$user/web/*/public_*html |
176 | | -done |
177 | | - |
178 | | -# Fix phpMyAdmin blowfish_secret error message due to incorrect permissions |
179 | | -if [ -e /var/lib/phpmyadmin/blowfish_secret.inc.php ]; then |
180 | | - echo "[ * ] Updating phpMyAdmin permissions..." |
181 | | - chmod 0644 /var/lib/phpmyadmin/blowfish_secret.inc.php |
182 | | -fi |
183 | | - |
184 | | -# Ensure that backup compression level is correctly set |
185 | | -GZIP_LVL_CHECK=$(cat $HESTIA/conf/hestia.conf | grep BACKUP_GZIP) |
186 | | -if [ -z "$GZIP_LVL_CHECK" ]; then |
187 | | - echo "[ * ] Updating backup compression level variable..." |
188 | | - $BIN/v-change-sys-config-value "BACKUP_GZIP" '9' |
189 | | -fi |
190 | | - |
191 | | -# Update phpMyAdmin/phpPgAdmin templates and set missing alias variables if necessary |
192 | | -if [ -e "/var/lib/phpmyadmin" ]; then |
193 | | - PMA_ALIAS_CHECK=$(cat $HESTIA/conf/hestia.conf | grep DB_PMA_ALIAS) |
194 | | - if [ -z "$PMA_ALIAS_CHECK" ]; then |
195 | | - echo "[ * ] Updating phpMyAdmin alias..." |
196 | | - $HESTIA/bin/v-change-sys-db-alias "pma" "phpMyAdmin" |
197 | | - else |
198 | | - echo "[ * ] Updating phpMyAdmin configuration..." |
199 | | - $HESTIA/bin/v-change-sys-db-alias "pma" "$DB_PMA_ALIAS" |
200 | | - fi |
201 | | -fi |
202 | | - |
203 | | -if [ -e "/var/lib/phppgadmin" ]; then |
204 | | - PGA_ALIAS_CHECK=$(cat $HESTIA/conf/hestia.conf | grep DB_PGA_ALIAS) |
205 | | - if [ -z "$PGA_ALIAS_CHECK" ]; then |
206 | | - echo "[ * ] Updating phpPgAdmin alias..." |
207 | | - $HESTIA/bin/v-change-sys-db-alias "pga" "phpPgAdmin" |
208 | | - else |
209 | | - echo "[ * ] Updating phpPgAdmin configuration..." |
210 | | - $HESTIA/bin/v-change-sys-db-alias "pga" "$DB_PGA_ALIAS" |
211 | | - fi |
212 | | -fi |
213 | | - |
214 | | -# Ensure that backup compression level is correctly set |
215 | | -GZIP_LVL_CHECK=$(cat $HESTIA/conf/hestia.conf | grep BACKUP_GZIP) |
216 | | -if [ -z "$GZIP_LVL_CHECK" ]; then |
217 | | - echo "[ * ] Updating backup compression level variable..." |
218 | | - $BIN/v-change-sys-config-value "BACKUP_GZIP" '9' |
219 | | -fi |
220 | | - |
221 | 9 | # Update template files to add warnings |
222 | 10 | # Backup current templates |
223 | 11 | cp -r -f $HESTIA/data/templates/* $HESTIA_BACKUP/templates/ |
|
0 commit comments