Skip to content

Commit 662a6e0

Browse files
authored
Merge branch 'main' into fix/v-restore-user
2 parents 0d7964d + fba26b4 commit 662a6e0

39 files changed

+1555
-1238
lines changed

bin/v-add-sys-rainloop

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ if [ "$UPDATE" == "no" ]; then
103103
echo "Forbidden" > ./data/index.html
104104

105105
# Create database
106-
mysql -e "DROP DATABASE rainloop"
107-
mysql -e "DROP USER rainloop@localhost"
108106
mysql -e "CREATE DATABASE rainloop"
109107
# Mysql available on system
110108
r=$(generate_password)
@@ -174,4 +172,4 @@ fi
174172

175173

176174
log_history "Rouncube successfuly installed" '' 'admin'
177-
log_event "$OK" "$ARGUMENTS"
175+
log_event "$OK" "$ARGUMENTS"

bin/v-change-sys-api

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ source $HESTIA/conf/hestia.conf
2525
#----------------------------------------------------------#
2626

2727
check_args '1' "$#" "STATUS"
28-
is_type_valid "enable,disable" "$status"
28+
is_type_valid "enable,disable,remove" "$status"
2929

3030
# Perform verification if read-only mode is enabled
3131
check_hestia_demo_mode
@@ -36,7 +36,15 @@ check_hestia_demo_mode
3636

3737
if [ "$status" = "enable" ]; then
3838
if [ ! -f "$HESTIA/web/api/index.php" ]; then
39-
wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/release/web/api/index.php -O $HESTIA/web/api/index.php
39+
wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/$RELEASE_BRANCH/web/api/index.php -O $HESTIA/web/api/index.php
40+
check_api_download=$(cat $HESTIA/web/api/index.php)
41+
if [ -z "$HESTIA/web/api/index.php" ]; then
42+
# Throw error message to user
43+
echo "ERROR: API installation failed."
44+
# Remove empty file created by wget output
45+
rm -f "$HESTIA/web/api/index.php"
46+
exit 1
47+
fi
4048
else
4149
sed -i 's|die("Error: Disabled");|//die("Error: Disabled");|g' $HESTIA/web/api/index.php
4250
sed -i 's|////|//|g' $HESTIA/web/api/index.php
@@ -45,12 +53,27 @@ if [ "$status" = "enable" ]; then
4553
else
4654
$HESTIA/bin/v-change-sys-config-value "API" "no"
4755
$HESTIA/bin/v-change-sys-config-value "API_ALLOWED_IP" ""
48-
sed -i 's|//die("Error: Disabled");|die("Error: Disabled");|g' $HESTIA/web/api/index.php
56+
if [ "$status" != "remove" ]; then
57+
sed -i 's|//die("Error: Disabled");|die("Error: Disabled");|g' $HESTIA/web/api/index.php
58+
fi
59+
fi
60+
61+
if [ "$status" = "remove" ]; then
62+
if [ ! -f "$HESTIA/web/api/index.php" ]; then
63+
echo "ERROR: API is not installed."
64+
exit 1
65+
else
66+
rm -f "$HESTIA/web/api/index.php"
67+
fi
4968
fi
5069

5170
#----------------------------------------------------------#
5271
# Logging #
5372
#----------------------------------------------------------#
5473

55-
log_history "API status has been changed to $status" '' 'admin'
74+
if [ "$status" = "enable" ] || [ "$status" = "disable" ]; then
75+
log_history "API status has been changed to $status" '' 'admin'
76+
else
77+
log_history "API has been disabled and removed" '' 'admin'
78+
fi
5679
log_event "$OK" "$ARGUMENTS"

bin/v-change-sys-config-value

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ else
4848
sed -i "s|$key=.*|$key='$value'|g" $HESTIA/conf/hestia.conf
4949
fi
5050

51+
# Sort configuration file in alphabetical order on change
52+
sort $HESTIA/conf/hestia.conf -o /tmp/updconf
53+
mv $HESTIA/conf/hestia.conf $HESTIA/conf/hestia.conf.bak
54+
mv /tmp/updconf $HESTIA/conf/hestia.conf
55+
rm -f $HESTIA/conf/hestia.conf.bak
56+
5157
#----------------------------------------------------------#
5258
# Hestia #
5359
#----------------------------------------------------------#

bin/v-rebuild-users

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# example: v-rebuild-users
77
#
8-
# The function all users on the system.
8+
# The function rebuilds user configuration for all users.
99

1010
#----------------------------------------------------------#
1111
# Variable&Function #

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 & 131 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,131 +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
92-
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
37+
syshealth_repair_system_config
11038

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-
# API Allowed IP
153-
if [ -z "$API_ALLOWED_IP" ]; then
154-
echo "[ ! ] Adding missing variable to hestia.conf: API_ALLOWED_IP ('allow-all')"
155-
$BIN/v-change-sys-config-value "API_ALLOWED_IP" "allow-all"
156-
fi
157-
15839
echo "[ * ] Health check complete. Starting upgrade from $VERSION to $new_version..."
15940
echo "============================================================================="
16041
}
@@ -674,13 +555,6 @@ upgrade_rainloop(){
674555
fi
675556
}
676557

677-
disable_api(){
678-
if [ "$API" = "no" ]; then
679-
echo "[ ! ] Disable Api..."
680-
sed -i 's|//die("Error: Disabled");|die("Error: Disabled");|g' $HESTIA/web/api/index.php
681-
$HESTIA/bin/v-change-sys-config-value "API_ALLOWED_IP" ""
682-
fi
683-
}
684558
upgrade_rebuild_web_templates() {
685559
if [ "$UPGRADE_UPDATE_WEB_TEMPLATES" = "true" ]; then
686560
echo "[ ! ] Updating default web domain templates..."

0 commit comments

Comments
 (0)