Skip to content

Commit 2bfb9d7

Browse files
author
Kristan Kenney
committed
Merge branch 'main' into feature/user-roles
2 parents b9ef8be + 8eb5219 commit 2bfb9d7

File tree

6 files changed

+105
-119
lines changed

6 files changed

+105
-119
lines changed
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,35 @@
33
# options: [SYSTEM]
44
# labels:
55
#
6-
# example: v-restore-sys-config
6+
# example: v-repair-sys-config
77
#
8-
# The function restores system configuration file
8+
# The function repairs or restores the system configuration file.
99

10-
system=$1
10+
mode=$1
1111

1212
# Includes
1313
# shellcheck source=/usr/local/hestia/func/main.sh
1414
source $HESTIA/func/main.sh
1515
# shellcheck source=/usr/local/hestia/func/syshealth.sh
1616
source $HESTIA/func/syshealth.sh
1717

18+
1819
#----------------------------------------------------------#
1920
# Action #
2021
#----------------------------------------------------------#
2122

22-
syshealth_restore_system_installed_config
23+
if [ "$mode" = "restore" ]; then
24+
syshealth_restore_system_config
25+
fi
26+
27+
if [ "$mode" = "repair" ]; then
28+
# shellcheck source=/usr/local/hestia/conf/hestia.conf
29+
source $HESTIA/conf/hestia.conf
30+
syshealth_repair_system_config
31+
fi
2332

2433
#----------------------------------------------------------#
2534
# Hestia #
2635
#----------------------------------------------------------#
36+
log_history "executed $mode operation on system configuration file." '' 'admin'
2737
log_event "$OK" "$ARGUMENTS"

bin/v-search-command

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ check_hestia_demo_mode
3535
# Action #
3636
#----------------------------------------------------------#
3737

38-
SearchPath=`ls -a $HESTIA/bin/ | sort`
38+
SearchResults=`ls -a $HESTIA/bin/ | sort`
3939
TotalItems=`ls -a $HESTIA/bin/ | sort | wc -l`
4040

41+
4142
for i; do
42-
SearchResults=`echo $SearchPath | tr " " "\n" | grep $i`
43+
SearchResults=`echo $SearchResults | tr " " "\n" | grep $i`
4344
FoundItems=`echo $SearchResults | tr " " "\n" | grep $i | wc -l`
4445
done
4546

func/syshealth.sh

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,20 @@ function syshealth_repair_web_config() {
147147
done
148148
}
149149

