Skip to content

Commit 3296251

Browse files
author
Kristan Kenney
committed
Merge branch 'main' into feature/user-roles
2 parents 9d17705 + 57a0fba commit 3296251

File tree

19 files changed

+68
-57
lines changed

19 files changed

+68
-57
lines changed

bin/v-backup-user

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ let u_disk=$(grep "U_DISK=" $HESTIA/data/users/$user/user.conf |cut -f 2 -d \')*
7070
let v_disk=$(($(stat -f --format="%a*%S" $BACKUP)))/1024/1024
7171

7272
if [ "$u_disk" -gt "$v_disk" ]; then
73-
echo "not enough diskspace available to perform the backup." |$SENDMAIL -s "$subj" $email $notify
73+
# Always notify on failure
74+
echo "not enough diskspace available to perform the backup." | $SENDMAIL -s "$subj" $email "yes"
7475
check_result $E_LIMIT "not enough diskspace available to perform the backup."
7576
fi
7677

@@ -82,7 +83,7 @@ fi
8283
tmpdir=$(mktemp -p $BACKUP_TEMP -d)
8384

8485
if [ "$?" -ne 0 ]; then
85-
echo "Can't create tmp dir $tmpdir" |$SENDMAIL -s "$subj" $email $notify
86+
echo "Can't create tmp dir $tmpdir" |$SENDMAIL -s "$subj" $email "yes"
8687
check_result $E_NOTEXIST "can't create tmp dir"
8788
fi
8889

@@ -592,6 +593,7 @@ backup_new_date=$(date +"%Y-%m-%d_%H-%M-%S")
592593

593594
echo -e "\n-- SUMMARY --" |tee -a $BACKUP/$user.log
594595

596+
errorcode="0"
595597
# Switching on backup system types
596598
for backup_type in $(echo -e "${BACKUP_SYSTEM//,/\\n}"); do
597599
case $backup_type in
@@ -605,7 +607,18 @@ done
605607

606608
# Removing tmpdir
607609
rm -rf $tmpdir
610+
if [[ "$errorcode" != "0" ]]; then
611+
if [[ "$BACKUP_SYSTEM" =~ "local" ]]; then
612+
echo -e "$(date "+%F %T") *** Local backup was successfully executed. Remote backup failed ***" |\
613+
tee -a $BACKUP/$user.log
614+
BACKUP_SYSTEM="local"
615+
else
616+
echo -e "$(date "+%F %T") *** Remote backup failed ***" |\
617+
tee -a $BACKUP/$user.log
608618

619+
exit $error_code;
620+
fi
621+
fi
609622
# Calculation run time
610623
run_time=$((end_time - start_time))
611624
run_time=$((run_time / 60))

bin/v-restore-user

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,6 @@ if [ "$web" != 'no' ] && [ ! -z "$WEB_SYSTEM" ]; then
287287
FTP_USER="${user}_${FTP_USER}"
288288
fi
289289

290-
# Converting stats users
291-
if [ ! -z "$STATS_USER" ]; then
292-
STATS_USER=$(echo "$STATS_USER" |sed -e "s/${old_user}_//")
293-
STATS_USER="${user}_${STATS_USER}"
294-
fi
295-
296290
# Copying SSL certificates
297291
if [ "$SSL" = 'yes' ]; then
298292

@@ -309,15 +303,16 @@ if [ "$web" != 'no' ] && [ ! -z "$WEB_SYSTEM" ]; then
309303
done
310304
fi
311305
fi
312-
306+
313307
# Merging web.conf keys
314308
str="DOMAIN='$domain' IP='$IP' IP6='$IP6' ALIAS='$ALIAS'"
315309
str="$str CUSTOM_DOCROOT='$CUSTOM_DOCROOT' CUSTOM_PHPROOT='$CUSTOM_PHPROOT'"
316310
str="$str REDIRECT='$REDIRECT' REDIRECT_CODE='$REDIRECT_CODE'"
317311
str="$str FASTCGI_CACHE='$FASTCGI_CACHE' FASTCGI_DURATION='$FASTCGI_DURATION'"
318312
str="$str TPL='$TPL' SSL='$SSL' SSL_HOME='$SSL_HOME'"
319313
str="$str LETSENCRYPT='$LETSENCRYPT' FTP_USER='$FTP_USER'"
320-
str="$str FTP_MD5='$FTP_MD5' BACKEND='$BACKEND' PROXY='$PROXY'"
314+
str="$str FTP_MD5='$FTP_MD5' FTP_PATH='$FTP_PATH'"
315+
str="$str BACKEND='$BACKEND' PROXY='$PROXY'"
321316
str="$str PROXY_EXT='$PROXY_EXT' STATS='$STATS'"
322317
str="$str STATS_USER='$STATS_USER' STATS_CRYPT='$STATS_CRYPT'"
323318
str="$str U_DISK='$U_DISK' U_BANDWIDTH='0' SUSPENDED='no'"
@@ -328,11 +323,11 @@ if [ "$web" != 'no' ] && [ ! -z "$WEB_SYSTEM" ]; then
328323
if [ ! -z "$WEB_BACKEND" ]; then
329324
$BIN/v-add-web-domain-backend $user $domain $BACKEND
330325
fi
331-
332-
# Rebuilding vhost
333-
rebuild_web_domain_conf
334326
fi
335-
327+
328+
# Rebuilding vhost
329+
rebuild_web_domain_conf
330+
336331
# Restoring web domain data
337332
if [ -d "$HOMEDIR/$user/web/$domain/public_html" ]; then
338333
rm -rf $HOMEDIR/$user/web/$domain/public_html/*
@@ -365,6 +360,9 @@ if [ "$web" != 'no' ] && [ ! -z "$WEB_SYSTEM" ]; then
365360
find $HOMEDIR/$user/web/$domain/ -user $old_uid \
366361
-exec chown -h $user:$user {} \;
367362
fi
363+
364+
# Rebuilding web config for the second time to make sure ftp users keep working
365+
rebuild_web_domain_conf
368366
done
369367

370368
# Adding user to traffic queue

func/backup.sh

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ local_backup(){
2525
rm -rf $tmpdir
2626
rm -f $BACKUP/$user.log
2727
sed -i "/ $user /d" $HESTIA/data/queue/backup.pipe
28-
echo "Not enough disk space" |$SENDMAIL -s "$subj" $email $notify
28+
echo "Not enough disk space" |$SENDMAIL -s "$subj" $email "yes"
2929
check_result "$E_DISK" "Not enough dsk space"
3030
fi
3131

@@ -58,11 +58,11 @@ ftp_backup() {
5858
# Checking config
5959
if [ ! -e "$HESTIA/conf/ftp.backup.conf" ]; then
6060
error="ftp.backup.conf doesn't exist"
61-
rm -rf $tmpdir
62-
rm -f $BACKUP/$user.log
63-
echo "$error" |$SENDMAIL -s "$subj" $email $notify
61+
echo "$error" |$SENDMAIL -s "$subj" $email "yes"
6462
sed -i "/ $user /d" $HESTIA/data/queue/backup.pipe
65-
check_result "$E_NOTEXIST" "$error"
63+
echo "$error"
64+
errorcode="$E_NOTEXIST"
65+
return "$E_NOTEXIST"
6666
fi
6767

6868
# Parse config
@@ -76,11 +76,11 @@ ftp_backup() {
7676
# Checking variables
7777
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
7878
error="Can't parse ftp backup configuration"
79-
rm -rf $tmpdir
80-
rm -f $BACKUP/$user.log
81-
echo "$error" |$SENDMAIL -s "$subj" $email $notify
79+
echo "$error" |$SENDMAIL -s "$subj" $email "yes"
8280
sed -i "/ $user /d" $HESTIA/data/queue/backup.pipe
83-
check_result "$E_PARSING" "$error"
81+
echo "$error"
82+
errorcode="$E_PARSING"
83+
return "$E_PARSING"
8484
fi
8585

8686
# Debug info
@@ -91,11 +91,11 @@ ftp_backup() {
9191
ferror=$(echo $fconn |grep -i -e failed -e error -e "Can't" -e "not conn")
9292
if [ ! -z "$ferror" ]; then
9393
error="Error: can't login to ftp ftp://$USERNAME@$HOST"
94-
rm -rf $tmpdir
95-
rm -f $BACKUP/$user.log
9694
echo "$error" |$SENDMAIL -s "$subj" $email $notify
9795
sed -i "/ $user /d" $HESTIA/data/queue/backup.pipe
98-
check_result "$E_CONNECT" "$error"
96+
echo "$error"
97+
errorcode="$E_CONNECT"
98+
return "$E_CONNECT"
9999
fi
100100

101101
# Check ftp permissions
@@ -109,11 +109,11 @@ ftp_backup() {
109109
ftp_result=$(ftpc "mkdir $ftmpdir" "rm $ftmpdir" |grep -v Trying)
110110
if [ ! -z "$ftp_result" ] ; then
111111
error="Can't create ftp backup folder ftp://$HOST$BPATH"
112-
rm -rf $tmpdir
113-
rm -f $BACKUP/$user.log
114112
echo "$error" |$SENDMAIL -s "$subj" $email $notify
115113
sed -i "/ $user /d" $HESTIA/data/queue/backup.pipe
116-
check_result "$E_FTP" "$error"
114+
echo "$error"
115+
errorcode="$E_FTP"
116+
return "$E_FTP"
117117
fi
118118

119119
# Checking retention
@@ -277,11 +277,11 @@ sftp_backup() {
277277
# Checking config
278278
if [ ! -e "$HESTIA/conf/sftp.backup.conf" ]; then
279279
error="Can't open sftp.backup.conf"
280-
rm -rf $tmpdir
281-
rm -f $BACKUP/$user.log
282-
echo "$error" |$SENDMAIL -s "$subj" $email $notify
280+
echo "$error" |$SENDMAIL -s "$subj" $email "yes"
283281
sed -i "/ $user /d" $HESTIA/data/queue/backup.pipe
284-
check_result "$E_NOTEXIST" "$error"
282+
echo "$error"
283+
errorcode="$E_NOTEXIST"
284+
return "$E_NOTEXIST"
285285
fi
286286

287287
# Parse config
@@ -295,11 +295,11 @@ sftp_backup() {
295295
# Checking variables
296296
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
297297
error="Can't parse sftp backup configuration"
298-
rm -rf $tmpdir
299-
rm -f $BACKUP/$user.log
300-
echo "$error" |$SENDMAIL -s "$subj" $email $notify
298+
echo "$error" |$SENDMAIL -s "$subj" $email "yes"
301299
sed -i "/ $user /d" $HESTIA/data/queue/backup.pipe
302-
check_result "$E_PARSING" "$error"
300+
echo "$error"
301+
errorcode="$E_PARSING"
302+
return "$E_PARSING"
303303
fi
304304

305305
# Debug info
@@ -320,11 +320,11 @@ sftp_backup() {
320320
$E_CONNECT) error="Can't login to sftp host $HOST" ;;
321321
$E_FTP) error="Can't create temp folder on sftp $HOST" ;;
322322
esac
323-
rm -rf $tmpdir
324-
rm -f $BACKUP/$user.log
325-
echo "$error" |$SENDMAIL -s "$subj" $email $notify
323+
echo "$error" |$SENDMAIL -s "$subj" $email "yes"
326324
sed -i "/ $user /d" $HESTIA/data/queue/backup.pipe
327-
check_result "$rc" "$error"
325+
echo "$error"
326+
errorcode="$rc"
327+
return "$rc"
328328
fi
329329

330330
# Checking retention

install/upgrade/versions/1.0.1.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# Hestia Control Panel upgrade script for target version 1.0.1
44

install/upgrade/versions/1.0.2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# Hestia Control Panel upgrade script for target version 1.0.2
44

install/upgrade/versions/1.0.3.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# Hestia Control Panel upgrade script for target version 1.0.3
44

install/upgrade/versions/1.0.4.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# Hestia Control Panel upgrade script for target version 1.0.4
44

install/upgrade/versions/1.0.5.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# Hestia Control Panel upgrade script for target version 1.0.5
44

install/upgrade/versions/1.0.6.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# Hestia Control Panel upgrade script for target version 1.0.6
44

install/upgrade/versions/1.1.0.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# Hestia Control Panel upgrade script for target version 1.1.0
44

0 commit comments

Comments
 (0)