11#! /bin/bash
22
3- # Define version check function
4- function version_ge(){ test " $( printf ' %s\n' " $@ " | sort -V | head -n 1) " ! = " $1 " -o ! -z " $1 " -a " $1 " = " $2 " ; }
3+ # Hestia Control Panel upgrade script for target version 1.00.0-190618
54
6- # Load hestia.conf
7- source /usr/local/hestia/conf/hestia.conf
5+ # ######################################################################################
6+ # ###### Place additional commands below. #######
7+ # ######################################################################################
88
9- # ###### Place additional commands below. #######
9+ # Add webmail alias variable to system configuration if non-existent
10+ WEBMAIL_ALIAS_CHECK=$( cat $HESTIA /conf/hestia.conf | grep WEBMAIL_ALIAS)
11+ if [ -z " $WEBMAIL_ALIAS_CHECK " ]; then
12+ echo " (*) Adding global webmail alias to system configuration..."
13+ sed -i " /WEBMAIL_ALIAS/d" $HESTIA /conf/hestia.conf
14+ echo " WEBMAIL_ALIAS='webmail'" >> $HESTIA /conf/hestia.conf
15+ fi
1016
11- # Add amd64 to repositories to prevent notifications - https://goo.gl/hmsSV7
12- if ! grep -q ' arch=amd64' /etc/apt/sources.list.d/nginx.list; then
13- sed -i s/" deb " /" deb [arch=amd64] " /g /etc/apt/sources.list.d/nginx.list
17+ # Update Apache and Nginx configuration to support new file structure
18+ if [ -f /etc/apache2/apache.conf ]; then
19+ echo " (*) Updating Apache configuration..."
20+ mv /etc/apache2/apache.conf $HESTIA_BACKUP /conf/
21+ cp -f $HESTIA /install/deb/apache2/apache.conf /etc/apache2/apache.conf
1422fi
15- if ! grep -q ' arch=amd64' /etc/apt/sources.list.d/mariadb.list; then
16- sed -i s/" deb " /" deb [arch=amd64] " /g /etc/apt/sources.list.d/mariadb.list
23+ if [ -f /etc/nginx/nginx.conf ]; then
24+ echo " (*) Updating NGINX configuration..."
25+ mv /etc/nginx/nginx.conf $HESTIA_BACKUP /conf/
26+ cp -f $HESTIA /install/deb/nginx/nginx.conf /etc/nginx/nginx.conf
1727fi
1828
19- # Add webmail alias variable to system configuration if non-existent
20- imap_check=$( cat $HESTIA /conf/hestia.conf | grep IMAP_SYSTEM)
21- if [ ! -z " $imap_check " ]; then
22- WEBMAIL_ALIAS_CHECK=$( cat $HESTIA /conf/hestia.conf | grep WEBMAIL_ALIAS)
23- if [ -z " $WEBMAIL_ALIAS_CHECK " ]; then
24- echo " (*) Adding global webmail alias to system configuration..."
25- sed -i " /WEBMAIL_ALIAS/d" $HESTIA /conf/hestia.conf
26- echo " WEBMAIL_ALIAS='webmail'" >> $HESTIA /conf/hestia.conf
27- fi
28- fi
29+ # Generate dhparam
30+ if [ ! -e /etc/ssl/dhparam.pem ]; then
31+ echo " (*) Enabling HTTPS Strict Transport Security (HSTS) support..."
32+ mv /etc/nginx/nginx.conf $HESTIA_BACKUP /conf/
33+ cp -f $hestiacp /nginx/nginx.conf /etc/nginx/
2934
30- # Load global variables
31- source $HESTIA /conf/hestia.conf
32-
33- # Load hestia main functions
34- source /usr/local/hestia/func/main.sh
35-
36- # Detect OS
37- case $( head -n1 /etc/issue | cut -f 1 -d ' ' ) in
38- Debian) os=" debian" ;;
39- Ubuntu) os=" ubuntu" ;;
40- esac
41-
42- # Detect release for Debian
43- if [ " $os " = " debian" ]; then
44- release=$( cat /etc/debian_version| grep -o [0-9]| head -n1)
45- VERSION=' debian'
46- elif [ " $os " = " ubuntu" ]; then
47- release=" $( lsb_release -s -r) "
48- VERSION=' ubuntu'
49- fi
35+ # Copy dhparam
36+ cp -f $hestiacp /ssl/dhparam.pem /etc/ssl/
5037
51- # Configure apt to retry downloading on error
52- if [ ! -f /etc/apt/apt .conf.d/80-retries ] ; then
53- echo " APT::Acquire::Retries \" 3 \" ; " > /etc/apt/apt .conf.d/80-retries
38+ # Update DNS servers in nginx.conf
39+ dns_resolver= $( cat /etc/resolv .conf | grep -i ' ^nameserver ' | cut -d ' ' -f2 | tr ' \r\n ' ' ' | xargs )
40+ sed -i " s/1.0.0.1 1.1.1.1/ $dns_resolver /g " /etc/nginx/nginx .conf
5441fi
5542
56- # Update default page templates
57- echo " (*) Replacing default templates and packages..."
58-
5943# Back up default package and install latest version
6044if [ -d $HESTIA /data/packages/ ]; then
45+ echo " (*) Replacing default packages..."
6146 cp -f $HESTIA /data/packages/default.pkg $HESTIA_BACKUP /packages/
6247fi
6348
49+ # Back up old template files and install the latest versions
50+ if [ -d $HESTIA /data/templates/ ]; then
51+ echo " (*) Replacing default Web, DNS, and Mail templates..."
52+ cp -rf $HESTIA /data/templates $HESTIA_BACKUP /templates/
53+ $HESTIA /bin/v-update-web-templates > /dev/null 2>&1
54+ $HESTIA /bin/v-update-dns-templates > /dev/null 2>&1
55+ $HESTIA /bin/v-update-mail-templates > /dev/null 2>&1
56+ fi
57+
6458# Remove old Office 365 template as there is a newer version with an updated name
6559if [ -f $HESTIA /data/templates/dns/o365.tpl ]; then
6660 rm -f $HESTIA /data/templates/dns/o365.tpl
@@ -178,16 +172,16 @@ if [ ! -f /etc/cron.daily/php-session-cleanup ]; then
178172 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
179173 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
180174fi
181- chmod 755 /etc/cron.daily/php-session-cleanup
175+ chmod 755 /etc/cron.daily/php-session-cleanup
182176
183177# Fix empty pool error message for MultiPHP
184178php_versions=$( ls /etc/php/* /fpm -d 2> /dev/null | wc -l)
185179if [ " $php_versions " -gt 1 ]; then
180+ echo " (*) Updating Multi-PHP configuration..."
186181 for v in $( ls /etc/php/) ; do
187182 if [ ! -d " /etc/php/$v /fpm/pool.d/" ]; then
188183 continue
189184 fi
190- echo " (*) Updating Multi-PHP configuration..."
191185 cp -f $hestiacp /php-fpm/dummy.conf /etc/php/$v /fpm/pool.d/
192186 v1=$( echo " $v " | sed -e ' s/[.]//' )
193187 sed -i " s/9999/99$v1 /g" /etc/php/$v /fpm/pool.d/dummy.conf
@@ -260,14 +254,15 @@ if [ ! -z "$WEBALIZER_CHECK" ]; then
260254 sed -i " s/STATS_SYSTEM='webalizer,awstats'/STATS_SYSTEM='awstats'/g" $HESTIA /conf/hestia.conf
261255fi
262256
263- # Enable SFTP chroot jail capabilities
264- $HESTIA /bin/v-add-sys-sftp-jail no
257+ # Run sftp jail once
258+ $HESTIA /bin/v-add-sys-sftp-jail
265259
266260# Enable SFTP subsystem for SSH
267261sftp_subsys_enabled=$( grep -iE " ^#?.*subsystem.+(sftp )?sftp-server" /etc/ssh/sshd_config)
268262if [ ! -z " $sftp_subsys_enabled " ]; then
269263 echo " (*) Updating SFTP subsystem configuration..."
270264 sed -i -E " s/^#?.*Subsystem.+(sftp )?sftp-server/Subsystem sftp internal-sftp/g" /etc/ssh/sshd_config
265+ systemctl restart ssh
271266fi
272267
273268# Remove and migrate obsolete object keys
@@ -289,23 +284,3 @@ for user in `ls /usr/local/hestia/data/users/`; do
289284 done
290285 sed -i " s/\sFORCESSL=''//g" $USER_DATA /web.conf
291286done
292-
293- # Reset backend port
294- if [ ! -z " $BACKEND_PORT " ]; then
295- /usr/local/hestia/bin/v-change-sys-port $BACKEND_PORT
296- fi
297-
298- # Move clamav to proper location - https://goo.gl/zNuM11
299- if [ ! -d /usr/local/hestia/web/edit/server/clamav-daemon ]; then
300- mv /usr/local/hestia/web/edit/server/clamd /usr/local/web/edit/server/clamav-daemon
301- fi
302-
303- # Fix named rule for AppArmor - https://goo.gl/SPqHdq
304- if [ " $DNS_SYSTEM " = ' bind9' ] && [ ! -f /etc/apparmor.d/local/usr.sbin.named ]; then
305- echo " /home/** rwm," >> /etc/apparmor.d/local/usr.sbin.named 2> /dev/null
306- fi
307-
308- # Remove obsolete ports.conf if exists.
309- if [ -f /usr/local/hestia/data/firewall/ports.conf ]; then
310- rm -f /usr/local/hestia/data/firewall/ports.conf
311- fi
0 commit comments