150-
function syshealth_restore_system_installed_config() {
150+
function syshealth_update_system_config_format() {
151+
# SYSTEM CONFIGURATION
152+
# Create array of known keys in configuration file
153+
system="system"
154+
known_keys=(ANTISPAM_SYSTEM ANTIVIRUS_SYSTEM API_ALLOWED_IP API BACKEND_PORT BACKUP_GZIP BACKUP_MODE BACKUP_SYSTEM CRON_SYSTEM DB_PMA_ALIAS DB_SYSTEM DISK_QUOTA DNS_SYSTEM ENFORCE_SUBDOMAIN_OWNERSHIP FILE_MANAGER FIREWALL_EXTENSION FIREWALL_SYSTEM FTP_SYSTEM IMAP_SYSTEM INACTIVE_SESSION_TIMEOUT LANGUAGE LOGIN_STYLE MAIL_SYSTEM PROXY_PORT PROXY_SSL_PORT PROXY_SYSTEM RELEASE_BRANCH STATS_SYSTEM THEME UPDATE_HOSTNAME_SSL UPGRADE_SEND_EMAIL UPGRADE_SEND_EMAIL_LOG WEB_BACKEND WEBMAIL_ALIAS WEBMAIL_SYSTEM WEB_PORT WEB_RGROUPS WEB_SSL WEB_SSL_PORT WEB_SYSTEM VERSION)
155+
write_kv_config_file
156+
unset system
157+
unset known_keys
158+
}
159+
160+
161+
# Restore System Configuration
162+
# Replaces $HESTIA/conf/hestia.conf with "known good defaults" file ($HESTIA/conf/defaults/hestia.conf)
163+
function syshealth_restore_system_config() {
151164
if [ -f "$HESTIA/conf/defaults/hestia.conf" ]; then
152165
mv $HESTIA/conf/hestia.conf $HESTIA/conf/hestia.conf.old
153166
cp $HESTIA/conf/defaults/hestia.conf $HESTIA/conf/hestia.conf
@@ -179,14 +192,14 @@ function syshealth_repair_system_config() {
179192
if [ ! -z "$DB_SYSTEM" ]; then
180193
if [ "$DB_SYSTEM" = "mysql" ]; then
181194
if [ -z "$DB_PMA_ALIAS" ]; then
182-
echo "[ ! ] Adding missing variable to hestia.conf: DB_PMA_ALIAS ('phpMyAdmin')"
183-
$BIN/v-change-sys-config-value 'DB_PMA_ALIAS' 'phpMyAdmin'
195+
echo "[ ! ] Adding missing variable to hestia.conf: DB_PMA_ALIAS ('phpmyadmin)"
196+
$BIN/v-change-sys-config-value 'DB_PMA_ALIAS' 'phpmyadmin'
184197
fi
185198
fi
186199
if [ "$DB_SYSTEM" = "pgsql" ]; then
187200
if [ -z "$DB_PGA_ALIAS" ]; then
188-
echo "[ ! ] Adding missing variable to hestia.conf: DB_PGA_ALIAS ('phpPgAdmin')"
189-
$BIN/v-change-sys-config-value 'DB_PGA_ALIAS' 'phpPgAdmin'
201+
echo "[ ! ] Adding missing variable to hestia.conf: DB_PGA_ALIAS ('phppgadmin')"
202+
$BIN/v-change-sys-config-value 'DB_PGA_ALIAS' 'phppgadmin'
190203
fi
191204
fi
192205
fi
@@ -199,8 +212,8 @@ function syshealth_repair_system_config() {
199212

200213
# Theme
201214
if [ -z "$THEME" ]; then
202-
echo "[ ! ] Adding missing variable to hestia.conf: THEME ('default')"
203-
$BIN/v-change-sys-config-value 'THEME' 'default'
215+
echo "[ ! ] Adding missing variable to hestia.conf: THEME ('dark')"
216+
$BIN/v-change-sys-config-value 'THEME' 'dark'
204217
fi
205218

206219
# Default language
@@ -242,7 +255,6 @@ function syshealth_repair_system_config() {
242255
# File Manager
243256
if [ -z "$FILE_MANAGER" ]; then
244257
echo "[ ! ] Adding missing variable to hestia.conf: FILE_MANAGER ('true')"
245-
echo "[ ! ] File Manager is enabled but not installed, repairing components..."
246258
$BIN/v-add-sys-filemanager quiet
247259
fi
248260

install/hst-install-debian.sh

Lines changed: 36 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ installer_dependencies="apt-transport-https curl dirmngr gnupg wget ca-certifica
7171
help() {
7272
echo "Usage: $0 [OPTIONS]
7373
-a, --apache Install Apache [yes|no] default: yes
74-
-n, --nginx Install Nginx [yes|no] default: yes
7574
-w, --phpfpm Install PHP-FPM [yes|no] default: yes
7675
-o, --multiphp Install Multi-PHP [yes|no] default: no
7776
-v, --vsftpd Install Vsftpd [yes|no] default: yes
@@ -182,7 +181,6 @@ for arg; do
182181
delim=""
183182
case "$arg" in
184183
--apache) args="${args}-a " ;;
185-
--nginx) args="${args}-n " ;;
186184
--phpfpm) args="${args}-w " ;;
187185
--vsftpd) args="${args}-v " ;;
188186
--proftpd) args="${args}-j " ;;
@@ -214,10 +212,9 @@ done
214212
eval set -- "$args"
215213

216214
# Parsing arguments
217-
while getopts "a:n:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
215+
while getopts "a:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
218216
case $Option in
219217
a) apache=$OPTARG ;; # Apache
220-
n) nginx=$OPTARG ;; # Nginx
221218
w) phpfpm=$OPTARG ;; # PHP-FPM
222219
o) multiphp=$OPTARG ;; # Multi-PHP
223220
v) vsftpd=$OPTARG ;; # Vsftpd
@@ -453,9 +450,9 @@ clear
453450
install_welcome_message
454451

