Skip to content

Commit d106876

Browse files
author
Kristan Kenney
committed
Merge branch 'bugfix-backend' into develop
2 parents a82cb4e + b2f7660 commit d106876

16 files changed

+315
-74
lines changed

bin/v-backup-user

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ if [ -e "$BACKUP/$user.log" ]; then
937937
email=$(get_user_value '$CONTACT')
938938
cat $BACKUP/$user.log |$SENDMAIL -s "$subj" $email $notify
939939
rm $BACKUP/$user.log
940+
$BIN/v-add-user-notification $user "$subj" "$email"
940941
fi
941942

942943
# Logging

bin/v-change-sys-hestia-ssl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ else
4949
is_web_domain_cert_valid
5050
fi
5151

52-
# Moving old certificate
53-
mv $HESTIA/ssl/certificate.crt $HESTIA/ssl/certificate.crt.back
54-
mv $HESTIA/ssl/certificate.key $HESTIA/ssl/certificate.key.back
55-
5652
# Adding new certificate
5753
cp -f $ssl_dir/certificate.crt $HESTIA/ssl/certificate.crt
5854
cp -f $ssl_dir/certificate.key $HESTIA/ssl/certificate.key

bin/v-change-sys-release

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,20 @@ if [ -z "$branch" ]; then
3636
echo ""
3737
exit
3838
else
39+
# Check that requested branch exists
40+
echo "Checking for existence of $branch branch..."
41+
branch_check=$(curl -s --head -w %{http_code} https://raw.githubusercontent.com/hestiacp/hestiacp/$branch/src/deb/hestia/control -o /dev/null)
42+
if [ $branch_check -ne "200" ]; then
43+
echo "Error: invalid branch name specified."
44+
exit 1
45+
fi
46+
3947
# Remove old branch variable
4048
sed -i "/RELEASE_BRANCH/d" $HESTIA/conf/hestia.conf
49+
4150
# Set new branch variable
4251
echo "RELEASE_BRANCH='$branch'" >> $HESTIA/conf/hestia.conf
43-
echo "Changed system to follow release branch: $branch"
52+
echo "Changed system release to update from Git branch: $branch"
4453
fi
4554

4655
#----------------------------------------------------------#

bin/v-change-sys-webmail

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
# Variable&Function #
1010
#----------------------------------------------------------#
1111

12-
# Argument definition
13-
WEBMAIL=$1
14-
1512
# Includes
1613
source $HESTIA/func/main.sh
1714
source $HESTIA/conf/hestia.conf
@@ -23,12 +20,6 @@ export $WEBMAIL_ALIAS
2320
OLD_ALIAS=$WEBMAIL_ALIAS
2421
NEW_ALIAS=$1
2522

26-
#----------------------------------------------------------#
27-
# Verifications #
28-
#----------------------------------------------------------#
29-
30-
check_args '1' "$#" 'WEBMAIL'
31-
3223
#----------------------------------------------------------#
3324
# Action #
3425
#----------------------------------------------------------#
@@ -41,18 +32,17 @@ for user in `ls /usr/local/hestia/data/users/`; do
4132
done
4233

4334
# Set new webmail alias
44-
sed -i "s|WEBMAIL_ALIAS='$OLD_ALIAS'|WEBMAIL_ALIAS='$NEW_ALIAS'|gI" $HESTIA/conf/hestia.conf
35+
$BIN/v-change-sys-config-value 'WEBMAIL_ALIAS' $NEW_ALIAS
4536

4637
for user in `ls /usr/local/hestia/data/users/`; do
4738
for domain in $($BIN/v-list-web-domains $user plain |cut -f 1); do
48-
echo "Changing webmail alias for $domain"
4939
$BIN/v-add-webmail $user $domain
5040
done
5141
done
5242

53-
# Update alias (non-subdomain) configuration to match
54-
sed -i "s|Alias \/webmail|Alias \/$NEW_ALIAS|gI" /etc/apache2/conf.d/roundcube.conf
55-
sed -i "s|location \/webmail|location \/$NEW_ALIAS|gI" /etc/nginx/conf.d/webmail.inc
43+
# Update global directory alias configuration
44+
sed -i "s|Alias \/$OLD_ALIAS|Alias \/$NEW_ALIAS|gI" /etc/apache2/conf.d/roundcube.conf
45+
sed -i "s|location \/$OLD_ALIAS|location \/$NEW_ALIAS|gI" /etc/nginx/conf.d/webmail.inc
5646

5747
#----------------------------------------------------------#
5848
# Hestia #
@@ -63,7 +53,7 @@ $BIN/v-restart-web $restart
6353
$BIN/v-restart-proxy $restart
6454

6555
# Logging
66-
log_history "changed system webmail alias to $NEW_ALIAS"
56+
log_history "changed global webmail alias to $NEW_ALIAS"
6757
log_event "$OK" "$ARGUMENTS"
6858

6959
exit

bin/v-change-web-domain-dirlist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ if [ "$mode" = "on" ]; then
5151
# Enable directory listing for SSL-enforced domains
5252
sed -i "s/-Index/+Index/g" $HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.ssl.conf
5353
fi
54-
echo "INFO: Enabled directory browsing for $domain."
54+
echo "Enabled directory browsing for $domain."
5555
else
5656
# Disable directory listing
5757
sed -i "s/+Index/-Index/g" $HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.conf
5858
if [ -e "$ssl_dir/$domain.ca" ]; then
5959
# Enable directory listing for SSL-enforced domains
6060
sed -i "s/+Index/-Index/g" $HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.ssl.conf
6161
fi
62-
echo "INFO: Disabled directory browsing for $domain."
62+
echo "Disabled directory browsing for $domain."
6363
fi
6464

6565

bin/v-rebuild-database

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
# info: rebuild databases
3+
# options: USER
4+
#
5+
# The function for rebuilding a single database for a user
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument definition
13+
user=$1
14+
database=$2
15+
16+
# Includes
17+
source $HESTIA/func/main.sh
18+
source $HESTIA/func/db.sh
19+
source $HESTIA/func/rebuild.sh
20+
source $HESTIA/conf/hestia.conf
21+
22+
23+
#----------------------------------------------------------#
24+
# Verifications #
25+
#----------------------------------------------------------#
26+
27+
check_args '2' "$#" 'USER DATABASE'
28+
is_format_valid 'user'
29+
is_system_enabled "$DB_SYSTEM" 'DB_SYSTEM'
30+
is_object_valid 'user' 'USER' "$user"
31+
is_object_valid 'db' 'DB' "$database"
32+
33+
34+
#----------------------------------------------------------#
35+
# Action #
36+
#----------------------------------------------------------#
37+
38+
# Get database values
39+
get_database_values
40+
41+
# Switching on db type
42+
case $TYPE in
43+
mysql) rebuild_mysql_database ;;
44+
pgsql) rebuild_pgsql_database ;;
45+
esac
46+
47+
U_DISK_DB=$((U_DISK_DB + U_DISK))
48+
U_DATABASES=$((U_DATABASES + 1))
49+
if [ "$SUSPENDED" = 'yes' ]; then
50+
SUSPENDED_DB=$((SUSPENDED_DB + 1))
51+
fi
52+
53+
update_user_value "$user" '$SUSPENDED_DB' "$SUSPENDED_DB"
54+
update_user_value "$user" '$U_DATABASES' "$U_DATABASES"
55+
update_user_value "$user" '$U_DISK_DB' "$U_DISK_DB"
56+
57+
58+
#----------------------------------------------------------#
59+
# Hestia #
60+
#----------------------------------------------------------#
61+
62+
# Logging
63+
log_event "$OK" "$ARGUMENTS"
64+
65+
exit

