Skip to content

Commit a0f7e93

Browse files
author
Kristan Kenney
committed
Refactoring of backend code
- Ensure Webalizer is removed - Rework upgrade script routines - Enable 4096-bit dhparam for dovecot - Remove unnecessary OS detection code - Update version detection in installers - Add global var for installer files - Update copyright infomation
1 parent 873d20c commit a0f7e93

File tree

26 files changed

+394
-549
lines changed

26 files changed

+394
-549
lines changed

bin/v-add-sys-ip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ if [ ! -z "$WEB_SYSTEM" ]; then
130130
echo "NameVirtualHost $ip:$WEB_PORT" > $web_conf
131131
fi
132132
echo "Listen $ip:$WEB_PORT" >> $web_conf
133-
cat $HESTIA/install/deb/apache2/unassigned.conf >> $web_conf
133+
cat $HESTIA_INSTALL_DIR/apache2/unassigned.conf >> $web_conf
134134
sed -i 's/directIP/'$ip'/g' $web_conf
135135
sed -i 's/directPORT/'$WEB_PORT'/g' $web_conf
136136

137137
elif [ "$WEB_SYSTEM" = 'nginx' ]; then
138-
cp -f $HESTIA/install/deb/nginx/unassigned.inc $web_conf
138+
cp -f $HESTIA_INSTALL_DIR/nginx/unassigned.inc $web_conf
139139
sed -i 's/directIP/'$ip'/g' $web_conf
140140
fi
141141