455452
# Web stack
456-
if [ "$nginx" = 'yes' ]; then
457-
echo ' - NGINX Web / Proxy Server'
458-
fi
453+
454+
echo ' - NGINX Web / Proxy Server'
455+
459456
if [ "$apache" = 'yes' ] && [ "$nginx" = 'no' ] ; then
460457
echo ' - Apache Web Server'
461458
fi
@@ -605,11 +602,10 @@ echo "Adding required repositories to proceed with installation:"
605602
echo
606603

607604
# Installing Nginx repo
608-
if [ "$nginx" = 'yes' ]; then
609-
echo "[ * ] NGINX"
610-
echo "deb [arch=amd64] https://nginx.org/packages/mainline/$VERSION/ $codename nginx" > $apt/nginx.list
611-
apt-key adv --fetch-keys 'https://nginx.org/keys/nginx_signing.key' > /dev/null 2>&1
612-
fi
605+
echo "[ * ] NGINX"
606+
echo "deb [arch=amd64] https://nginx.org/packages/mainline/$VERSION/ $codename nginx" > $apt/nginx.list
607+
apt-key adv --fetch-keys 'https://nginx.org/keys/nginx_signing.key' > /dev/null 2>&1
608+
613609

614610
# Installing sury PHP repo
615611
echo "[ * ] PHP"
@@ -752,9 +748,7 @@ fi
752748

753749
# Excluding packages
754750
software=$(echo "$software" | sed -e "s/apache2.2-common//")
755-
if [ "$nginx" = 'no' ]; then
756-
software=$(echo "$software" | sed -r -e 's/(\s|^)nginx(\s|$)/ /')
757-
fi
751+
758752
if [ "$apache" = 'no' ]; then
759753
software=$(echo "$software" | sed -e "s/apache2 //")
760754
software=$(echo "$software" | sed -e "s/apache2-bin//")
@@ -1000,15 +994,7 @@ touch $HESTIA/conf/hestia.conf
1000994
chmod 660 $HESTIA/conf/hestia.conf
1001995

1002996
# Web stack
1003-
if [ "$apache" = 'yes' ] && [ "$nginx" = 'no' ] ; then
1004-
write_config_value "WEB_SYSTEM" "apache2"
1005-
write_config_value "WEB_RGROUPS" "www-data"
1006-
write_config_value "WEB_PORT" "80"
1007-
write_config_value "WEB_SSL_PORT" "443"
1008-
write_config_value "WEB_SSL" "mod_ssl"
1009-
write_config_value "STATS_SYSTEM" "awstats"
1010-
fi
1011-
if [ "$apache" = 'yes' ] && [ "$nginx" = 'yes' ] ; then
997+
if [ "$apache" = 'yes' ]; then
1012998
write_config_value "WEB_SYSTEM" "apache2"
1013999
write_config_value "WEB_RGROUPS" "www-data"
10141000
write_config_value "WEB_PORT" "8080"
@@ -1019,12 +1005,13 @@ if [ "$apache" = 'yes' ] && [ "$nginx" = 'yes' ] ; then
10191005
write_config_value "PROXY_SSL_PORT" "443"
10201006
write_config_value "STATS_SYSTEM" "awstats"
10211007
fi
1022-
if [ "$apache" = 'no' ] && [ "$nginx" = 'yes' ]; then
1008+
if [ "$apache" = 'no' ]; then
10231009
write_config_value "WEB_SYSTEM" "nginx"
10241010
write_config_value "WEB_PORT" "80"
10251011
write_config_value "WEB_SSL_PORT" "443"
10261012
write_config_value "WEB_SSL" "openssl"
10271013
write_config_value "STATS_SYSTEM" "awstats"
1014+
10281015
fi
10291016

