Skip to content

Commit 3fa91ec

Browse files
authored
Merge pull request hestiacp#1523 from hestiacp/staging/features
Staging/features
2 parents 03f42fc + ea99185 commit 3fa91ec

File tree

296 files changed

+15633
-423
lines changed

Some content is hidden

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

296 files changed

+15633
-423
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/bin/bash
2+
# info: Adding fast cgi nginx support
3+
# options: USER DOMAIN [DEBUG]
4+
# labels: hestia web
5+
#
6+
# example: v-add-web-domain-fast-cgi-cache user domain.tld
7+
#
8+
# Function enables fast cgi support for Nginx
9+
# Add "yes" as last parameter append debug information to response headers
10+
11+
12+
#----------------------------------------------------------#
13+
# Variable&Function #
14+
#----------------------------------------------------------#
15+
16+
# Argument definition
17+
user=$1
18+
domain=$2
19+
debug=$3
20+
21+
# Includes
22+
source $HESTIA/func/main.sh
23+
source $HESTIA/conf/hestia.conf
24+
25+
26+
#----------------------------------------------------------#
27+
# Verifications #
28+
#----------------------------------------------------------#
29+
30+
check_args '2' "$#" 'USER DOMAIN DEBUG'
31+
is_format_valid 'user' 'domain'
32+
is_object_valid 'user' 'USER' "$user"
33+
is_object_unsuspended 'user' 'USER' "$user"
34+
is_object_valid 'web' 'DOMAIN' "$domain"
35+
is_object_unsuspended 'web' 'DOMAIN' "$domain"
36+
37+
# Perform verification if read-only mode is enabled
38+
check_hestia_demo_mode
39+
40+
41+
#----------------------------------------------------------#
42+
# Action #
43+
#----------------------------------------------------------#
44+
45+
# Load domain data
46+
parse_object_kv_list $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
47+
48+
# Check if web server is NGINX standalone
49+
if [ "$WEB_SYSTEM" != 'nginx' ]; then
50+
echo "Error: NGINX not in Stand Alone mode"
51+
exit $E_NOTEXIST
52+
fi
53+
54+
55+
if ! grep --quiet "forcessl" $HESTIA/data/templates/web/nginx/default.tpl; then
56+
$BIN/v-update-web-templates
57+
fi
58+
fastcgi="$HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.fastcgi_cache.conf"
59+
no_cache='$no_cache'
60+
cookie_session='$cookie_session'
61+
http_x_update='$http_x_update'
62+
status='$upstream_cache_status'
63+
64+
cat << EOF > $fastcgi
65+
fastcgi_cache $domain;
66+
fastcgi_no_cache $no_cache;
67+
fastcgi_cache_bypass $no_cache;
68+
fastcgi_cache_bypass $cookie_session $http_x_update;
69+
EOF
70+
71+
if [ ! -z "$debug" ]; then
72+
echo " add_header \"X-STATUS\" \"$status\";" >> $fastcgi
73+
fi
74+
75+
chown root:$user $fastcgi
76+
chmod 640 $fastcgi
77+
78+
str="fastcgi_cache_path /var/cache/nginx/php-fpm/$domain levels=2"
79+
str="$str keys_zone=$domain:10m inactive=60m max_size=512m;"
80+
conf='/etc/nginx/conf.d/01_fast_cgi_caching_pool.conf'
81+
if [ -e "$conf" ]; then
82+
if [ -z "$(grep "=${domain}:" $conf)" ]; then
83+
echo "$str" >> $conf
84+
fi
85+
else
86+
echo "$str" >> $conf
87+
fi
88+
89+
mkdir -p /var/cache/nginx/php-fpm/$domain
90+
91+
#----------------------------------------------------------#
92+
# Hestia #
93+
#----------------------------------------------------------#
94+
95+
if [ -z "$FASTCGI" ]; then
96+
add_object_key "web" 'DOMAIN' "$domain" 'FASTCGI_CACHE' 'ALIAS'
97+
fi
98+
99+
# Set FASTCGI flag to enabled
100+
update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_CACHE' 'yes'
101+
102+
# Restart web server
103+
$BIN/v-restart-web
104+
check_result $? "Web restart failed" > /dev/null
105+
106+
# Logging
107+
log_history "enabled fast cgi support for $domain"
108+
log_event "$OK" "$ARGUMENTS"
109+
110+
exit

bin/v-add-web-domain-ssl-preset

100644100755
File mode changed.

bin/v-change-user-role

100644100755
File mode changed.

bin/v-change-web-domain-docroot

100644100755
File mode changed.