bin/v-add-web-php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ if [ -f "$php_fpm" ] && [ -f "$HESTIA/data/templates/$WEB_SYSTEM/PHP-$version.sh
3939
fi
4040

4141
# Check if php version is supported
42-
if [ ! -f "$HESTIA/install/deb/multiphp/$WEB_SYSTEM/PHP-${version//.}.sh" ]; then
42+
if [ ! -f "$HESTIA_INSTALL_DIR/multiphp/$WEB_SYSTEM/PHP-${version//.}.sh" ]; then
4343
echo "Version is currently not supported or does not exist..."
4444
exit
4545
fi
@@ -100,15 +100,15 @@ fi
100100
update-rc.d php$version-fpm defaults > /dev/null 2>&1
101101
v_tpl=$(echo "$version" | sed -e 's/[.]//')
102102
rm -f /etc/php/$version/fpm/pool.d/*
103-
cp -f $HESTIA/install/deb/php-fpm/dummy.conf /etc/php/$version/fpm/pool.d/
103+
cp -f $HESTIA_INSTALL_DIR/php-fpm/dummy.conf /etc/php/$version/fpm/pool.d/
104104
sed -i "s/9999/99$v_tpl/g" /etc/php/$version/fpm/pool.d/dummy.conf
105105

106106
# Install php templates
107-
cp -f $HESTIA/install/deb/multiphp/$WEB_SYSTEM/PHP-${version//.}.sh \
107+
cp -f $HESTIA_INSTALL_DIR/multiphp/$WEB_SYSTEM/PHP-${version//.}.sh \
108108
$HESTIA/data/templates/web/$WEB_SYSTEM/
109-
cp -f $HESTIA/install/deb/multiphp/$WEB_SYSTEM/PHP-${version//.}.tpl \
109+
cp -f $HESTIA_INSTALL_DIR/multiphp/$WEB_SYSTEM/PHP-${version//.}.tpl \
110110
$HESTIA/data/templates/web/$WEB_SYSTEM/
111-
cp -f $HESTIA/install/deb/multiphp/$WEB_SYSTEM/PHP-${version//.}.stpl \
111+
cp -f $HESTIA_INSTALL_DIR/multiphp/$WEB_SYSTEM/PHP-${version//.}.stpl \
112112
$HESTIA/data/templates/web/$WEB_SYSTEM/
113113
chmod a+x $HESTIA/data/templates/web/$WEB_SYSTEM/PHP-${version//.}.sh
114114

bin/v-update-dns-templates

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,12 @@ restart=$1
1616
source $HESTIA/func/main.sh
1717
source $HESTIA/conf/hestia.conf
1818

19-
# Detect OS
20-
case $(head -n1 /etc/issue | cut -f 1 -d ' ') in
21-
Debian) type="debian" ;;
22-
Ubuntu) type="ubuntu" ;;
23-
*) type="NoSupport" ;;
24-
esac
25-
26-
# Detect version
27-
if [ "$type" = "ubuntu" ] || [ "$type" = "debian" ]; then
28-
type="deb"
29-
else
30-
echo "Error: can't detect supported os"
31-
log_event "$E_NOTEXIST"
32-
exit $E_NOTEXIST
33-
fi
34-
35-
3619
#----------------------------------------------------------#
3720
# Action #
3821
#----------------------------------------------------------#
3922

4023
# Update templates
41-
cp -rf $HESTIA/install/$type/templates/dns $HESTIA/data/templates/
42-
24+
cp -rf $HESTIA_INSTALL_DIR/templates/dns $HESTIA/data/templates/
4325

4426
#----------------------------------------------------------#
4527
# Hestia #

bin/v-update-mail-templates

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,12 @@ restart=$1
1616
source $HESTIA/func/main.sh
1717
source $HESTIA/conf/hestia.conf
1818

19-
# Detect OS
20-
case $(head -n1 /etc/issue | cut -f 1 -d ' ') in
21-
Debian) type="debian" ;;
22-
Ubuntu) type="ubuntu" ;;
23-
*) type="NoSupport" ;;
24-
esac
25-
26-
# Detect version
27-
if [ "$type" = "ubuntu" ] || [ "$type" = "debian" ]; then
28-
type="deb"
29-
else
30-
echo "Error: can't detect supported os"
31-
log_event "$E_NOTEXIST"
32-
exit $E_NOTEXIST
33-
fi
34-
35-
3619
#----------------------------------------------------------#
3720
# Action #
3821
#----------------------------------------------------------#
3922

4023
# Update templates
41-
cp -rf $HESTIA/install/$type/templates/mail $HESTIA/data/templates/
24+
cp -rf $HESTIA_INSTALL_DIR/templates/mail $HESTIA/data/templates/
4225

4326
# Rebuild mail domains if mail services are enabled
4427
if [ ! -z $MAIL_SYSTEM ]; then

bin/v-update-web-templates

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,22 @@ restart=$1
1616
source $HESTIA/func/main.sh
1717
source $HESTIA/conf/hestia.conf
1818

19-
# Detect OS
20-
case $(head -n1 /etc/issue | cut -f 1 -d ' ') in
21-
Debian) type="debian" ;;
22-
Ubuntu) type="ubuntu" ;;
23-
*) type="NoSupport" ;;
24-
esac
25-
26-
# Detect version
27-
if [ "$type" = "ubuntu" ] || [ "$type" = "debian" ]; then
28-
type="deb"
29-
else
30-
echo "Error: can't detect supported os"
31-
log_event "$E_NOTEXIST"
32-
exit $E_NOTEXIST
33-
fi
34-
35-
if [ -z "$WEB_SYSTEM" ]; then
36-
echo "Error: Missing Web System"
37-
log_event "$E_ARGS"
38-
exit $E_ARGS
39-
fi
40-
41-
HST_WEBTEMPLATES="$HESTIA/data/templates/web"
42-
4319
#----------------------------------------------------------#
4420
# Action #
4521
#----------------------------------------------------------#
4622

4723
# Update templates
48-
if [ -d "${HST_WEBTEMPLATES}" ]; then
49-
rm -rf "${HST_WEBTEMPLATES}/skel" 2>/dev/null
50-
rm -rf "${HST_WEBTEMPLATES}/suspend" 2>/dev/null
51-
rm -rf "${HST_WEBTEMPLATES}/unassigned" 2>/dev/null
24+
if [ -d "${WEBTPL}" ]; then
25+
rm -rf "${WEBTPL}/skel" 2>/dev/null
26+
rm -rf "${WEBTPL}/suspend" 2>/dev/null
27+
rm -rf "${WEBTPL}/unassigned" 2>/dev/null
5228
fi
5329

54-
for webtpl_folder in $(ls $HESTIA/install/$type/templates/web/* -d 2>/dev/null | egrep -v '/(nginx)$' ); do
55-
cp -rf "${webtpl_folder}" "${HST_WEBTEMPLATES}/"
30+
for webtpl_folder in $(ls $HESTIA_INSTALL_DIR/templates/web/* -d 2>/dev/null | egrep -v '/(nginx)$' ); do
31+
cp -rf "${webtpl_folder}" "${WEBTPL}/"
5632
done
5733

58-
[ -d "${HST_WEBTEMPLATES}/nginx" ] || mkdir -p "${HST_WEBTEMPLATES}/nginx"
34+
[ -d "${WEBTPL}/nginx" ] || mkdir -p "${WEBTPL}/nginx"
5935

6036
# Update Multi-PHP templates
6137
php_versions=$(ls /etc/php/*/fpm -d 2>/dev/null | wc -l)
@@ -65,20 +41,20 @@ if [ "$php_versions" -gt 1 ]; then
6541
continue
6642
fi
6743
v_tpl=$(echo "$v" | sed -e 's/[.]//')
68-
cp -f "$HESTIA/install/$type/multiphp/${WEB_SYSTEM}/PHP-${v_tpl}".* "${HST_WEBTEMPLATES}/${WEB_SYSTEM}/"
44+
cp -f "$HESTIA_INSTALL_DIR/multiphp/${WEB_SYSTEM}/PHP-${v_tpl}".* "${WEBTPL}/${WEB_SYSTEM}/"
6945
done
70-
chmod a+x "${HST_WEBTEMPLATES}/${WEB_SYSTEM}/"*.sh 2> /dev/null
46+
chmod a+x "${WEBTPL}/${WEB_SYSTEM}/"*.sh 2> /dev/null
7147

