Skip to content

Commit 3f84ec3

Browse files
author
Kristan Kenney
committed
Merge branch 'feature/system-health-check' into main
2 parents 0933487 + 7eabe99 commit 3f84ec3

File tree

2 files changed

+143
-130
lines changed

2 files changed

+143
-130
lines changed

func/syshealth.sh

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/bin/bash
2+
3+
# Hestia Control Panel - System Health Check Function Library
4+
5+
# Repair System Configuration
6+
# Adds missing variables to $HESTIA/conf/hestia.conf with safe default values
7+
function syshealth_repair_system_config () {
8+
# Release branch
9+
if [ -z "$RELEASE_BRANCH" ]; then
10+
echo "[ ! ] Adding missing variable to hestia.conf: RELEASE_BRANCH ('release')"
11+
$BIN/v-change-sys-config-value 'RELEASE_BRANCH' 'release'
12+
fi
13+
14+
# Webmail alias
15+
if [ ! -z "$IMAP_SYSTEM" ]; then
16+
if [ -z "$WEBMAIL_ALIAS" ]; then
17+
echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_ALIAS ('webmail')"
18+
$BIN/v-change-sys-config-value 'WEBMAIL_ALIAS' 'webmail'
19+
fi
20+
fi
21+
22+
# phpMyAdmin/phpPgAdmin alias
23+
if [ ! -z "$DB_SYSTEM" ]; then
24+
if [ "$DB_SYSTEM" = "mysql" ]; then
25+
if [ -z "$DB_PMA_ALIAS" ]; then
26+
echo "[ ! ] Adding missing variable to hestia.conf: DB_PMA_ALIAS ('phpMyAdmin')"
27+
$BIN/v-change-sys-config-value 'DB_PMA_ALIAS' 'phpMyAdmin'
28+
fi
29+
fi
30+
if [ "$DB_SYSTEM" = "pgsql" ]; then
31+
if [ -z "$DB_PGA_ALIAS" ]; then
32+
echo "[ ! ] Adding missing variable to hestia.conf: DB_PGA_ALIAS ('phpPgAdmin')"
33+
$BIN/v-change-sys-config-value 'DB_PGA_ALIAS' 'phpPgAdmin'
34+
fi
35+
fi
36+
fi
37+
38+
# Backup compression level
39+
if [ -z "$BACKUP_GZIP" ]; then
40+
echo "[ ! ] Adding missing variable to hestia.conf: BACKUP_GZIP ('9')"
41+
$BIN/v-change-sys-config-value 'BACKUP_GZIP' '9'
42+
fi
43+
44+
# Theme
45+
if [ -z "$THEME" ]; then
46+
echo "[ ! ] Adding missing variable to hestia.conf: THEME ('default')"
47+
$BIN/v-change-sys-config-value 'THEME' 'default'
48+
fi
49+
50+
# Default language
51+
if [ -z "$LANGUAGE" ]; then
52+
echo "[ ! ] Adding missing variable to hestia.conf: LANGUAGE ('en')"
53+
$BIN/v-change-sys-language 'en'
54+
fi
55+
56+
# Disk Quota
57+
if [ -z "$DISK_QUOTA" ]; then
58+
echo "[ ! ] Adding missing variable to hestia.conf: DISK_QUOTA ('no')"
59+
$BIN/v-change-sys-config-value 'DISK_QUOTA' 'no'
60+
fi
61+
62+
# CRON daemon
63+
if [ -z "$CRON_SYSTEM" ]; then
64+
echo "[ ! ] Adding missing variable to hestia.conf: CRON_SYSTEM ('cron')"
65+
$BIN/v-change-sys-config-value 'CRON_SYSTEM' 'cron'
66+
fi
67+
68+
# Backend port
69+
if [ -z "$BACKEND_PORT" ]; then
70+
echo "[ ! ] Adding missing variable to hestia.conf: BACKEND_PORT ('8083')"
71+
$BIN/v-change-sys-port '8083' >/dev/null 2>&1
72+
fi
73+
74+
# Upgrade: Send email notification
75+
if [ -z "$UPGRADE_SEND_EMAIL" ]; then
76+
echo "[ ! ] Adding missing variable to hestia.conf: UPGRADE_SEND_EMAIL ('true')"
77+
$BIN/v-change-sys-config-value 'UPGRADE_SEND_EMAIL' 'true'
78+
fi
79+
80+
# Upgrade: Send email notification
81+
if [ -z "$UPGRADE_SEND_EMAIL_LOG" ]; then
82+
echo "[ ! ] Adding missing variable to hestia.conf: UPGRADE_SEND_EMAIL_LOG ('false')"
83+
$BIN/v-change-sys-config-value 'UPGRADE_SEND_EMAIL_LOG' 'false'
84+
fi
85+
86+
# File Manager
87+
if [ -z "$FILE_MANAGER" ]; then
88+
echo "[ ! ] Adding missing variable to hestia.conf: FILE_MANAGER ('true')"
89+
echo "[ ! ] File Manager is enabled but not installed, repairing components..."
90+
$BIN/v-add-sys-filemanager quiet
91+
fi
92+
93+
# Support for ZSTD / GZIP Change
94+
if [ -z "$BACKUP_MODE" ]; then
95+
echo "[ ! ] Setting zstd backup compression type as default..."
96+
$BIN/v-change-sys-config-value "BACKUP_MODE" "zstd"
97+
fi
98+
99+
# Login style switcher
100+
if [ -z "$LOGIN_STYLE" ]; then
101+
echo "[ ! ] Adding missing variable to hestia.conf: LOGIN_STYLE ('default')"
102+
$BIN/v-change-sys-config-value "LOGIN_STYLE" "default"
103+
fi
104+
105+
# Webmail clients
106+
if [ -z "$WEBMAIL_SYSTEM" ]; then
107+
if [ -d "/var/lib/roundcube" ]; then
108+
echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_SYSTEM ('roundcube')"
109+
$BIN/v-change-sys-config-value "WEBMAIL_SYSTEM" "roundcube"
110+
else
111+
echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_SYSTEM ('')"
112+
$BIN/v-change-sys-config-value "WEBMAIL_SYSTEM" ""
113+
fi
114+
fi
115+
116+
# Inactive session timeout
117+
if [ -z "$INACTIVE_SESSION_TIMEOUT" ]; then
118+
echo "[ ! ] Adding missing variable to hestia.conf: INACTIVE_SESSION_TIMEOUT ('60')"
119+
$BIN/v-change-sys-config-value "INACTIVE_SESSION_TIMEOUT" "60"
120+
fi
121+
122+
# Enforce subdomain ownership
123+
if [ -z "$ENFORCE_SUBDOMAIN_OWNERSHIP" ]; then
124+
echo "[ ! ] Adding missing variable to hestia.conf: ENFORCE_SUBDOMAIN_OWNERSHIP ('yes')"
125+
$BIN/v-change-sys-config-value "ENFORCE_SUBDOMAIN_OWNERSHIP" "yes"
126+
fi
127+
128+
# API access allowed IP's
129+
if [ "$API" = "yes" ]; then
130+
check_api_key=$(grep "API_ALLOWED_IP" $HESTIA/conf/hestia.conf)
131+
if [ -z "$check_api_key" ]; then
132+
if [ -z "$API_ALLOWED_IP" ]; then
133+
echo "[ ! ] Adding missing variable to hestia.conf: API_ALLOWED_IP ('allow-all')"
134+
$BIN/v-change-sys-config-value "API_ALLOWED_IP" "allow-all"
135+
fi
136+
fi
137+
fi
138+
}