bin/v-delete-user-auth-log

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
# info: Delete auth log file for user
3+
#
4+
# The function for deleting a users auth log file
5+
6+
# Argument definition
7+
user=$1
8+
date=$(date "+%F %T")
9+
10+
# Includes
11+
source $HESTIA/func/main.sh
12+
source $HESTIA/conf/hestia.conf
13+
14+
# Perform verification if read-only mode is enabled
15+
check_hestia_demo_mode
16+
17+
#----------------------------------------------------------#
18+
# Verifications #
19+
#----------------------------------------------------------#
20+
21+
check_args '1' "$#" 'USER'
22+
is_format_valid 'user'
23+
is_object_valid 'user' 'USER' "$user"
24+
25+
if [ ! -f $USER_DATA/auth.log ]; then
26+
touch $USER_DATA/auth.log
27+
fi
28+
29+
#----------------------------------------------------------#
30+
# Action #
31+
#----------------------------------------------------------#
32+
33+
rm $USER_DATA/auth.log
34+
35+
log_history "Authentication log for $user was cleared on $date."
36+
log_event "$OK" "$ARGUMENTS"
37+
38+
exit
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
# info: remove fast cgi nginx support
3+
# options: USER DOMAIN [RESTART]
4+
# labels: hestia web
5+
#
6+
# example: v-delete-web-domain-fast-cgi-cache user domain.tld
7+
#
8+
# The function removes fast cgi cache.
9+
10+
#----------------------------------------------------------#
11+
# Variable&Function #
12+
#----------------------------------------------------------#
13+
14+
# Argument definition
15+
user=$1
16+
domain=$2
17+
restart=$3
18+
19+
# Includes
20+
source $HESTIA/func/main.sh
21+
source $HESTIA/conf/hestia.conf
22+
23+
#----------------------------------------------------------#
24+
# Verifications #
25+
#----------------------------------------------------------#
26+
27+
check_args '2' "$#" 'USER DOMAIN'
28+
is_format_valid 'user' 'domain'
29+
is_object_valid 'user' 'USER' "$user"
30+
is_object_unsuspended 'user' 'USER' "$user"
31+
is_object_valid 'web' 'DOMAIN' "$domain"
32+
is_object_unsuspended 'web' 'DOMAIN' "$domain"
33+
is_object_valid 'web' 'DOMAIN' "$domain" "$FASTCGI_CACHE"
34+
35+
# Perform verification if read-only mode is enabled
36+
check_hestia_demo_mode
37+
38+
39+
#----------------------------------------------------------#
40+
# Action #
41+
#----------------------------------------------------------#
42+
43+
# Load domain data
44+
parse_object_kv_list $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
45+
46+
# Remove fast cgi configs
47+
if [ -f $HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.fastcgi_cache.conf ]; then
48+
rm -f $HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.fastcgi_cache.conf
49+
fi
50+
51+
# Delete cache folder on disabling
52+
if [ -d /var/cache/nginx/php-fpm/$domain ]; then
53+
rm -f /var/cache/nginx/php-fpm/$domain
54+
fi
55+
56+
#----------------------------------------------------------#
57+
# Hestia #
58+
#----------------------------------------------------------#
59+
60+
if [ -z "$FASTCGI_CACHE" ]; then
61+
add_object_key "web" 'DOMAIN' "$domain" 'FASTCGI_CACHE' 'ALIAS'
62+
fi
63+
64+
# Set FASTCGI flag to disabled
65+
update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_CACHE' ''
66+
67+
# Restart services if requested
68+
if [ ! -z "$restart" ]; then
69+
$BIN/v-restart-web
70+
check_result $? "Web restart failed" >/dev/null
71+
fi
72+
73+
# Logging
74+
log_history "disabled fast cgi support for $domain"
75+
log_event "$OK" "$ARGUMENTS"
76+
77+
exit

bin/v-list-sys-config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# info: list system configuration
33
# options: [FORMAT]
4-
# labels:
4+
# labels:
55
#
66
# example: v-list-sys-config json
77
#
@@ -61,6 +61,7 @@ json_list() {
6161
"DB_PMA_ALIAS": "'$DB_PMA_ALIAS'",
6262
"DB_PGA_ALIAS": "'$DB_PGA_ALIAS'",
6363
"LOGIN_STYLE": "'$LOGIN_STYLE'",
64+
"INACTIVE_SESSION_TIMEOUT": "'$INACTIVE_SESSION_TIMEOUT'",
6465
"SOFTACULOUS": "'$SOFTACULOUS'"
6566
}
6667
}'