7248
# Create default TPL symlink when missing and point to the last php version found
7349
if [ ! -z $v_tpl ] && [ "$WEB_SYSTEM" = "nginx" ]; then
74-
[ -e "${HST_WEBTEMPLATES}/${WEB_SYSTEM}/default.sh" ] || ln -s "${HST_WEBTEMPLATES}/${WEB_SYSTEM}/PHP-${v_tpl}.sh" "${HST_WEBTEMPLATES}/${WEB_SYSTEM}/default.sh"
75-
[ -e "${HST_WEBTEMPLATES}/${WEB_SYSTEM}/default.tpl" ] || ln -s "${HST_WEBTEMPLATES}/${WEB_SYSTEM}/PHP-${v_tpl}.tpl" "${HST_WEBTEMPLATES}/${WEB_SYSTEM}/default.tpl"
76-
[ -e "${HST_WEBTEMPLATES}/${WEB_SYSTEM}/default.stpl" ] || ln -s "${HST_WEBTEMPLATES}/${WEB_SYSTEM}/PHP-${v_tpl}.stpl" "${HST_WEBTEMPLATES}/${WEB_SYSTEM}/default.stpl"
50+
[ -e "${WEBTPL}/${WEB_SYSTEM}/default.sh" ] || ln -s "${WEBTPL}/${WEB_SYSTEM}/PHP-${v_tpl}.sh" "${WEBTPL}/${WEB_SYSTEM}/default.sh"
51+
[ -e "${WEBTPL}/${WEB_SYSTEM}/default.tpl" ] || ln -s "${WEBTPL}/${WEB_SYSTEM}/PHP-${v_tpl}.tpl" "${WEBTPL}/${WEB_SYSTEM}/default.tpl"
52+
[ -e "${WEBTPL}/${WEB_SYSTEM}/default.stpl" ] || ln -s "${WEBTPL}/${WEB_SYSTEM}/PHP-${v_tpl}.stpl" "${WEBTPL}/${WEB_SYSTEM}/default.stpl"
7753
fi
7854
fi
7955

8056
if [ "$PROXY_SYSTEM" = 'nginx' ] || [ "$php_versions" -le 1 ]; then
81-
cp -rf "${HESTIA}/install/${type}/templates/web/nginx" "${HST_WEBTEMPLATES}/"
57+
cp -rf "${HESTIA_INSTALL_DIR}/templates/web/nginx" "${WEBTPL}/"
8258
fi
8359

8460
# Rebuilding web domains

func/main.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ BACKUP_DISK_LIMIT=95
77
BACKUP_LA_LIMIT=`cat /proc/cpuinfo | grep processor | wc -l`
88
RRD_STEP=300
99
BIN=$HESTIA/bin
10+
HESTIA_INSTALL_DIR=$HESTIA/install/deb
11+
HESTIA_BACKUP="/root/hst_backups/$(date +%d%m%Y%H%M)"
1012
USER_DATA=$HESTIA/data/users/$user
1113
WEBTPL=$HESTIA/data/templates/web
1214
MAILTPL=$HESTIA/data/templates/mail

