From e54fcfdab18980a7bb130de89508ce2c540095a0 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Fri, 19 Feb 2021 17:03:56 -0800 Subject: [PATCH] changed echo to eval --- bin/vmail-domains-del.sh | 16 ++++++++-------- bin/vmail-mboxes-add.sh | 11 +++++------ bin/vmail-mboxes-del.sh | 22 +++++++++++----------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/bin/vmail-domains-del.sh b/bin/vmail-domains-del.sh index f57165b..cdd16d7 100755 --- a/bin/vmail-domains-del.sh +++ b/bin/vmail-domains-del.sh @@ -61,14 +61,14 @@ if [ "$rowcount" -eq '1' ] ; then # domain exists, delete from all vmail tables # singled delete should be sufficient for vm_* tables due to ON DELETE CASCADE foreign key references dbquery="DELETE FROM vm_domains WHERE domain='$domain';" - echo $dbcmd $dbcmdopts "\"$dbquery\"" - dbquery="DELETE FROM sa_userpref WHERE username LIKE '%@$domain'" - echo $dbcmd $dbcmdopts "\"$dbquery\"" - dbquery="DELETE FROM vm_greylisting WHERE recipient LIKE '%@$domain'" - echo $dbcmd $dbcmdopts "\"$dbquery\"" + eval $dbcmd $dbcmdopts "\"$dbquery\"" + dbquery="DELETE FROM sa_userpref WHERE username LIKE '%@$domain';" + eval $dbcmd $dbcmdopts "\"$dbquery\"" + dbquery="DELETE FROM vm_greylisting WHERE recipient LIKE '%@$domain';" + eval $dbcmd $dbcmdopts "\"$dbquery\"" # this should be sufficient for rc due to ON DELETE CASCADE foreign key references - dbquery="DELETE FROM rc_users WHERE username LIKE '%@$domain'" - echo $dbcmd $dbcmdopts "\"$dbquery\"" + dbquery="DELETE FROM rc_users WHERE username LIKE '%@$domain';" + eval $dbcmd $dbcmdopts "\"$dbquery\"" elif [ "$rowcount" -eq '0' ] ; then echo "ERROR: $domain does not exist in vmail database." exit 1 @@ -78,5 +78,5 @@ else fi if [ -d "$VMAIL_DIR/$domain" ] ; then - echo "/usr/bin/rm -r $VMAIL_DIR/$domain" + /usr/bin/rm -r $VMAIL_DIR/$domain fi diff --git a/bin/vmail-mboxes-add.sh b/bin/vmail-mboxes-add.sh index af6e807..fe63c6b 100755 --- a/bin/vmail-mboxes-add.sh +++ b/bin/vmail-mboxes-add.sh @@ -117,19 +117,18 @@ else fi # add mbox -# evail $dbcmd -echo $dbcmd +eval $dbcmd # create all required vmail dirs if [ ! -d "/var/vmail/$domain" ] ; then - echo "install -o vmail -g vmail -m 750 -d /var/vmail/$domain" + install -o vmail -g vmail -m 750 -d /var/vmail/$domain fi if [ ! -d "/var/vmail/$domain/$mbox" ] ; then - echo "install -o vmail -g vmail -m 750 -d /var/vmail/$domain/$mbox" + install -o vmail -g vmail -m 750 -d /var/vmail/$domain/$mbox fi if [ ! -d "/var/vmail/$domain/$mbox/Maildir" ] ; then - echo "install -o vmail -g vmail -m 750 -d /var/vmail/$domain/$mbox/Maildir" + install -o vmail -g vmail -m 750 -d /var/vmail/$domain/$mbox/Maildir fi if [ ! -d "/var/vmail/$domain/$mbox/Maildir/cur" ] ; then - echo "install -o vmail -g vmail -m 750 -d /var/vmail/$domain/$mbox/Maildir/cur" + install -o vmail -g vmail -m 750 -d /var/vmail/$domain/$mbox/Maildir/cur fi diff --git a/bin/vmail-mboxes-del.sh b/bin/vmail-mboxes-del.sh index a273467..18f586d 100755 --- a/bin/vmail-mboxes-del.sh +++ b/bin/vmail-mboxes-del.sh @@ -72,19 +72,19 @@ if [ -z "$mboxes_id" ]; then elif [ "$mboxes_id" -gt '0' ]; then if [ -n "$force" ] || vmail::yesno "Delete $email now?"; then # this should be sufficient for vm_* tables due to ON DELETE CASCADE foreign key references - dbquery="DELETE FROM vm_mboxes WHERE vm_mboxes.id='$mboxes_id'" - echo $dbcmd $dbcmdopts "\"$dbquery\"" - dbquery="DELETE FROM sa_userpref WHERE username='$email'" - echo $dbcmd $dbcmdopts "\"$dbquery\"" - dbquery="DELETE FROM vm_greylisting WHERE recipient='$email'" - echo $dbcmd $dbcmdopts "\"$dbquery\"" - dbquery="DELETE FROM vm_greylisting WHERE recipient LIKE '$mbox+%@$domain'" - echo $dbcmd $dbcmdopts "\"$dbquery\"" + dbquery="DELETE FROM vm_mboxes WHERE vm_mboxes.id='$mboxes_id';" + eval $dbcmd $dbcmdopts "\"$dbquery\"" + dbquery="DELETE FROM sa_userpref WHERE username='$email';" + eval $dbcmd $dbcmdopts "\"$dbquery\"" + dbquery="DELETE FROM vm_greylisting WHERE recipient='$email';" + eval $dbcmd $dbcmdopts "\"$dbquery\"" + dbquery="DELETE FROM vm_greylisting WHERE recipient LIKE '$mbox+%@$domain';" + eval $dbcmd $dbcmdopts "\"$dbquery\"" # this should be sufficient for rc due to ON DELETE CASCADE foreign key references - dbquery="DELETE FROM rc_users WHERE username='$email'" - echo $dbcmd $dbcmdopts "\"$dbquery\"" + dbquery="DELETE FROM rc_users WHERE username='$email';" + eval $dbcmd $dbcmdopts "\"$dbquery\"" if [ -d "$VMAIL_DIR/$domain/$mbox" ]; then - echo "rm -r $VMAIL_DIR/$domain/$mbox" + rm -r $VMAIL_DIR/$domain/$mbox fi echo "SUCCESS: $email removed from system." exit 0