Skip to content

Commit abb81f5

Browse files
author
Kristan Kenney
committed
Merge branch 'main' into feature/user-roles
2 parents 83dc37b + 706314c commit abb81f5

File tree

16 files changed

+196
-184
lines changed

16 files changed

+196
-184
lines changed

bin/v-change-sys-api

Lines changed: 22 additions & 3 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,7 +53,18 @@ 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
#----------------------------------------------------------#

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 & 143 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,143 +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
37+
syshealth_repair_system_config
6838

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
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-
# Enable read-only access to the System Administrator account for other administrators
154-
if [ -z "$RESTRICTED_ADMIN" ]; then
155-
echo "[ ! ] Adding missing variable to hestia.conf: RESTRICTED_ADMIN ('yes')"
156-
$BIN/v-change-sys-config-value 'RESTRICTED_ADMIN' 'yes'
157-
fi
158-
159-
# Debug Mode
160-
if [ -z "$DEBUG_MODE" ]; then
161-
echo "[ ! ] Adding missing variable to hestia.conf: DEBUG_MODE ('false')"
162-
$BIN/v-change-sys-config-value "DEBUG_MODE" "false"
163-
fi
164-
# API Allowed IP
165-
if [ -z "$API_ALLOWED_IP" ]; then
166-
echo "[ ! ] Adding missing variable to hestia.conf: API_ALLOWED_IP ('allow-all')"
167-
$BIN/v-change-sys-config-value "API_ALLOWED_IP" "allow-all"
168-
fi
169-
17039
echo "[ * ] Health check complete. Starting upgrade from $VERSION to $new_version..."
17140
echo "============================================================================="
17241
}
@@ -698,13 +567,6 @@ upgrade_rainloop(){
698567
fi
699568
}
700569

701-
disable_api(){
702-
if [ "$API" = "no" ]; then
703-
echo "[ ! ] Disable Api..."
704-
sed -i 's|//die("Error: Disabled");|die("Error: Disabled");|g' $HESTIA/web/api/index.php
705-
$HESTIA/bin/v-change-sys-config-value "API_ALLOWED_IP" ""
706-
fi
707-
}
708570
upgrade_rebuild_web_templates() {
709571
if [ "$UPGRADE_UPDATE_WEB_TEMPLATES" = "true" ]; then
710572
echo "[ ! ] Updating default web domain templates..."

install/hst-install-debian.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ echo "[ * ] Install Roundcube..."
16371637

16381638
if [ "$mysql" == 'yes' ] && [ "$dovecot" == "yes" ]; then
16391639
$HESTIA/bin/v-add-sys-roundcube
1640-
echo " WEBMAIL_ALIAS='webmail'" >> $HESTIA/conf/hestia.conf
1640+
echo "WEBMAIL_ALIAS='webmail'" >> $HESTIA/conf/hestia.conf
16411641
fi
16421642

16431643
#----------------------------------------------------------#
@@ -1646,7 +1646,7 @@ fi
16461646

16471647
if [ "$api" = "yes" ]; then
16481648
echo "API='yes'" >> $HESTIA/conf/hestia.conf
1649-
echo "API_ALLOWED_IP='127.0.0.1'" >> $HESTIA/conf/hestia.conf
1649+
echo "API_ALLOWED_IP=''" >> $HESTIA/conf/hestia.conf
16501650
else
16511651
$HESTIA/bin/v-change-sys-api disable
16521652
fi

0 commit comments

Comments
 (0)