Skip to content

Commit 4d792cc

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
2 parents c28e525 + 0a7164e commit 4d792cc

25 files changed

+416
-432
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

0 commit comments

Comments
 (0)