Skip to content

Commit c2b8ba0

Browse files
author
Kristan Kenney
committed
Merge branch 'main' into feature/ui-themes_vestia
2 parents 8496f00 + 872df51 commit c2b8ba0

File tree

94 files changed

+2386
-1800
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2386
-1800
lines changed

bin/v-add-fastcgi-cache

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
#!/bin/bash
2-
# info: Add FastCGI nginx support
3-
# options: USER DOMAIN [DEBUG]
2+
# info: Enable FastCGI cache for nginx
3+
# options: USER DOMAIN [DURATION] [DEBUG] [RESTART]
44
# labels: hestia web
55
#
6-
# example: v-add-fastcgi-cache user domain.tld
6+
# example: v-add-fastcgi-cache user domain.tld 30m
77
#
88
# The function enables FastCGI cache for nginx
9+
# Acceptable values for duration is time in seconds (10s) minutes (10m) or days (10d)
910
# Add "yes" as last parameter to append debug information to response headers
1011

11-
1212
#----------------------------------------------------------#
1313
# Variable&Function #
1414
#----------------------------------------------------------#
1515

1616
# Argument definition
1717
user=$1
1818
domain=$2
19-
debug=$3
19+
duration=${3-2m}
20+
debug=${4-no}
21+
restart=${5-no}
2022

2123
# Includes
2224
# shellcheck source=/usr/local/hestia/func/main.sh
@@ -36,6 +38,16 @@ is_object_unsuspended 'user' 'USER' "$user"
3638
is_object_valid 'web' 'DOMAIN' "$domain"
3739
is_object_unsuspended 'web' 'DOMAIN' "$domain"
3840

41+
if ! [[ "$duration" =~ ^[0-9].*[s|m|d]$ ]]; then
42+
echo "Invalid duration";
43+
exit 2;
44+
fi
45+
46+
if [[ "$duration" =~ ^[0].*[s|m|d]$ ]]; then
47+
echo "Invalid duration";
48+
exit 2;
49+
fi
50+
3951
# Perform verification if read-only mode is enabled
4052
check_hestia_demo_mode
4153

@@ -47,7 +59,7 @@ check_hestia_demo_mode
4759
# Load domain data
4860
parse_object_kv_list $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
4961

50-
# Check if nginx is not in proxy mode
62+
# Check that nginx is not in proxy mode
5163
if [ "$WEB_SYSTEM" != 'nginx' ]; then
5264
echo "Error: nginx is in proxy mode"
5365
exit $E_NOTEXIST
@@ -65,11 +77,12 @@ status='$upstream_cache_status'
6577

6678
cat << EOF > $fastcgi
6779
fastcgi_cache $domain;
68-
fastcgi_cache_valid 200 2m;
80+
fastcgi_cache_valid 200 $duration;
6981
fastcgi_cache_valid 301 302 10m;
7082
fastcgi_cache_valid 404 10m;
7183
fastcgi_cache_bypass $no_cache;
72-
fastcgi_no_cache $no_cache;
84+
fastcgi_no_cache $no_cache;
85+
set $no_cache 0;
7386
EOF
7487

7588
if [ ! -z "$debug" ]; then
@@ -96,16 +109,22 @@ mkdir -p /var/cache/nginx/micro/$domain
96109
# Hestia #
97110
#----------------------------------------------------------#
98111

99-
if [ -z "$FASTCGI" ]; then
112+
if [ -z "$FASTCGI_CACHE" ]; then
100113
add_object_key "web" 'DOMAIN' "$domain" 'FASTCGI_CACHE' 'ALIAS'
101114
fi
115+
if [ -z "$FASTCGI_DURATION" ]; then
116+
add_object_key "web" 'DOMAIN' "$domain" 'FASTCGI_DURATION' 'ALIAS'
117+
fi
102118

103119
# Set FastCGI cache flag to enabled
104120
update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_CACHE' 'yes'
121+
update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_DURATION' "$duration"
105122

106-
# Restart web server
107-
$BIN/v-restart-web
108-
check_result $? "Web server restart failed" > /dev/null
123+
if [ "$restart" = "yes" ]; then
124+
# Restart web server
125+
$BIN/v-restart-web
126+
check_result $? "Web server restart failed" > /dev/null
127+
fi
109128

110129
# Logging
111130
log_history "Enabled FastCGI cache for $domain"

bin/v-add-sys-rainloop

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,5 @@ fi
171171

172172

173173

174-
log_history "Rouncube successfuly installed" '' 'admin'
174+
log_history "Rainloop successfuly installed" '' 'admin'
175175
log_event "$OK" "$ARGUMENTS"

bin/v-add-sys-roundcube

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,5 @@ fi
193193

194194

195195

196-
log_history "Rouncube successfuly installed" '' 'admin'
196+
log_history "Roundcube successfuly installed" '' 'admin'
197197
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-change-sys-port

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,8 @@ check_hestia_demo_mode
5858
# Get original port
5959
ORIGINAL_PORT=$(cat $HESTIA/nginx/conf/nginx.conf | grep "listen" | sed 's/[^0-9]*//g')
6060