bin/v-rebuild-mail-domain

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
# info: rebuild mail domain
3+
# options: USER DOMAIN
4+
#
5+
# The function rebuilds configuration files for a single domain.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument definition
13+
user=$1
14+
domain=$2
15+
16+
# Includes
17+
source $HESTIA/func/main.sh
18+
source $HESTIA/func/domain.sh
19+
source $HESTIA/func/rebuild.sh
20+
source $HESTIA/conf/hestia.conf
21+
22+
23+
#----------------------------------------------------------#
24+
# Verifications #
25+
#----------------------------------------------------------#
26+
27+
check_args '2' "$#" 'USER DOMAIN'
28+
is_format_valid 'user'
29+
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
30+
is_object_valid 'user' 'USER' "$user"
31+
is_object_unsuspended 'user' 'USER' "$user"
32+
is_object_valid 'mail' 'DOMAIN' "$domain"
33+
34+
if [ "$MAIL_SYSTEM" = 'remote' ]; then
35+
exit
36+
fi
37+
38+
39+
#----------------------------------------------------------#
40+
# Action #
41+
#----------------------------------------------------------#
42+
43+
# Rebuild mail domain configuration
44+
rebuild_mail_domain_conf
45+
46+
# Rebuild webmail configuration
47+
if [ ! -z "$WEB_SYSTEM" ] || [ ! -z "$PROXY_SYSTEM" ]; then
48+
$BIN/v-delete-webmail $user $domain ''
49+
$BIN/v-add-webmail $user $domain ''
50+
fi
51+
52+
#----------------------------------------------------------#
53+
# Hestia #
54+
#----------------------------------------------------------#
55+
56+
# Updating counters
57+
update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS"
58+
update_user_value "$user" '$U_MAIL_DKIM' "$U_MAIL_DKIM"
59+
update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS"
60+
update_user_value "$user" '$U_MAIL_SSL' "$U_MAIL_SSL"
61+
update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL"
62+
update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL"
63+
64+
# Update disk usage statistics
65+
$BIN/v-update-user-disk $user
66+
67+
# Logging
68+
log_event "$OK" "$ARGUMENTS"
69+
70+
exit