func/upgrade.sh

Lines changed: 5 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
# Hestia Control Panel - Upgrade Control Script
44

5+
# Import system health check and repair library
6+
source $HESTIA/func/syshealth.sh
7+
58
#####################################################################
69
####### Functions & Initialization #######
710
#####################################################################
@@ -16,6 +19,7 @@ is_debug_build() {
1619
}
1720

1821
upgrade_health_check() {
22+
1923
echo "============================================================================="
2024
echo "[ ! ] Performing system health check before proceeding with installation... "
2125
# Perform basic health check against hestia.conf to ensure that
@@ -30,137 +34,8 @@ upgrade_health_check() {
3034
echo
3135
fi
3236

33-
# Release branch
34-
if [ -z "$RELEASE_BRANCH" ]; then
35-
echo "[ ! ] Adding missing variable to hestia.conf: RELEASE_BRANCH ('release')"
36-
$BIN/v-change-sys-config-value 'RELEASE_BRANCH' 'release'
37-
fi
38-
39-
# Webmail alias
40-
if [ ! -z "$IMAP_SYSTEM" ]; then
41-
if [ -z "$WEBMAIL_ALIAS" ]; then
42-
echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_ALIAS ('webmail')"
43-
$BIN/v-change-sys-config-value 'WEBMAIL_ALIAS' 'webmail'
44-
fi
45-
fi
46-
47-
# phpMyAdmin/phpPgAdmin alias
48-
if [ ! -z "$DB_SYSTEM" ]; then
49-
if [ "$DB_SYSTEM" = "mysql" ]; then
50-
if [ -z "$DB_PMA_ALIAS" ]; then
51-
echo "[ ! ] Adding missing variable to hestia.conf: DB_PMA_ALIAS ('phpMyAdmin')"
52-
$BIN/v-change-sys-config-value 'DB_PMA_ALIAS' 'phpMyAdmin'
53-
fi
54-
fi
55-
if [ "$DB_SYSTEM" = "pgsql" ]; then
56-
if [ -z "$DB_PGA_ALIAS" ]; then
57-
echo "[ ! ] Adding missing variable to hestia.conf: DB_PGA_ALIAS ('phpPgAdmin')"
58-
$BIN/v-change-sys-config-value 'DB_PGA_ALIAS' 'phpPgAdmin'
59-
fi
60-
fi
61-
fi
62-
63-
# Backup compression level
64-
if [ -z "$BACKUP_GZIP" ]; then
65-
echo "[ ! ] Adding missing variable to hestia.conf: BACKUP_GZIP ('9')"
66-
$BIN/v-change-sys-config-value 'BACKUP_GZIP' '9'
67-
fi
68-
69-
# Theme
70-
if [ -z "$THEME" ]; then
71-
echo "[ ! ] Adding missing variable to hestia.conf: THEME ('default')"
72-
$BIN/v-change-sys-config-value 'THEME' 'default'
73-
fi
74-
75-
# Default language
76-
if [ -z "$LANGUAGE" ]; then
77-
echo "[ ! ] Adding missing variable to hestia.conf: LANGUAGE ('en')"
78-
$BIN/v-change-sys-language 'en'
79-
fi
80-
81-
# Disk Quota
82-
if [ -z "$DISK_QUOTA" ]; then
83-
echo "[ ! ] Adding missing variable to hestia.conf: DISK_QUOTA ('no')"
84-
$BIN/v-change-sys-config-value 'DISK_QUOTA' 'no'
85-
fi
86-
87-
# CRON daemon
88-
if [ -z "$CRON_SYSTEM" ]; then
89-
echo "[ ! ] Adding missing variable to hestia.conf: CRON_SYSTEM ('cron')"
90-
$BIN/v-change-sys-config-value 'CRON_SYSTEM' 'cron'
91-
fi
37+
syshealth_repair_system_config
9238

93-
# Backend port
94-
if [ -z "$BACKEND_PORT" ]; then
95-
echo "[ ! ] Adding missing variable to hestia.conf: BACKEND_PORT ('8083')"
96-
$BIN/v-change-sys-port '8083' >/dev/null 2>&1
97-
fi
98-
99-
# Upgrade: Send email notification
100-
if [ -z "$UPGRADE_SEND_EMAIL" ]; then
101-
echo "[ ! ] Adding missing variable to hestia.conf: UPGRADE_SEND_EMAIL ('true')"
102-
$BIN/v-change-sys-config-value 'UPGRADE_SEND_EMAIL' 'true'
103-
fi
104-
105-
# Upgrade: Send email notification
106-
if [ -z "$UPGRADE_SEND_EMAIL_LOG" ]; then
107-
echo "[ ! ] Adding missing variable to hestia.conf: UPGRADE_SEND_EMAIL_LOG ('false')"
108-
$BIN/v-change-sys-config-value 'UPGRADE_SEND_EMAIL_LOG' 'false'
109-
fi
110-
111-
# File Manager
112-
if [ -z "$FILE_MANAGER" ]; then
113-
echo "[ ! ] Adding missing variable to hestia.conf: FILE_MANAGER ('true')"
114-
echo "[ ! ] File Manager is enabled but not installed, repairing components..."
115-
$BIN/v-add-sys-filemanager quiet
116-
fi
117-
118-
# Support for ZSTD / GZIP Change
119-
if [ -z "$BACKUP_MODE" ]; then
120-
echo "[ ! ] Setting zstd backup compression type as default..."
121-
$BIN/v-change-sys-config-value "BACKUP_MODE" "zstd"
122-
fi
123-
124-
# Login style switcher
125-
if [ -z "$LOGIN_STYLE" ]; then
126-
echo "[ ! ] Adding missing variable to hestia.conf: LOGIN_STYLE ('default')"
127-
$BIN/v-change-sys-config-value "LOGIN_STYLE" "default"
128-
fi
129-
130-
# Webmail clients
131-
if [ -z "$WEBMAIL_SYSTEM" ]; then
132-
if [ -d "/var/lib/roundcube" ]; then
133-
echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_SYSTEM ('roundcube')"
134-
$BIN/v-change-sys-config-value "WEBMAIL_SYSTEM" "roundcube"
135-
else
136-
echo "[ ! ] Adding missing variable to hestia.conf: WEBMAIL_SYSTEM ('')"
137-
$BIN/v-change-sys-config-value "WEBMAIL_SYSTEM" ""
138-
fi
139-
fi
140-
141-
# Inactive session timeout
142-
if [ -z "$INACTIVE_SESSION_TIMEOUT" ]; then
143-
echo "[ ! ] Adding missing variable to hestia.conf: INACTIVE_SESSION_TIMEOUT ('60')"
144-
$BIN/v-change-sys-config-value "INACTIVE_SESSION_TIMEOUT" "60"
145-
fi
146-
147-
# Enforce subdomain ownership
148-
if [ -z "$ENFORCE_SUBDOMAIN_OWNERSHIP" ]; then
149-
echo "[ ! ] Adding missing variable to hestia.conf: ENFORCE_SUBDOMAIN_OWNERSHIP ('yes')"
150-
$BIN/v-change-sys-config-value "ENFORCE_SUBDOMAIN_OWNERSHIP" "yes"
151-
fi
152-
153-
# API access allowed IP's
154-
if [ "$API" = "yes" ]; then
155-
check_api_key=$(grep "API_ALLOWED_IP" $HESTIA/conf/hestia.conf)
156-
if [ -z "$check_api_key" ]; then
157-
if [ -z "$API_ALLOWED_IP" ]; then
158-
echo "[ ! ] Adding missing variable to hestia.conf: API_ALLOWED_IP ('allow-all')"
159-
$BIN/v-change-sys-config-value "API_ALLOWED_IP" "allow-all"
160-
fi
161-
fi
162-
fi
163-
16439
echo "[ * ] Health check complete. Starting upgrade from $VERSION to $new_version..."
16540
echo "============================================================================="
16641
}

0 commit comments

Comments
 (0)