Skip to content

Commit 2b37760

Browse files
author
Kristan Kenney
committed
Merge remote-tracking branch 'jaapmarcus/fix/v-restore-user' into main
2 parents fba26b4 + 662a6e0 commit 2b37760

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

bin/v-restore-user

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ if [ "$web" != 'no' ] && [ ! -z "$WEB_SYSTEM" ]; then
310310

311311
# Merging web.conf keys
312312
str="DOMAIN='$domain' IP='$IP' IP6='$IP6' ALIAS='$ALIAS'"
313-
str="$str CUSTOM_DOCROOT='$CUSTOM_DOCROOT' CUSTOM_PHPROOT='$CUSTOM_PHPROOT' IP='$IP' IP6='$IP6' ALIAS='$ALIAS'"
313+
str="$str CUSTOM_DOCROOT='$CUSTOM_DOCROOT' CUSTOM_PHPROOT='$CUSTOM_PHPROOT'"
314+
str="$str REDIRECT='$REDIRECT' REDIRECT_CODE='$REDIRECT_CODE'"
315+
str="$str FASTCGI_CACHE='$FASTCGI_CACHE' FASTCGI_CACHE_LENGTH='$FASTCGI_CACHE_LENGTH'"
314316
str="$str TPL='$TPL' SSL='$SSL' SSL_HOME='$SSL_HOME'"
315317
str="$str LETSENCRYPT='$LETSENCRYPT' FTP_USER='$FTP_USER'"
316318
str="$str FTP_MD5='$FTP_MD5' BACKEND='$BACKEND' PROXY='$PROXY'"
@@ -542,20 +544,29 @@ if [ "$mail" != 'no' ] && [ ! -z "$MAIL_SYSTEM" ]; then
542544
if [ ! -e "$HOMEDIR/$user/conf/mail/$domain/ssl/" ]; then
543545
mkdir -p $HOMEDIR/$user/conf/mail/$domain/ssl/
544546
fi
545-
547+
546548
# Add certificate to Hestia user configuration data directory
547549
if [ -f $tmpdir/mail/$domain/$backup_system/ssl/$domain.crt ]; then
548-
echo "path found"
549550
cp -f $tmpdir/mail/$domain/$backup_system/ssl/$domain.crt $USER_DATA/ssl/mail.$domain.crt
550551
cp -f $tmpdir/mail/$domain/$backup_system/ssl/$domain.key $USER_DATA/ssl/mail.$domain.key
551552
cp -f $tmpdir/mail/$domain/$backup_system/ssl/$domain.crt $USER_DATA/ssl/mail.$domain.pem
552-
if [ -e "$tmpdir/mail/$domain/$backup_system/ssl//$domain.ca" ]; then
553-
cp -f $tmpdir/mail/$domain/$backup_system/ssl//$domain.ca $USER_DATA/ssl/mail.$domain.ca
553+
if [ -e "$tmpdir/mail/$domain/$backup_system/ssl/$domain.ca" ]; then
554+
cp -f $tmpdir/mail/$domain/$backup_system/ssl/$domain.ca $USER_DATA/ssl/mail.$domain.ca
555+
echo >> $USER_DATA/ssl/mail.$domain.pem
556+
cat $USER_DATA/ssl/mail.$domain.ca >> $USER_DATA/ssl/mail.$domain.pem
557+
fi
558+
elif [ -f "$tmpdir/mail/$domain/conf/ssl/$domain.crt" ]; then
559+
cp -f $tmpdir/mail/$domain/conf/ssl/$domain.crt $USER_DATA/ssl/mail.$domain.crt
560+
cp -f $tmpdir/mail/$domain/conf/ssl/$domain.key $USER_DATA/ssl/mail.$domain.key
561+
cp -f $tmpdir/mail/$domain/conf/ssl/$domain.crt $USER_DATA/ssl/mail.$domain.pem
562+
if [ -e "$tmpdir/mail/$domain/conf/ssl/$domain.ca" ]; then
563+
cp -f $tmpdir/mail/$domain/conf/ssl/$domain.ca $USER_DATA/ssl/mail.$domain.ca
554564
echo >> $USER_DATA/ssl/mail.$domain.pem
555565
cat $USER_DATA/ssl/mail.$domain.ca >> $USER_DATA/ssl/mail.$domain.pem
556566
fi
567+
557568
fi
558-
569+
559570
chmod 660 $USER_DATA/ssl/mail.$domain.*
560571

561572
# Add certificate to user home directory
@@ -600,18 +611,24 @@ if [ "$mail" != 'no' ] && [ ! -z "$MAIL_SYSTEM" ]; then
600611
chmod -R 0644 /usr/local/hestia/ssl/mail/*
601612
chown -h $user:mail /usr/local/hestia/ssl/mail/*
602613
fi
603-
614+
604615
# Restoring email accounts
605616
cp -f $tmpdir/mail/$domain/$backup_system/$domain.conf $USER_DATA/mail/
606-
617+
607618
domain_idn=$domain
608619
format_domain_idn
609620

621+
if [ ! -d "$HOMEDIR/$user/mail/$domain_idn" ]; then
622+
mkdir $HOMEDIR/$user/mail/$domain_idn
623+
fi
624+
625+
# Current Hestia store email in the $HOMEDIR/$user/mail/$domain_idn
626+
chmod u+w "$HOMEDIR/$user/mail/$domain_idn"
627+
chown $user:$user "$HOMEDIR/$user/mail/$domain_idn"
628+
610629
# Restoring emails
611630
if [ $backup_mode = 'zstd' ]; then
612631
if [ -e "$tmpdir/mail/$domain/accounts.tar.zst" ]; then
613-
# Current Hestia store email in the $HOMEDIR/$user/mail/$domain_idn
614-
chmod u+w "$HOMEDIR/$user/mail/$domain_idn"
615632
$BIN/v-extract-fs-archive "$user" "$tmpdir/mail/$domain/accounts.tar.zst" "$HOMEDIR/$user/mail/$domain_idn/"
616633
if [ "$?" -ne 0 ]; then
617634
rm -rf $tmpdir
@@ -627,7 +644,6 @@ if [ "$mail" != 'no' ] && [ ! -z "$MAIL_SYSTEM" ]; then
627644
fi
628645
else
629646
if [ -e "$tmpdir/mail/$domain/accounts.tar.gz" ]; then
630-
chmod u+w "$HOMEDIR/$user/mail/$domain_idn"
631647
$BIN/v-extract-fs-archive "$user" "$tmpdir/mail/$domain/accounts.tar.gz" "$HOMEDIR/$user/mail/$domain_idn/"
632648
if [ "$?" -ne 0 ]; then
633649
rm -rf $tmpdir
@@ -643,9 +659,13 @@ if [ "$mail" != 'no' ] && [ ! -z "$MAIL_SYSTEM" ]; then
643659
fi
644660
fi
645661
# Chowning mail conf files to exim user
646-
find $HOMEDIR/$user/conf/mail/$domain -user root \
647-
-exec chown $exim_user {} \;
648-
662+
if [ -d "$HOMEDIR/$user/conf/mail/$domain" ]; then
663+
find $HOMEDIR/$user/conf/mail/$domain -user root \
664+
-exec chown $exim_user {} \;
665+
fi
666+
667+
$HESTIA/bin/v-rebuild-mail-domain $user $domain
668+
649669
done
650670

651671
# Restarting web server

0 commit comments

Comments
 (0)