61-
# Check if system variable is set
62-
if [ ! -n "$BACKEND_PORT" ]; then
63-
echo "BACKEND_PORT='$port'" >> $HESTIA/conf/hestia.conf
64-
source $HESTIA/conf/hestia.conf
65-
fi
66-
67-
# Check if port is different to hestia.conf
68-
if [ ! "$BACKEND_PORT" = "$PORT" ]; then
69-
sed -i s/BACKEND_PORT=\'$BACKEND_PORT\'/BACKEND_PORT=\'$PORT\'/g $HESTIA/conf/hestia.conf
70-
fi
61+
# Set new port in config via v-change-sys-config-value
62+
$HESTIA/bin/v-change-sys-config-value "BACKEND_PORT" $PORT
7163

7264
# Check if port is different to nginx.conf
7365
if [ "$ORIGINAL_PORT" = "$PORT" ]; then

bin/v-delete-fastcgi-cache

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/bash
2-
# info: Remove FastCGI nginx support
2+
# info: Disable FastCGI cache for nginx
33
# options: USER DOMAIN [RESTART]
44
# labels: hestia web
55
#
66
# example: v-delete-fastcgi-cache user domain.tld
77
#
8-
# The function enables FastCGI cache for nginx
8+
# The function disables FastCGI cache for nginx
99

1010

1111
#----------------------------------------------------------#
@@ -51,7 +51,7 @@ fi
5151

5252
conf='/etc/nginx/conf.d/fastcgi_cache_pool.conf'
5353
if [ -f "$conf" ]; then
54-
sed -i "/fastcgi_cache $domain;/d" $conf
54+
sed -i "/ keys_zone=$domain/d" $conf
5555
if [ ! -s "$conf" ]; then
5656
rm -rf $conf
5757
fi
@@ -68,11 +68,15 @@ fi
6868
#----------------------------------------------------------#
6969

7070
if [ -z "$FASTCGI_CACHE" ]; then
71-
add_object_key "web" 'DOMAIN' "$domain" 'FASTCGI_CACHE' 'ALIAS'
71+
add_object_key "web" 'DOMAIN' "$domain" 'FASTCGI_CACHE' 'ALIAS'
72+
fi
73+
if [ -z "$FASTCGI_DURATION" ]; then
74+
add_object_key "web" 'DOMAIN' "$domain" 'FASTCGI_DURATION' 'ALIAS'
7275
fi
7376

74-
# Set FASTCGI flag to disabled
75-
update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_CACHE' ''
77+
# Set FastCGI cache flag to disabled
78+
update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_CACHE' 'no'
79+
update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_DURATION' '0s'
7680

7781
# Restart web server
7882
if [ ! -z "$restart" ]; then

bin/v-delete-web-domain

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ if [ "$SSL" = 'yes' ]; then
8181
rm -f $USER_DATA/ssl/$domain.*
8282
fi
8383

84+
if [ "$FASTCGI_CACHE" = "yes" ]; then
85+
# make sure no trails left behind
86+
$BIN/v-delete-fastcgi-cache $user $domain
87+
fi
88+
8489
# Deleting domain from web.conf
8590
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf
8691

@@ -111,7 +116,6 @@ rm -f /var/log/$WEB_SYSTEM/domains/$domain.error*
111116
rm -rf $HOMEDIR/$user/web/$domain
112117
rm -rf $HOMEDIR/$user/conf/web/$domain
113118

114-
115119
#----------------------------------------------------------#
116120
# Hestia #
117121
#----------------------------------------------------------#

bin/v-list-web-domain

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ json_list() {
4646
"PROXY": "'$PROXY'",
4747
"PROXY_EXT": "'$PROXY_EXT'",
4848
"FASTCGI_CACHE": "'$FASTCGI_CACHE'",
49+
"FASTCGI_DURATION": "'$FASTCGI_DURATION'",
4950
"REDIRECT": "'$REDIRECT'",
5051
"REDIRECT_CODE": "'$REDIRECT_CODE'",
5152
"CUSTOM_DOCROOT": "'$CUSTOM_DOCROOT'",

bin/v-rebuild-all

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ restart=$2
2222
# Includes
2323
# shellcheck source=/usr/local/hestia/func/main.sh
2424
# shellcheck source=/usr/local/hestia/func/rebuild.sh
25+
# shellcheck source=/usr/local/hestia/func/syshealth.sh
2526
# shellcheck source=/usr/local/hestia/conf/hestia.conf
2627
source $HESTIA/func/main.sh
2728
source $HESTIA/func/rebuild.sh
29+
source $HESTIA/func/syshealth.sh
2830
source $HESTIA/conf/hestia.conf
2931

3032
# Export sbin

0 commit comments

Comments
 (0)