func/upgrade.sh

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
#!/bin/bash
2+
3+
# Hestia Control Panel - Upgrade Control Script
4+
5+
#####################################################################
6+
####### Functions & Initialization #######
7+
#####################################################################
8+
9+
function upgrade_welcome_message() {
10+
echo
11+
echo ' _ _ _ _ ____ ____ '
12+
echo ' | | | | ___ ___| |_(_) __ _ / ___| _ \ '
13+
echo ' | |_| |/ _ \/ __| __| |/ _` | | | |_) | '
14+
echo ' | _ | __/\__ \ |_| | (_| | |___| __/ '
15+
echo ' |_| |_|\___||___/\__|_|\__,_|\____|_| '
16+
echo ""
17+
echo " Hestia Control Panel Upgrade Script"
18+
echo " Version: $new_version "
19+
echo "==================================================="
20+
echo ""
21+
echo "Please note that some configuration and template"
22+
echo "files may be replaced during the upgrade process."
23+
echo ""
24+
echo "Backups of these files will be available under:"
25+
echo "$HESTIA_BACKUP/"
26+
echo ""
27+
echo "This process may take a few minutes, please wait..."
28+
echo ""
29+
}
30+
31+
function upgrade_complete_message() {
32+
# Add notification to panel
33+
$HESTIA/bin/v-add-user-notification admin 'Upgrade complete' 'Your server has been updated to Hestia Control Panel version '$new_version'.<br>Please report any bugs on GitHub at<br><a href="https://github.com/hestiacp/hestiacp/Issues" target="_new">https://github.com/hestiacp/hestiacp/Issues</a><br><br>Have a great day!'
34+
35+
# Echo message to console output
36+
echo ""
37+
echo " Upgrade complete! Please report any bugs or issues to"
38+
echo " https://github.com/hestiacp/hestiacp/issues"
39+
echo ""
40+
echo " We hope that you enjoy this release of Hestia Control Panel,"
41+
echo " enjoy your day!"
42+
echo ""
43+
echo " Sincerely,"
44+
echo " The Hestia Control Panel development team"
45+
echo ""
46+
echo " www.hestiacp.com"
47+
echo " Made with love & pride by the open-source community around the world."
48+
echo ""
49+
echo ""
50+
}
51+
52+
function upgrade_init_backup() {
53+
# Ensure that backup directories are created
54+
mkdir -p $HESTIA_BACKUP/conf/
55+
mkdir -p $HESTIA_BACKUP/packages/
56+
mkdir -p $HESTIA_BACKUP/templates/
57+
}
58+
59+
function upgrade_start_routine() {
60+
61+
#####################################################################
62+
####### Start upgrade for pre-release builds #######
63+
#####################################################################
64+
65+
if [ $VERSION = "0.9.8-25" ] || [ $VERSION = "0.9.8-26" ] || [ $VERSION = "0.9.8-27" ] || [ $VERSION = "0.9.8-28" ] || [ $VERSION = "0.9.8-29" ] || [ $VERSION = "0.10.0" ] || [ $VERSION = "1.00.0-190618" ] || [ $VERSION = "1.00.0-190621" ]; then
66+
source $HESTIA_INSTALL_DIR/upgrade/versions/previous/0.9.8-29.sh
67+
source $HESTIA_INSTALL_DIR/upgrade/versions/previous/1.00.0-190618.sh
68+
source $HESTIA_INSTALL_DIR/upgrade/versions/previous/1.0.1.sh
69+
VERSION="1.0.1"
70+
fi
71+
72+
#####################################################################
73+
####### Start standard upgrade process #######
74+
#####################################################################
75+
76+
# Upgrade to Version 1.0.2
77+
if [ $VERSION = "1.0.1" ]; then
78+
source $HESTIA_INSTALL_DIR/upgrade/versions/previous/1.0.2.sh
79+
VERSION="1.0.2"
80+
fi
81+
82+
# Upgrade to Version 1.0.3
83+
if [ $VERSION = "1.0.2" ]; then
84+
source $HESTIA_INSTALL_DIR/upgrade/versions/latest.sh
85+
VERSION="$new_version"
86+
fi
87+
88+
# Ensure that latest upgrade commands are processed if version is the same
89+
if [ $VERSION = "$new_version" ]; then
90+
echo "(!) The latest version of Hestia Control Panel ($new_version) is already installed."
91+
echo " Verifying configuration..."
92+
echo ""
93+
source $HESTIA_INSTALL_DIR/upgrade/versions/latest.sh
94+
VERSION="$new_version"
95+
fi
96+
97+
#####################################################################
98+
####### End upgrade process #######
99+
#####################################################################
100+
}
101+
102+
function upgrade_phpmyadmin() {
103+
# Define version check function
104+
function version_ge(){ test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" -o ! -z "$1" -a "$1" = "$2"; }
105+
106+
pma_release_file=$(ls /usr/share/phpmyadmin/RELEASE-DATE-* 2>/dev/null |tail -n 1)
107+
if version_ge "${pma_release_file##*-}" "$pma_v"; then
108+
echo "(*) phpMyAdmin $pma_v or newer is already installed: ${pma_release_file##*-}, skipping update..."
109+
else
110+
# Display upgrade information
111+
echo "(*) Upgrade phpMyAdmin to v$pma_v..."
112+
[ -d /usr/share/phpmyadmin ] || mkdir -p /usr/share/phpmyadmin
113+
114+
# Download latest phpMyAdmin release
115+
wget --quiet https://files.phpmyadmin.net/phpMyAdmin/$pma_v/phpMyAdmin-$pma_v-all-languages.tar.gz
116+
117+
# Unpack files
118+
tar xzf phpMyAdmin-$pma_v-all-languages.tar.gz
119+
120+
# Delete file to prevent error
121+
rm -fr /usr/share/phpmyadmin/doc/html
122+
123+
# Overwrite old files
124+
cp -rf phpMyAdmin-$pma_v-all-languages/* /usr/share/phpmyadmin
125+
126+
# Set config and log directory
127+
sed -i "s|define('CONFIG_DIR', '');|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
128+
sed -i "s|define('TEMP_DIR', './tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
129+
130+
# Create temporary folder and change permissions
131+
if [ ! -d /usr/share/phpmyadmin/tmp ]; then
132+
mkdir /usr/share/phpmyadmin/tmp
133+
chmod 777 /usr/share/phpmyadmin/tmp
134+
fi
135+
136+
# Clean up source files
137+
rm -fr phpMyAdmin-$pma_v-all-languages
138+
rm -f phpMyAdmin-$pma_v-all-languages.tar.gz
139+
fi
140+
}
141+
142+
function upgrade_set_version() {
143+
# Set new version number in hestia.conf
144+
sed -i "/VERSION/d" $HESTIA/conf/hestia.conf
145+
echo "VERSION='$new_version'" >> $HESTIA/conf/hestia.conf
146+
}
147+
148+
function upgrade_rebuild_users() {
149+
for user in `ls /usr/local/hestia/data/users/`; do
150+
echo "(*) Rebuilding domains and account for user: $user..."
151+
if [ ! -z $WEB_SYSTEM ]; then
152+
$BIN/v-rebuild-web-domains $user >/dev/null 2>&1
153+
fi
154+
if [ ! -z $DNS_SYSTEM ]; then
155+
$BIN/v-rebuild-dns-domains $user >/dev/null 2>&1
156+
fi
157+
if [ ! -z $MAIL_SYSTEM ]; then
158+
$BIN/v-rebuild-mail-domains $user >/dev/null 2>&1
159+
fi
160+
done
161+
}
162+
163+
function upgrade_restart_services() {
164+
echo "(*) Restarting services..."
165+
if [ ! -z $MAIL_SYSTEM ]; then
166+
$BIN/v-restart-mail $restart
167+
fi
168+
if [ ! -z $IMAP_SYSTEM ]; then
169+
$BIN/v-restart-service $IMAP_SYSTEM $restart
170+
fi
171+
if [ ! -z $WEB_SYSTEM ]; then
172+
$BIN/v-restart-web $restart
173+
$BIN/v-restart-proxy $restart
174+
fi
175+
if [ ! -z $DNS_SYSTEM ]; then
176+
$BIN/v-restart-dns $restart
177+
fi
178+
for v in `ls /etc/php/`; do
179+
if [ -e /etc/php/$v/fpm ]; then
180+
$BIN/v-restart-service php$v-fpm $restart
181+
fi
182+
done
183+
if [ ! -z $FTP_SYSTEM ]; then
184+
$BIN/v-restart-ftp $restart
185+
fi
186+
187+
# Restart SSH daemon and Hestia Control Panel service
188+
$BIN/v-restart-service ssh $restart
189+
$BIN/v-restart-service hestia $restart
190+
}

install/deb/dovecot/conf.d/10-ssl.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ssl_cert = </usr/local/hestia/ssl/certificate.crt
77
ssl_key = </usr/local/hestia/ssl/certificate.key
88

99
# From and up to version 2.2
10-
ssl_dh_parameters_length = 2048
10+
ssl_dh_parameters_length = 4096
1111

1212
# From version 2.3
1313
#ssl_dh = </etc/ssl/dhparam.pem

0 commit comments

Comments
 (0)