Skip to content

Commit bdab1ca

Browse files
author
Kristan Kenney
committed
Merge branch 'release-1.0.1'
2 parents 405d5ef + e0260b3 commit bdab1ca

Some content is hidden

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

82 files changed

+978
-461
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,4 @@ If you would like to help our developers cover their time and infrastucture cost
117117

118118
License
119119
=============================
120-
Hestia Control Panel is licensed under [GPL v3](https://github.com/hestiacp/hestiacp/blob/master/LICENSE) license, and is based on the [VestaCP](https://www.vestacp.com/) project.<br>
120+
Hestia Control Panel is licensed under [GPL v3](https://github.com/hestiacp/hestiacp/blob/master/LICENSE) license, and is based on the [VestaCP](https://www.vestacp.com/) project.<br>

bin/v-add-letsencrypt-host

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
# info: add letsencrypt for host and backend
3+
# options:
4+
#
5+
# The function check and validates the backend certificate and generate
6+
# a new let's encrypt certificate.
7+
8+
9+
#----------------------------------------------------------#
10+
# Variable&Function #
11+
#----------------------------------------------------------#
12+
13+
# Argument definition
14+
user="admin"
15+
domain=$HOSTNAME
16+
17+
# Includes
18+
source $HESTIA/func/main.sh
19+
source $HESTIA/func/domain.sh
20+
source $HESTIA/conf/hestia.conf
21+
22+
23+
#----------------------------------------------------------#
24+
# Verifications #
25+
#----------------------------------------------------------#
26+
27+
is_format_valid 'user' 'domain' 'aliases'
28+
is_object_valid 'user' 'USER' "$user"
29+
is_object_unsuspended 'user' 'USER' "$user"
30+
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
31+
32+
33+
#----------------------------------------------------------#
34+
# Action #
35+
#----------------------------------------------------------#
36+
37+
# Check if hostname already exists as domain
38+
if [ "$($BIN/v-list-web-domain $user $domain plain |cut -f 1)" != "$domain" ]; then
39+
# Create web domain for hostname
40+
$BIN/v-add-web-domain $user $domain
41+
fi
42+
43+
# Validate web domain
44+
is_object_valid 'web' 'DOMAIN' "$domain"
45+
is_object_unsuspended 'web' 'DOMAIN' "$domain"
46+
get_domain_values 'web'
47+
48+
# Load domain data
49+
eval $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
50+
51+
# Set ssl installation to yes
52+
add_ssl="yes"
53+
54+
if [ "$SSL" = "yes" ]; then
55+
# Valildate SSL Certificate
56+
if [ -e "$USER_DATA/ssl/$domain.ca" ]; then
57+
if openssl verify -CAfile $USER_DATA/ssl/$domain.ca $USER_DATA/ssl/$domain.pem | grep -q "$domain.pem: OK"; then
58+
add_ssl="no"
59+
fi
60+
else
61+
if openssl verify $USER_DATA/ssl/$domain.pem | grep -q "$domain.pem: OK"; then
62+
add_ssl="no"
63+
fi
64+
fi
65+
fi
66+
67+
# Add let's encrypt ssl if needed
68+
if [ "$add_ssl" = "yes" ]; then
69+
# Add let's encrypt ssl
70+
$BIN/v-add-letsencrypt-domain $user $domain
71+
fi
72+
73+
# Add certificate to backend
74+
$BIN/v-update-host-certificate $user $domain
75+
76+
77+
#----------------------------------------------------------#
78+
# Hestia #
79+
#----------------------------------------------------------#
80+
81+
exit

bin/v-add-mail-domain

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ if [[ "$MAIL_SYSTEM" =~ exim ]]; then
108108

109109
# Set ownership
110110
chown -R $MAIL_USER:mail $HOMEDIR/$user/conf/mail/$domain
111-
chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain/passwd
111+
if [ "$IMAP_SYSTEM" = 'dovecot' ]; then
112+
chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain/passwd
113+
fi
112114
chown $user:mail $HOMEDIR/$user/mail/$domain_idn
113115
fi
114116

@@ -129,7 +131,9 @@ fi
129131

130132
# Add webmail configuration to mail domain
131133
if [ ! -z "$WEB_SYSTEM" ] || [ ! -z "$PROXY_SYSTEM" ]; then
132-
$BIN/v-add-webmail $user $domain ''
134+
if [ ! -z "$IMAP_SYSTEM" ]; then
135+
$BIN/v-add-webmail $user $domain ''
136+
fi
133137
fi
134138

135139
#----------------------------------------------------------#

bin/v-add-sys-sftp-jail

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add system sftp jail
3-
# options: NONE
3+
# options: [RESTART]
44
#
55
# The script enables sftp jailed environment
66

@@ -14,6 +14,7 @@ source /etc/profile
1414
source $HESTIA/func/main.sh
1515
source $HESTIA/conf/hestia.conf
1616

17+
restart=$1
1718

1819
#----------------------------------------------------------#
1920
# Verifications #
@@ -45,11 +46,13 @@ if [ -z "$sftp_i" ]; then
4546
echo " X11Forwarding no" >> $config
4647
echo " AllowTCPForwarding no" >> $config
4748
echo " ForceCommand internal-sftp" >> $config
48-
restart='yes'
4949
fi
5050

5151
# Validating opensshd config
52-
if [ "$restart" = 'yes' ]; then
52+
if [ "$restart" = 'no' ]; then
53+
# Skipping SSH Restart
54+
echo "" > /dev/null 2>&1
55+
else
5356
subj="OpenSSH restart failed"
5457
email=$(grep CONTACT $HESTIA/data/users/admin/user.conf |cut -f 2 -d \')
5558
/usr/sbin/sshd -t >/dev/null 2>&1
@@ -59,7 +62,6 @@ if [ "$restart" = 'yes' ]; then
5962
echo -e "$mail_text" |$SENDMAIL -s "$subj" $email
6063
else
6164
service ssh restart >/dev/null 2>&1
62-
service sshd restart >/dev/null 2>&1
6365
fi
6466
fi
6567

bin/v-add-user-sftp-jail

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# info: add user sftp jail
3-
# options: USER
3+
# options: USER [RESTART]
44
#
55
# The script enables sftp jailed environment
66

@@ -11,6 +11,7 @@
1111

1212
# Argument definition
1313
user=$1
14+
restart=$2
1415

1516
# Includes
1617
source $HESTIA/func/main.sh
@@ -62,8 +63,12 @@ chown root:root /home/$user
6263
#----------------------------------------------------------#
6364

6465
# Restart ssh service
65-
service ssh restart > /dev/null 2>&1
66-
service sshd restart > /dev/null 2>&1
66+
if [ "$restart" = 'no' ]; then
67+
# Skip restart of SSH daemon
68+
echo "" > /dev/null 2>&1
69+
else
70+
service ssh restart > /dev/null 2>&1
71+
fi
6772

6873
# Logging
6974
log_event "$OK" "$ARGUMENTS"

bin/v-add-web-domain

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ if [ "$aliases" = 'none' ]; then
114114
else
115115
ALIAS="www.$domain"
116116
if [ -z "$aliases" ]; then
117-
ALIAS="www.$domain"
117+
# Check and skip www alias for subdomains.
118+
IFS='.' read -r -a domain_elements <<< "$domain"
119+
if [ "${#domain_elements[@]}" -gt 2 ]; then
120+
ALIAS=""
121+
else
122+
ALIAS="www.$domain"
123+
fi
118124
else
119125
ALIAS="$aliases"
120126
fi

bin/v-add-webmail

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ check_args '2' "$#" 'USER DOMAIN [RESTART]'
4545
is_format_valid 'user' 'domain'
4646
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
4747
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
48+
is_system_enabled "$IMAP_SYSTEM" 'IMAP_SYSTEM'
4849
is_object_valid 'user' 'USER' "$user"
4950
is_object_unsuspended 'user' 'USER' "$user"
5051
is_object_valid 'mail' 'DOMAIN' "$domain"
@@ -54,39 +55,44 @@ is_object_unsuspended 'mail' 'DOMAIN' "$domain"
5455
# Action #
5556
#----------------------------------------------------------#
5657

57-
# Ensure DNS record exists if Hestia is hosting DNS zones
58-
if [ ! -z "$DNS_SYSTEM" ]; then
59-
dns_domain=$($BIN/v-list-dns-domains $user | grep $domain | cut -d' ' -f1)
60-
webmail_record=$($BIN/v-list-dns-records $user $domain | grep -i $WEBMAIL_ALIAS | cut -d' ' -f1)
61-
62-
if [ "$dns_domain" = "$domain" ]; then
63-
if [ -z "$webmail_record" ]; then
64-
$BIN/v-add-dns-record $user $domain $WEBMAIL_ALIAS A $ip
65-
else
66-
$BIN/v-delete-dns-record $user $domain $webmail_record
67-
$BIN/v-add-dns-record $user $domain $WEBMAIL_ALIAS A $ip
58+
# Verify that webmail alias variable exists
59+
if [ ! -z "$WEBMAIL_ALIAS" ]; then
60+
# Ensure DNS record exists if Hestia is hosting DNS zones
61+
if [ ! -z "$DNS_SYSTEM" ]; then
62+
dns_domain=$($BIN/v-list-dns-domains $user | grep $domain | cut -d' ' -f1)
63+
webmail_record=$($BIN/v-list-dns-records $user $domain | grep -i $WEBMAIL_ALIAS | cut -d' ' -f1)
64+
65+
if [ "$dns_domain" = "$domain" ]; then
66+
if [ -z "$webmail_record" ]; then
67+
$BIN/v-add-dns-record $user $domain $WEBMAIL_ALIAS A $ip
68+
else
69+
$BIN/v-delete-dns-record $user $domain $webmail_record
70+
$BIN/v-add-dns-record $user $domain $WEBMAIL_ALIAS A $ip
71+
fi
6872
fi
6973
fi
70-
fi
7174

72-
# Add webmail configuration to mail domain
73-
WEBMAIL_TEMPLATE="default"
74-
if [ "$WEB_SYSTEM" = "nginx" ]; then
75-
WEBMAIL_TEMPLATE="web_system"
76-
fi
77-
add_webmail_config "$WEB_SYSTEM" "${WEBMAIL_TEMPLATE}.tpl"
75+
# Add webmail configuration to mail domain
76+
WEBMAIL_TEMPLATE="default"
77+
if [ "$WEB_SYSTEM" = "nginx" ]; then
78+
WEBMAIL_TEMPLATE="web_system"
79+
fi
80+
add_webmail_config "$WEB_SYSTEM" "${WEBMAIL_TEMPLATE}.tpl"
7881

79-
if [ ! -z "$PROXY_SYSTEM" ]; then
80-
add_webmail_config "$PROXY_SYSTEM" "default.tpl"
81-
fi
82+
if [ ! -z "$PROXY_SYSTEM" ]; then
83+
add_webmail_config "$PROXY_SYSTEM" "default.tpl"
84+
fi
8285

83-
# Enable SSL for webmail if available
84-
if [ -f $HOMEDIR/$user/conf/mail/$domain/ssl/$domain.crt ] || [ "$SSL" = 'yes' ]; then
85-
add_webmail_config "$WEB_SYSTEM" "${WEBMAIL_TEMPLATE}.stpl"
86+
# Enable SSL for webmail if available
87+
if [ -f $HOMEDIR/$user/conf/mail/$domain/ssl/$domain.crt ] || [ "$SSL" = 'yes' ]; then
88+
add_webmail_config "$WEB_SYSTEM" "${WEBMAIL_TEMPLATE}.stpl"
8689

87-
if [ ! -z "$PROXY_SYSTEM" ]; then
88-
add_webmail_config "$PROXY_SYSTEM" "default.stpl"
90+
if [ ! -z "$PROXY_SYSTEM" ]; then
91+
add_webmail_config "$PROXY_SYSTEM" "default.stpl"
92+
fi
8993
fi
94+
else
95+
echo "Error: WEBMAIL_ALIAS is not defined in hestia.conf"
9096
fi
9197

9298
#----------------------------------------------------------#

bin/v-change-sys-port

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ if [ "$ORIGINAL_PORT" = "$PORT" ]; then
7272
else
7373
# Replace port in config files.
7474
sed -i "/listen/c\ listen $PORT ssl;" $HESTIA/nginx/conf/nginx.conf
75-
sed -i "/password_hestia_port/c\$rcmail_config['password_hestia_port'] = '$PORT';" /etc/roundcube/plugins/password/config.inc.php
75+
if [ -d /etc/roundcube/ ]; then
76+
sed -i "/password_hestia_port/c\$rcmail_config['password_hestia_port'] = '$PORT';" /etc/roundcube/plugins/password/config.inc.php
77+
fi
7678
sed -i "/COMMENT='HESTIA'/c\RULE='2' ACTION='ACCEPT' PROTOCOL='TCP' PORT='$PORT' IP='0.0.0.0/0' COMMENT='HESTIA' SUSPENDED='no' TIME='07:40:16' DATE='2014-05-25'" $HESTIA/data/firewall/rules.conf
7779

7880
# Restart services

bin/v-change-sys-release

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ if [ -z "$branch" ]; then
2727
echo "Usage: v-change-sys-release branchname"
2828
echo ""
2929
echo "Common release branches:"
30-
echo "(*) master: Stable releases only"
31-
echo "(*) beta: Beta builds which are being prepared for release"
32-
echo "(*) develop: Daily development builds"
30+
echo "(*) release: The latest stable release available via APT"
31+
echo "(*) prerelease: Beta/release candidate releases"
32+
echo "(*) master: The latest development code from GitHub"
3333
echo ""
3434
echo "You can also specify another branch name from the"
3535
echo "GitHub repository to install the code from that branch."
@@ -49,7 +49,7 @@ else
4949

5050
# Set new branch variable
5151
echo "RELEASE_BRANCH='$branch'" >> $HESTIA/conf/hestia.conf
52-
echo "Changed system release to update from Git branch: $branch"
52+
echo "Changed system release to update from branch: $branch"
5353
fi
5454

5555
#----------------------------------------------------------#

bin/v-change-web-domain-hsts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
# info: add/remove HSTS support from a domain
3+
# options: USER DOMAIN STATUS
4+
#
5+
# This function will enable or disable HSTS (HTTP Strict Transport Security)
6+
# for a web domain.
7+
8+
9+
#----------------------------------------------------------#
10+
# Variable&Function #
11+
#----------------------------------------------------------#
12+
13+
# Argument definition
14+
user=$1
15+
domain=$2
16+
domain_idn=$2
17+
status=$3
18+
19+
# Includes
20+
source $HESTIA/func/main.sh
21+
source $HESTIA/func/domain.sh
22+
source $HESTIA/conf/hestia.conf
23+
24+
#----------------------------------------------------------#
25+
# Verifications #
26+
#----------------------------------------------------------#
27+
28+
check_args '2' "$#" 'USER DOMAIN'
29+
is_format_valid 'user' 'domain'
30+
is_object_valid 'user' 'USER' "$user"
31+
is_object_unsuspended 'user' 'USER' "$user"
32+
is_object_valid 'web' 'DOMAIN' "$domain"
33+
is_object_unsuspended 'web' 'DOMAIN' "$domain"
34+
35+
#----------------------------------------------------------#
36+
# Action #
37+
#----------------------------------------------------------#
38+
39+
# Load domain data
40+
eval $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
41+
42+
# Check if SSL is enabled
43+
if [ "$SSL" != 'yes' ]; then
44+
echo "Error: SSL is not enabled"
45+
exit $E_NOTEXIST
46+
fi
47+
48+
# Check for Apache/Nginx or Nginx/PHP-FPM configuration
49+
if [ -z $PROXY_SYSTEM ]; then
50+
hstsconf="$HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.hsts.conf"
51+
else
52+
hstsconf="$HOMEDIR/$user/conf/web/$domain/$PROXY_SYSTEM.hsts.conf"
53+
fi
54+
55+
if [ "$status" = "on" ]; then
56+
echo 'add_header Strict-Transport-Security "max-age=15768000;" always;' > $hstsconf
57+
echo "HTTP Strict Transport Security (HSTS) turned on for $domain."
58+
elif [ "$status" = "off" ]; then
59+
rm -f $hstsconf
60+
nginx -s reload
61+
echo "HTTP Strict Transport Security (HSTS) turned off for $domain."
62+
else
63+
echo "Error: Invalid mode specified."
64+
echo "Usage: v-change-web-domain-hsts USER DOMAIN [ON / OFF]"
65+
fi
66+
67+
#----------------------------------------------------------#
68+
# Hestia #
69+
#----------------------------------------------------------#
70+
71+
# Logging
72+
log_history "Enabled HTTP Strict Transport Security on $domain."
73+
log_event "$OK" "$ARGUMENTS"
74+
75+
exit

0 commit comments

Comments
 (0)