33# Hestia Control Panel - System Health Check Function Library
44
55# Read known configuration keys from $HESTIA/conf/defaults/$system.conf
6- function read_kv_config_file () {
6+ function read_kv_config_file() {
77 local system=$1
88 while read -r str; do
99 echo " $str "
@@ -12,7 +12,7 @@ function read_kv_config_file () {
1212}
1313
1414# Write known configuration keys to $HESTIA/conf/defaults/
15- function write_kv_config_file () {
15+ function write_kv_config_file() {
1616 # Ensure configuration directory exists
1717 if [ ! -d " $HESTIA /conf/defaults/" ]; then
1818 mkdir " $HESTIA /conf/defaults/"
@@ -30,8 +30,17 @@ function write_kv_config_file () {
3030 done
3131}
3232
33+ # Sanitize configuration input
34+ function sanitize_config_file() {
35+ local system=$1
36+ known_keys=$( read_kv_config_file " $system " )
37+ for key in $known_keys ; do
38+ unset $key
39+ done
40+ }
41+
3342# Update list of known keys for web.conf files
34- function syshealth_update_web_config_format () {
43+ function syshealth_update_web_config_format() {
3544
3645 # WEB DOMAINS
3746 # Create array of known keys in configuration file
@@ -43,7 +52,7 @@ function syshealth_update_web_config_format () {
4352}
4453
4554# Update list of known keys for dns.conf files
46- function syshealth_update_dns_config_format () {
55+ function syshealth_update_dns_config_format() {
4756
4857 # DNS DOMAINS
4958 # Create array of known keys in configuration file
@@ -62,7 +71,7 @@ function syshealth_update_dns_config_format () {
6271}
6372
6473# Update list of known keys for mail.conf files
65- function syshealth_update_mail_config_format () {
74+ function syshealth_update_mail_config_format() {
6675
6776 # MAIL DOMAINS
6877 # Create array of known keys in configuration file
@@ -81,7 +90,7 @@ function syshealth_update_mail_config_format () {
8190}
8291
8392# Update list of known keys for user.conf files
84- function syshealth_update_user_config_format () {
93+ function syshealth_update_user_config_format() {
8594
8695 # USER CONFIGURATION
8796 # Create array of known keys in configuration file
@@ -101,7 +110,7 @@ function syshealth_update_user_config_format () {
101110}
102111
103112# Update list of known keys for db.conf files
104- function syshealth_update_database_config_format () {
113+ function syshealth_update_database_config_format() {
105114
106115 # DATABASE CONFIGURATION
107116 # Create array of known keys in configuration file
@@ -113,7 +122,7 @@ function syshealth_update_database_config_format () {
113122}
114123
115124# Update list of known keys for ip.conf files
116- function syshealth_update_ip_config_format () {
125+ function syshealth_update_ip_config_format() {
117126
118127 # IP ADDRESS
119128 # Create array of known keys in configuration file
@@ -124,18 +133,24 @@ function syshealth_update_ip_config_format () {
124133 unset known_keys
125134}
126135
127- # Sanitize web domain configuration
128- function syshealth_sanitize_config() {
129- local system=$1
130- known_keys=$( read_kv_config_file " $system " )
131- for key in $known_keys ; do
132- unset $key
136+ # Repair web domain configuration
137+ function syshealth_repair_web_config() {
138+ system=" web"
139+ sanitize_config_file
140+ get_domain_values ' web'
141+ prev=" DOMAIN"
142+ for key in $known_keys ;
143+ do
144+ if [ -z " ${! key} " ]; then
145+ add_object_key ' web' ' DOMAIN' " $domain " " $key " " $prev "
146+ fi
147+ prev=$key
133148 done
134149}
135150
136151# Repair System Configuration
137152# Adds missing variables to $HESTIA/conf/hestia.conf with safe default values
138- function syshealth_repair_system_config () {
153+ function syshealth_repair_system_config() {
139154 # Release branch
140155 if [ -z " $RELEASE_BRANCH " ]; then
141156 echo " [ ! ] Adding missing variable to hestia.conf: RELEASE_BRANCH ('release')"
0 commit comments