From a88ef93d4958fa32aa29eecfd52d9df9953a3a05 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Mon, 9 Oct 2023 16:35:30 -0700 Subject: [PATCH] add verbose option to bin/vmail-domains-exp.sh --- bin/vmail-domains-exp.sh | 22 ++++++++++++++-------- bin/vmail.sh | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/bin/vmail-domains-exp.sh b/bin/vmail-domains-exp.sh index db45980..324baa2 100755 --- a/bin/vmail-domains-exp.sh +++ b/bin/vmail-domains-exp.sh @@ -14,10 +14,11 @@ help() echo "$thisfilename" echo "Export vmail settings, for backups and/or migrating to a new server." echo "" - echo "usage: $thisfilename -d " + echo "usage: $thisfilename -d [-v] [-h]" echo "" echo " -h Print this help." echo " -d Domain to export settings for." + echo " -v Verbose - output instructions for sycning vmail domain to new server, if verbose option was enabled." exit } @@ -93,14 +94,19 @@ if [[ "$domains_id" -gt '0' ]] ; then /usr/local/bin/vmail-roundcubemail-settings-export.php $domain fi - servername=`hostname -f` + # output instructions for sycning website to new server, if verbose option was enabled. + if [[ -n $verbose ]]; then - echo - echo "Vmail configs for $domain have been exported." - echo "To migrate to a new server run these commands (as root) from the new server:" - echo - echo "rsync -v --archive --relative --rsh=/usr/bin/ssh root@$servername:/var/vmail/$domain /" - echo "vmail-domains-imp.sh -d $domain" + servername=`hostname -f` + + echo + echo "Vmail configs for $domain have been exported." + echo "To migrate to a new server run these commands (as root) from the new server:" + echo + echo "rsync -v --archive --relative --rsh=/usr/bin/ssh root@$servername:/var/vmail/$domain /" + echo "vmail-domains-imp.sh -d $domain" + + fi else diff --git a/bin/vmail.sh b/bin/vmail.sh index 20d1e5d..545e73d 100755 --- a/bin/vmail.sh +++ b/bin/vmail.sh @@ -12,7 +12,7 @@ readonly VMAIL_DIR=/var/vmail readonly MYSQL_CONNECTION_INFO_FILE=$VMAIL_DIR/.my.cnf # switch to required user -if [[ $(basename $0) == "vmail-domains-exp.sh" ]] || [[ $(basename $0) == "vmail-domains-imp.sh" ]] || [[ $(basename $0) == "vmail-dovecot-"* ]]; then +if [[ $(basename $0) == "vmail-domains-arc.sh" ]] || [[ $(basename $0) == "vmail-domains-exp.sh" ]] || [[ $(basename $0) == "vmail-domains-imp.sh" ]] || [[ $(basename $0) == "vmail-dovecot-"* ]]; then if [[ "$USER" != "root" ]]; then exec sudo -u root $0 "$@" fi