bin/v-list-user-auth-log

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/bash
2+
# info: list user log
3+
# options: USER [FORMAT]
4+
#
5+
# The function of obtaining the list of 10 last users commands.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument definition
13+
user=$1
14+
format=${2-shell}
15+
16+
# Includes
17+
source $HESTIA/func/main.sh
18+
19+
# JSON list function
20+
json_list() {
21+
IFS=$'\n'
22+
i=1
23+
objects=$(echo "$logs" |wc -l)
24+
echo "{"
25+
for str in $logs; do
26+
IP=$(echo "$str" |cut -f 2 -d \')
27+
FINGERPRINT=$(echo "$str" |cut -f 4 -d \')
28+
DATE=$(echo "$str" |cut -f 6 -d \')
29+
TIME=$(echo "$str" |cut -f 8 -d \')
30+
ACTIVE=$(echo "$str" |cut -f 10 -d \')
31+
echo -n ' "'$i'": {
32+
"IP": "'$IP'",
33+
"FINGERPRINT": "'$FINGERPRINT'",
34+
"TIME": "'$TIME'",
35+
"DATE": "'$DATE'",
36+
"ACTIVE": "'$ACTIVE'"
37+
}'
38+
if [ "$i" -lt "$objects" ]; then
39+
echo ','
40+
else
41+
echo
42+
fi
43+
((i++))
44+
done
45+
echo '}'
46+
}
47+
48+
shell_list() {
49+
IFS=$'\n'
50+
echo "DATE~TIME~IP~FINGERPRINT~ACTIVE"
51+
echo "----~----~--~-----------~------"
52+
for str in $logs; do
53+
IP=$(echo "$str" |cut -f 2 -d \')
54+
FINGERPRINT=$(echo "$str" |cut -f 4 -d \')
55+
DATE=$(echo "$str" |cut -f 6 -d \')
56+
TIME=$(echo "$str" |cut -f 8 -d \')
57+
ACTIVE=$(echo "$str" |cut -f 10 -d \')
58+
echo "$DATE~$TIME~$IP~$FINGERPRINT~$ACTIVE"
59+
done
60+
}
61+
62+
# PLAIN list function
63+
plain_list() {
64+
IFS=$'\n'
65+
for str in $logs; do
66+
IP=$(echo "$str" |cut -f 2 -d \')
67+
FINGERPRINT=$(echo "$str" |cut -f 4 -d \')
68+
DATE=$(echo "$str" |cut -f 6 -d \')
69+
TIME=$(echo "$str" |cut -f 8 -d \')
70+
ACTIVE=$(echo "$str" |cut -f 10 -d \')
71+
echo -e "$DATE\t$TIME\t$IP\t$FINGERPRINT\t$ACTIVE"
72+
done
73+
}
74+
75+
# CSV list function
76+
csv_list() {
77+
IFS=$'\n'
78+
echo "ID,CMD,UNDO,TIME,DATE"
79+
for str in $logs; do
80+
IP=$(echo "$str" |cut -f 2 -d \')
81+
FINGERPRINT=$(echo "$str" |cut -f 4 -d \')
82+
DATE=$(echo "$str" |cut -f 6 -d \')
83+
TIME=$(echo "$str" |cut -f 8 -d \')
84+
ACTIVE=$(echo "$str" |cut -f 10 -d \')
85+
echo "$DATE,$TIME,$IP,$FINGERPRINT,$ACTIVE"
86+
87+
done
88+
}
89+
90+
#----------------------------------------------------------#
91+
# Verifications #
92+
#----------------------------------------------------------#
93+
94+
check_args '1' "$#" 'USER [FORMAT]'
95+
is_format_valid 'user'
96+
is_object_valid 'user' 'USER' "$user"
97+
98+
99+
#----------------------------------------------------------#
100+
# Action #
101+
#----------------------------------------------------------#
102+
103+
# Parsing history log
104+
logs=$(tail -n 10 $USER_DATA/auth.log 2>/dev/null)
105+
106+
case $format in
107+
json) json_list ;;
108+
plain) plain_list ;;
109+
csv) csv_list ;;
110+
shell) shell_list |column -t -s '~';;
111+
esac
112+
113+
114+
#----------------------------------------------------------#
115+
# Hestia #
116+
#----------------------------------------------------------#
117+
118+
exit

bin/v-list-web-domain

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ json_list() {
4444
"BACKEND": "'$BACKEND'",
4545
"PROXY": "'$PROXY'",
4646
"PROXY_EXT": "'$PROXY_EXT'",
47+
"FASTCGI_CACHE": "'$FASTCGI_CACHE'",
4748
"CUSTOM_DOCROOT": "'$CUSTOM_DOCROOT'",
4849
"SUSPENDED": "'$SUSPENDED'",
4950
"TIME": "'$TIME'",

0 commit comments

Comments
 (0)