bin/v-rebuild-mail-domains

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,12 @@ U_MAIL_SSL=0
4545
SUSPENDED_MAIL=0
4646
U_DISK_MAIL=0
4747

48-
# Checking mail folder
49-
if [ ! -d "$USER_DATA/mail" ]; then
50-
rm -f $USER_DATA/mail
51-
mkdir $USER_DATA/mail
52-
fi
53-
5448
# Starting loop
5549
for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do
5650
rebuild_mail_domain_conf
5751
if [ ! -z "$WEB_SYSTEM" ] || [ ! -z "$PROXY_SYSTEM" ]; then
5852
$BIN/v-delete-webmail $user $domain ''
59-
$BIN/v-add-webmail $user $domain ''
60-
sleep 0.5
53+
$BIN/v-add-webmail $user $domain ''
6154
fi
6255
done
6356

@@ -74,7 +67,8 @@ update_user_value "$user" '$U_MAIL_SSL' "$U_MAIL_SSL"
7467
update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL"
7568
update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL"
7669

77-
recalc_user_disk_usage
70+
# Update disk usage statistics
71+
$BIN/v-update-user-disk $user
7872

7973
# Logging
8074
log_event "$OK" "$ARGUMENTS"

bin/v-rebuild-user

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ fi
4444
# Rebuild user
4545
rebuild_user_conf
4646

47+
# Update user counters
48+
$BIN/v-update-user-counters $user
49+
50+
# Update account usage statistics
51+
$BIN/v-update-user-stats $user
52+
4753

4854
#----------------------------------------------------------#
4955
# Hestia #

bin/v-rebuild-users

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# info: rebuild system user
3+
# options: USER [RESTART]
4+
#
5+
# The function rebuilds system user accounts.
6+
7+
#----------------------------------------------------------#
8+
# Variable&Function #
9+
#----------------------------------------------------------#
10+
11+
# Argument definition
12+
restart=$1
13+
14+
# Includes
15+
source $HESTIA/func/main.sh
16+
source $HESTIA/func/rebuild.sh
17+
source $HESTIA/conf/hestia.conf
18+
19+
# Export sbin
20+
export PATH=$PATH:/usr/sbin
21+
22+
23+
#----------------------------------------------------------#
24+
# Verifications #
25+
#----------------------------------------------------------#
26+
27+
check_args '1' "$#" 'USER [RESTART]'
28+
is_format_valid 'user'
29+
is_object_valid 'user' 'USER' "$user"
30+
is_object_unsuspended 'user' 'USER' "$user"
31+
32+
33+
#----------------------------------------------------------#
34+
# Action #
35+
#----------------------------------------------------------#
36+
37+
# Rebuild loop
38+
for user in $($BIN/v-list-users plain |cut -f 1); do
39+
$BIN/v-rebuild-user $user
40+
done
41+
42+
43+
#----------------------------------------------------------#
44+
# Hestia #
45+
#----------------------------------------------------------#
46+
47+
# Logging
48+
log_event "$OK" "$ARGUMENTS"
49+
50+
exit

0 commit comments

Comments
 (0)