add verbose option to bin/vmail-domains-exp.sh

This commit is contained in:
Matthew Saunders Brown 2023-10-09 16:35:30 -07:00
parent d6f35d6f78
commit a88ef93d49
2 changed files with 15 additions and 9 deletions

View File

@ -14,10 +14,11 @@ help()
echo "$thisfilename" echo "$thisfilename"
echo "Export vmail settings, for backups and/or migrating to a new server." echo "Export vmail settings, for backups and/or migrating to a new server."
echo "" echo ""
echo "usage: $thisfilename -d <domain>" echo "usage: $thisfilename -d <domain> [-v] [-h]"
echo "" echo ""
echo " -h Print this help." echo " -h Print this help."
echo " -d Domain to export settings for." 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 exit
} }
@ -93,14 +94,19 @@ if [[ "$domains_id" -gt '0' ]] ; then
/usr/local/bin/vmail-roundcubemail-settings-export.php $domain /usr/local/bin/vmail-roundcubemail-settings-export.php $domain
fi fi
servername=`hostname -f` # output instructions for sycning website to new server, if verbose option was enabled.
if [[ -n $verbose ]]; then
echo servername=`hostname -f`
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 echo "Vmail configs for $domain have been exported."
echo "rsync -v --archive --relative --rsh=/usr/bin/ssh root@$servername:/var/vmail/$domain /" echo "To migrate to a new server run these commands (as root) from the new server:"
echo "vmail-domains-imp.sh -d $domain" echo
echo "rsync -v --archive --relative --rsh=/usr/bin/ssh root@$servername:/var/vmail/$domain /"
echo "vmail-domains-imp.sh -d $domain"
fi
else else

View File

@ -12,7 +12,7 @@ readonly VMAIL_DIR=/var/vmail
readonly MYSQL_CONNECTION_INFO_FILE=$VMAIL_DIR/.my.cnf readonly MYSQL_CONNECTION_INFO_FILE=$VMAIL_DIR/.my.cnf
# switch to required user # 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 if [[ "$USER" != "root" ]]; then
exec sudo -u root $0 "$@" exec sudo -u root $0 "$@"
fi fi