10301017
if [ "$release" -ge 9 ] || [ "$multiphp" = 'yes' ]; then
@@ -1180,35 +1167,33 @@ cp -f $HESTIA_INSTALL_DIR/ssl/dhparam.pem /etc/ssl
11801167
# Configure Nginx #
11811168
#----------------------------------------------------------#
11821169

1183-
if [ "$nginx" = 'yes' ]; then
1184-
echo "[ * ] Configuring NGINX..."
1185-
rm -f /etc/nginx/conf.d/*.conf
1186-
cp -f $HESTIA_INSTALL_DIR/nginx/nginx.conf /etc/nginx/
1187-
cp -f $HESTIA_INSTALL_DIR/nginx/status.conf /etc/nginx/conf.d/
1188-
cp -f $HESTIA_INSTALL_DIR/nginx/phpmyadmin.inc /etc/nginx/conf.d/
1189-
cp -f $HESTIA_INSTALL_DIR/nginx/phppgadmin.inc /etc/nginx/conf.d/
1190-
cp -f $HESTIA_INSTALL_DIR/logrotate/nginx /etc/logrotate.d/
1191-
mkdir -p /etc/nginx/conf.d/domains
1192-
mkdir -p /etc/nginx/modules-enabled
1193-
mkdir -p /var/log/nginx/domains
1194-
1195-
# Update dns servers in nginx.conf
1196-
dns_resolver=$(cat /etc/resolv.conf | grep -i '^nameserver' | cut -d ' ' -f2 | tr '\r\n' ' ' | xargs)
1197-
for ip in $dns_resolver; do
1198-
if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
1199-
resolver="$ip $resolver"
1200-
fi
1201-
done
1202-
if [ ! -z "$resolver" ]; then
1203-
sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /etc/nginx/nginx.conf
1204-
sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /usr/local/hestia/nginx/conf/nginx.conf
1170+
echo "[ * ] Configuring NGINX..."
1171+
rm -f /etc/nginx/conf.d/*.conf
1172+
cp -f $HESTIA_INSTALL_DIR/nginx/nginx.conf /etc/nginx/
1173+
cp -f $HESTIA_INSTALL_DIR/nginx/status.conf /etc/nginx/conf.d/
1174+
cp -f $HESTIA_INSTALL_DIR/nginx/phpmyadmin.inc /etc/nginx/conf.d/
1175+
cp -f $HESTIA_INSTALL_DIR/nginx/phppgadmin.inc /etc/nginx/conf.d/
1176+
cp -f $HESTIA_INSTALL_DIR/logrotate/nginx /etc/logrotate.d/
1177+
mkdir -p /etc/nginx/conf.d/domains
1178+
mkdir -p /etc/nginx/modules-enabled
1179+
mkdir -p /var/log/nginx/domains
1180+
1181+
# Update dns servers in nginx.conf
1182+
dns_resolver=$(cat /etc/resolv.conf | grep -i '^nameserver' | cut -d ' ' -f2 | tr '\r\n' ' ' | xargs)
1183+
for ip in $dns_resolver; do
1184+
if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
1185+
resolver="$ip $resolver"
12051186
fi
1206-
1207-
update-rc.d nginx defaults > /dev/null 2>&1
1208-
systemctl start nginx >> $LOG
1209-
check_result $? "nginx start failed"
1187+
done
1188+
if [ ! -z "$resolver" ]; then
1189+
sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /etc/nginx/nginx.conf
1190+
sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /usr/local/hestia/nginx/conf/nginx.conf
12101191
fi
12111192

1193+
update-rc.d nginx defaults > /dev/null 2>&1
1194+
systemctl start nginx >> $LOG
1195+
check_result $? "nginx start failed"
1196+
12121197

12131198
#----------------------------------------------------------#
12141199
# Configure Apache #

0 commit comments

Comments
 (0)