Skip to content

Commit 89ddfba

Browse files
author
Kristan Kenney
committed
Revert "Refactor upgrade scripts and routine for previous releases"
This reverts commit 772f668.
1 parent 6b2dde6 commit 89ddfba

File tree

6 files changed

+377
-312
lines changed

6 files changed

+377
-312
lines changed

install/upgrade/restart.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Rebuild users and domains
44
for user in `ls /usr/local/hestia/data/users/`; do
5-
echo "(*) Rebuilding domains and account configuration for user: $user..."
5+
echo "(*) Rebuilding domains and account for user: $user..."
66
if [ ! -z $WEB_SYSTEM ]; then
77
$BIN/v-rebuild-web-domains $user >/dev/null 2>&1
88
fi

install/upgrade/version.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@ if [ $VERSION = "$version" ]; then
1717
source /usr/local/hestia/install/upgrade/versions/$version.sh
1818
VERSION="$version"
1919
fi
20-
21-
# Upgrade from pre-release/beta versions prior to v1.0.1
22-
if [ $VERSION = "0.9.8-27" ] || [ $VERSION = "0.9.8-28" ] || [ $VERSION = "0.10.0" ] || [ $VERSION = "1.00.0-190618" ] || [ $VERSION = "1.00.0-190621" ]; then
20+
if [ $VERSION = "0.9.8-27" ]; then
21+
source /usr/local/hestia/install/upgrade/versions/0.9.8-28.sh
22+
VERSION="0.9.8-28"
23+
fi
24+
if [ $VERSION = "0.9.8-28" ]; then
25+
source /usr/local/hestia/install/upgrade/versions/1.00.0-190618.sh
26+
VERSION="1.00.0-190618"
27+
fi
28+
if [ $VERSION = "0.10.00" ] || [ $VERSION = "1.00.0-190618" ] || [ $VERSION = "1.00.0-190621" ]; then
2329
source /usr/local/hestia/install/upgrade/versions/$version.sh
2430
VERSION="$version"
2531
fi
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
HESTIA="/usr/local/hestia"
3+
HESTIA_BACKUP="/root/hst_upgrade/$(date +%d%m%Y%H%M)"
4+
spinner="/-\|"
5+
6+
function version_ge(){ test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" -o ! -z "$1" -a "$1" = "$2"; }
7+
8+
# Add amd64 to repositories to prevent notifications - https://goo.gl/hmsSV7
9+
if ! grep -q 'arch=amd64' /etc/apt/sources.list.d/nginx.list; then
10+
sed -i s/"deb "/"deb [arch=amd64] "/g /etc/apt/sources.list.d/nginx.list
11+
fi
12+
if ! grep -q 'arch=amd64' /etc/apt/sources.list.d/mariadb.list; then
13+
sed -i s/"deb "/"deb [arch=amd64] "/g /etc/apt/sources.list.d/mariadb.list
14+
fi
15+
16+
# Fix named rule for AppArmor - https://goo.gl/SPqHdq
17+
if [ "$DNS_SYSTEM" = 'bind9' ] && [ ! -f /etc/apparmor.d/local/usr.sbin.named ]; then
18+
echo "/home/** rwm," >> /etc/apparmor.d/local/usr.sbin.named 2> /dev/null
19+
fi
20+
21+
# Remove obsolete ports.conf if exists.
22+
if [ -f /usr/local/hestia/data/firewall/ports.conf ]; then
23+
rm -f /usr/local/hestia/data/firewall/ports.conf
24+
fi
25+
26+
# Move clamav to proper location - https://goo.gl/zNuM11
27+
if [ ! -d /usr/local/hestia/web/edit/server/clamav-daemon ]; then
28+
mv /usr/local/hestia/web/edit/server/clamd /usr/local/web/edit/server/clamav-daemon
29+
fi

install/upgrade/versions/1.0.1.sh

Lines changed: 17 additions & 275 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ function version_ge(){ test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1
66
# Set new version number
77
NEW_VERSION="1.0.1"
88

9+
# Set phpMyAdmin version for upgrade
10+
pma_v='4.9.0.1'
11+
12+
# Set backup folder
13+
HESTIA_BACKUP="/root/hst_upgrade/$(date +%d%m%Y%H%M)"
14+
15+
# Set installation source folder
16+
hestiacp="$HESTIA/install/deb"
17+
918
# Load hestia.conf
1019
source /usr/local/hestia/conf/hestia.conf
1120

12-
########################################################################################################
13-
####### Place additional commands below. #######
14-
########################################################################################################
21+
####### Place additional commands below. #######
1522

1623
# Ensure that users from previous releases are set to the correct stable release branch
1724
if [ $RELEASE_BRANCH = "master" ] || [ $RELEASE_BRANCH = "develop" ]; then
@@ -23,35 +30,11 @@ fi
2330
# Add amd64 to repositories to prevent notifications - https://goo.gl/hmsSV7
2431
if ! grep -q 'arch=amd64' /etc/apt/sources.list.d/nginx.list; then
2532
sed -i s/"deb "/"deb [arch=amd64] "/g /etc/apt/sources.list.d/nginx.list
26-
fi
27-
if ! grep -q 'arch=amd64' /etc/apt/sources.list.d/mariadb.list; then
28-
sed -i s/"deb "/"deb [arch=amd64] "/g /etc/apt/sources.list.d/mariadb.list
29-
fi
30-
31-
# Add a general group for normal users created by Hestia
32-
echo "(*) Verifying ACLs and hardening user permissions..."
33-
if [ -z "$(grep ^hestia-users: /etc/group)" ]; then
34-
groupadd --system "hestia-users"
35-
fi
36-
37-
# Make sure non-admin users belong to correct Hestia group
38-
for user in `ls /usr/local/hestia/data/users/`; do
39-
if [ "$user" != "admin" ]; then
40-
usermod -a -G "hestia-users" "$user"
41-
setfacl -m "u:$user:r-x" "$HOMEDIR/$user"
42-
43-
# Update FTP users groups membership
44-
uid=$(id -u $user)
45-
for ftp_user in $(cat /etc/passwd | grep -v "^$user:" | grep "^$user.*:$uid:$uid:" | cut -d ":" -f1); do
46-
usermod -a -G "hestia-users" "$ftp_user"
47-
done
48-
fi
49-
setfacl -m "g:hestia-users:---" "$HOMEDIR/$user"
50-
done
51-
52-
# Fix named rule for AppArmor - https://goo.gl/SPqHdq
53-
if [ "$DNS_SYSTEM" = 'bind9' ] && [ ! -f /etc/apparmor.d/local/usr.sbin.named ]; then
54-
echo "/home/** rwm," >> /etc/apparmor.d/local/usr.sbin.named 2> /dev/null
33+
# Back up old template files and install the latest versions
34+
if [ -d $HESTIA/data/templates/ ]; then
35+
echo "(*) Updating and rebuild web templates..."
36+
cp -rf $HESTIA/data/templates $HESTIA_BACKUP/templates/
37+
$HESTIA/bin/v-update-web-templates
5538
fi
5639

5740
# Update Apache and Nginx configuration to support new file structure
@@ -89,251 +72,10 @@ if [ ! -e /etc/ssl/dhparam.pem ]; then
8972
sed -i "/add_header X-Frame-Options SAMEORIGIN;/d" /etc/nginx/nginx.conf
9073
sed -i "/add_header X-Content-Type-Options nosniff;/d" /etc/nginx/nginx.conf
9174
fi
92-
fi
93-
94-
# Back up old template files and install the latest versions
95-
if [ -d $HESTIA/data/templates/ ]; then
96-
echo "(*) Updating default templates and packages..."
97-
cp -rf $HESTIA/data/templates $HESTIA_BACKUP/templates/
98-
$HESTIA/bin/v-update-web-templates > /dev/null 2>&1
99-
$HESTIA/bin/v-update-dns-templates > /dev/null 2>&1
100-
$HESTIA/bin/v-update-mail-templates > /dev/null 2>&1
101-
fi
102-
103-
# Back up default package and install latest version
104-
if [ -d $HESTIA/data/packages/ ]; then
105-
cp -f $HESTIA/data/packages/default.pkg $HESTIA_BACKUP/packages/
106-
fi
107-
108-
# Remove old Office 365 template as there is a newer version with an updated name
109-
if [ -f $HESTIA/data/templates/dns/o365.tpl ]; then
110-
rm -f $HESTIA/data/templates/dns/o365.tpl
111-
fi
112-
113-
# Back up and remove default index.html if it exists
114-
if [ -f /var/www/html/index.html ]; then
115-
mv /var/www/html/index.html $HESTIA_BACKUP/templates/
116-
fi
117-
118-
# Configure default success page and set permissions on CSS, JavaScript, and Font dependencies for unassigned hosts
119-
if [ ! -d /var/www/html ]; then
120-
mkdir -p /var/www/html/
121-
fi
122-
123-
if [ ! -d /var/www/document_errors/ ]; then
124-
mkdir -p /var/www/document_errors/
125-
fi
126-
127-
cp -rf $HESTIA/install/deb/templates/web/unassigned/* /var/www/html/
128-
cp -rf $HESTIA/install/deb/templates/web/skel/document_errors/* /var/www/document_errors/
129-
chmod 644 /var/www/html/*
130-
chmod 644 /var/www/document_errors/*
131-
132-
# Remove old default asset files from existing domains based on checksum
133-
for user in `ls /usr/local/hestia/data/users/`; do
134-
USER_DATA=$HESTIA/data/users/$user
135-
for domain in $($BIN/v-list-web-domains $user plain |cut -f 1); do
136-
WEBFOLDER="/home/$user/web/$domain/public_html"
137-
folderchecksum=$(find "$WEBFOLDER/css" "$WEBFOLDER/js" "$WEBFOLDER/webfonts" -type f -print0 2>/dev/null |sort -z |xargs -r0 cat |md5sum |cut -d" " -f1)
138-
if [ "$folderchecksum" = "926feacc51384fe13598631f9d1360c3" ]; then
139-
echo "(*) Removing old default asset files from: $domain..."
140-
rm -rf "$WEBFOLDER/css" "$WEBFOLDER/js" "$WEBFOLDER/webfonts"
141-
fi
142-
unset folderchecksum
143-
unset WEBFOLDER
144-
done
145-
done
146-
folderchecksum=$(find /var/www/html/css /var/www/html/js /var/www/html/webfonts -type f -print0 2>/dev/null |sort -z |xargs -r0 cat |md5sum |cut -d" " -f1)
147-
if [ "$folderchecksum" = "d148d5173e5e4162d7af0a60585392cb" ]; then
148-
rm -rf /var/www/html/css /var/www/html/js /var/www/html/webfonts
149-
fi
150-
unset folderchecksum
151-
152-
# Correct permissions for DNS server cache
153-
if [ -d "/var/cache/bind" ]; then
154-
chown bind:bind /var/cache/bind
155-
fi
156-
157-
# Add unassigned hosts configuration to Nginx and Apache
158-
for ipaddr in $(ls /usr/local/hestia/data/ips/ 2>/dev/null); do
159-
160-
web_conf="/etc/$WEB_SYSTEM/conf.d/$ipaddr.conf"
161-
rm -f $web_conf
162-
163-
if [ "$WEB_SYSTEM" = "apache2" ]; then
164-
echo "(*) Adding unassigned hosts configuration to Apache..."
165-
if [ -z "$(/usr/sbin/apache2 -v | grep Apache/2.4)" ]; then
166-
echo "NameVirtualHost $ipaddr:$WEB_PORT" > $web_conf
167-
fi
168-
echo "Listen $ipaddr:$WEB_PORT" >> $web_conf
169-
cat $HESTIA/install/deb/apache2/unassigned.conf >> $web_conf
170-
sed -i 's/directIP/'$ipaddr'/g' $web_conf
171-
sed -i 's/directPORT/'$WEB_PORT'/g' $web_conf
172-
173-
if [ "$WEB_SSL" = 'mod_ssl' ]; then
174-
if [ -z "$(/usr/sbin/apache2 -v | grep Apache/2.4)" ]; then
175-
sed -i "1s/^/NameVirtualHost $ipaddr:$WEB_SSL_PORT\n/" $web_conf
176-
fi
177-
sed -i "1s/^/Listen $ipaddr:$WEB_SSL_PORT\n/" $web_conf
178-
sed -i 's/directSSLPORT/'$WEB_SSL_PORT'/g' $web_conf
179-
fi
180-
181-
elif [ "$WEB_SYSTEM" = "nginx" ]; then
182-
cp -f $HESTIA/install/deb/nginx/unassigned.inc $web_conf
183-
sed -i 's/directIP/'$ipaddr'/g' $web_conf
184-
fi
18575

186-
if [ "$PROXY_SYSTEM" = "nginx" ]; then
187-
echo "(*) Adding unassigned hosts configuration to Nginx..."
188-
cat $WEBTPL/$PROXY_SYSTEM/proxy_ip.tpl |\
189-
sed -e "s/%ip%/$ipaddr/g" \
190-
-e "s/%web_port%/$WEB_PORT/g" \
191-
-e "s/%proxy_port%/$PROXY_PORT/g" \
192-
> /etc/$PROXY_SYSTEM/conf.d/$ipaddr.conf
193-
fi
194-
done
195-
196-
# Cleanup php session files not changed in the last 7 days (60*24*7 minutes)
197-
if [ ! -f /etc/cron.daily/php-session-cleanup ]; then
198-
echo "(*) Configuring PHP session cleanup..."
199-
echo '#!/bin/sh' > /etc/cron.daily/php-session-cleanup
200-
echo "find -O3 /home/*/tmp/ -ignore_readdir_race -depth -mindepth 1 -name 'sess_*' -type f -cmin '+10080' -delete > /dev/null 2>&1" >> /etc/cron.daily/php-session-cleanup
201-
echo "find -O3 $HESTIA/data/sessions/ -ignore_readdir_race -depth -mindepth 1 -name 'sess_*' -type f -cmin '+10080' -delete > /dev/null 2>&1" >> /etc/cron.daily/php-session-cleanup
76+
# Restart Nginx service
77+
systemctl restart nginx >/dev/null 2>&1
20278
fi
203-
chmod 755 /etc/cron.daily/php-session-cleanup
20479

205-
# Fix empty pool error message for MultiPHP
206-
php_versions=$(ls /etc/php/*/fpm -d 2>/dev/null |wc -l)
207-
if [ "$php_versions" -gt 1 ]; then
208-
echo "(*) Updating Multi-PHP configuration..."
209-
for v in $(ls /etc/php/); do
210-
if [ ! -d "/etc/php/$v/fpm/pool.d/" ]; then
211-
continue
212-
fi
213-
214-
cp -f $hestiacp/php-fpm/dummy.conf /etc/php/$v/fpm/pool.d/
215-
v1=$(echo "$v" | sed -e 's/[.]//')
216-
sed -i "s/9999/99$v1/g" /etc/php/$v/fpm/pool.d/dummy.conf
217-
done
218-
fi
21980

220-
# Remove obsolete firewall ports.conf file if it exists
221-
if [ -f /usr/local/hestia/data/firewall/ports.conf ]; then
222-
rm -f /usr/local/hestia/data/firewall/ports.conf
223-
fi
224-
225-
# Move ClamAV daemon settings page to correct location if necessary
226-
if [ ! -d /usr/local/hestia/web/edit/server/clamav-daemon ]; then
227-
mv /usr/local/hestia/web/edit/server/clamd /usr/local/web/edit/server/clamav-daemon
228-
fi
229-
230-
# Remove old OS-specific installation files if they exist to free up space
231-
if [ -d $HESTIA/install/ubuntu ]; then
232-
echo "(*) Removing old Hestia Control Panel installation files for Ubuntu..."
233-
rm -rf $HESTIA/install/ubuntu
234-
fi
235-
if [ -d $HESTIA/install/debian ]; then
236-
echo "(*) Removing old Hestia Control Panel installation files for Debian..."
237-
rm -rf $HESTIA/install/debian
238-
fi
239-
240-
# Update Dovecot configuration to support per-domain SSL
241-
echo "(*) Updating Dovecot IMAP/POP server configuration..."
242-
if [ -f /etc/dovecot/conf.d/15-mailboxes.conf ]; then
243-
mv /etc/dovecot/conf.d/15-mailboxes.conf $HESTIA_BACKUP/conf/
244-
fi
245-
if [ -f /etc/dovecot/dovecot.conf ]; then
246-
# Update Dovecot configuration and restart Dovecot service
247-
mv /etc/dovecot/dovecot.conf $HESTIA_BACKUP/conf/
248-
cp -f $HESTIA/install/deb/dovecot/dovecot.conf /etc/dovecot/dovecot.conf
249-
systemctl restart dovecot
250-
sleep 0.5
251-
fi
252-
253-
# Update Exim SMTP configuration to support per-domain SSL
254-
if [ -f /etc/exim4/exim4.conf.template ]; then
255-
echo "(*) Updating Exim SMTP server configuration..."
256-
mv /etc/exim4/exim4.conf.template $HESTIA_BACKUP/conf/
257-
cp -f $HESTIA/install/deb/exim/exim4.conf.template /etc/exim4/exim4.conf.template
258-
# Reconfigure spam filter and virus scanning
259-
if [ ! -z "$ANTISPAM_SYSTEM" ]; then
260-
sed -i "s/#SPAM/SPAM/g" /etc/exim4/exim4.conf.template
261-
sed -i "s/#SPAM_SCORE/SPAM_SCORE/g" /etc/exim4/exim4.conf.template
262-
fi
263-
if [ ! -z "$ANTIVIRUS_SYSTEM" ]; then
264-
sed -i "s/#CLAMD/CLAMD/g" /etc/exim4/exim4.conf.template
265-
fi
266-
fi
26781

268-
# Add IMAP system variable to configuration if Dovecot is installed
269-
if [ -z "$IMAP_SYSTEM" ]; then
270-
if [ -f /usr/bin/dovecot ]; then
271-
echo "(*) Adding missing IMAP_SYSTEM variable to hestia.conf..."
272-
echo "IMAP_SYSTEM = 'dovecot'" >> $HESTIA/conf/hestia.conf
273-
fi
274-
fi
275-
276-
# Add webmail alias variable to system configuration if non-existent
277-
imap_check=$(cat $HESTIA/conf/hestia.conf | grep IMAP_SYSTEM)
278-
if [ ! -z "$imap_check" ]; then
279-
WEBMAIL_ALIAS_CHECK=$(cat $HESTIA/conf/hestia.conf | grep WEBMAIL_ALIAS)
280-
if [ -z "$WEBMAIL_ALIAS_CHECK" ]; then
281-
echo "(*) Adding global webmail alias to system configuration..."
282-
sed -i "/WEBMAIL_ALIAS/d" $HESTIA/conf/hestia.conf
283-
echo "WEBMAIL_ALIAS='webmail'" >> $HESTIA/conf/hestia.conf
284-
fi
285-
fi
286-
287-
# Set Purge to false in Roundcube configuration - https://goo.gl/3Nja3u
288-
echo "(*) Updating Roundcube configuration..."
289-
if [ -f /etc/roundcube/config.inc.php ]; then
290-
sed -i "s/\['flag_for_deletion'] = 'Purge';/\['flag_for_deletion'] = false;/gI" /etc/roundcube/config.inc.php
291-
fi
292-
if [ -f /etc/roundcube/defaults.inc.php ]; then
293-
sed -i "s/\['flag_for_deletion'] = 'Purge';/\['flag_for_deletion'] = false;/gI" /etc/roundcube/defaults.inc.php
294-
fi
295-
if [ -f /etc/roundcube/main.inc.php ]; then
296-
sed -i "s/\['flag_for_deletion'] = 'Purge';/\['flag_for_deletion'] = false;/gI" /etc/roundcube/main.inc.php
297-
fi
298-
if [ -d "/etc/roundcube" ]; then
299-
chmod 640 /etc/roundcube/debian-db*
300-
chown root:www-data /etc/roundcube/debian-db*
301-
fi
302-
303-
# Remove Webalizer and set AWStats as default
304-
WEBALIAZER_CHECK=$(cat $HESTIA/conf/hestia.conf | grep webalizer)
305-
if [ ! -z "$WEBALIZER_CHECK" ]; then
306-
echo "(*) Removing Webalizer and setting AWStats as default web statistics backend..."
307-
apt purge webalizer -y > /dev/null 2>&1
308-
sed -i "s/STATS_SYSTEM='webalizer,awstats'/STATS_SYSTEM='awstats'/g" $HESTIA/conf/hestia.conf
309-
fi
310-
311-
# Enable SFTP chroot jail capabilities
312-
$HESTIA/bin/v-add-sys-sftp-jail no
313-
314-
# Enable SFTP subsystem for SSH
315-
sftp_subsys_enabled=$(grep -iE "^#?.*subsystem.+(sftp )?sftp-server" /etc/ssh/sshd_config)
316-
if [ ! -z "$sftp_subsys_enabled" ]; then
317-
echo "(*) Updating SFTP subsystem configuration..."
318-
sed -i -E "s/^#?.*Subsystem.+(sftp )?sftp-server/Subsystem sftp internal-sftp/g" /etc/ssh/sshd_config
319-
fi
320-
321-
# Remove and migrate obsolete object keys
322-
for user in `ls /usr/local/hestia/data/users/`; do
323-
USER_DATA=$HESTIA/data/users/$user
324-
325-
# Web keys
326-
for domain in $($BIN/v-list-web-domains $user plain |cut -f 1); do
327-
obskey=$(get_object_value 'web' 'DOMAIN' "$domain" '$FORCESSL')
328-
if [ ! -z "$obskey" ]; then
329-
echo "(*) Updating HTTP-to-HTTPS redirect configuration for $domain..."
330-
update_object_value 'web' 'DOMAIN' "$domain" '$FORCESSL' ''
331-
332-
# copy value under new key name
333-
add_object_key "web" 'DOMAIN' "$domain" 'SSL_FORCE' 'SSL_HOME'
334-
update_object_value 'web' 'DOMAIN' "$domain" '$SSL_FORCE' "$obskey"
335-
fi
336-
unset FORCESSL
337-
done
338-
sed -i "s/\sFORCESSL=''//g" $USER_DATA/web.conf
339-
done

0 commit comments

Comments
 (0)