Skip to content

Commit c184675

Browse files
author
Kristan Kenney
committed
Merge branch 'feature/system-health-check' into main
2 parents 1d5ef6b + 21fcb38 commit c184675

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
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"

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

0 commit comments

Comments
 (0)