diff --git a/bin/vmail-aliases-add.sh b/bin/vmail-aliases-add.sh index 0739835..41097ac 100755 --- a/bin/vmail-aliases-add.sh +++ b/bin/vmail-aliases-add.sh @@ -49,14 +49,14 @@ fi # get mbox id, which also verfies that email address exists mbox_id=`mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE -s -r -N -e "SELECT id FROM vm_mboxes WHERE domain_id='$domain_id' AND mbox='$mbox';"` -if [ -z $mbox_id ] ; then +if [[ -z $mbox_id ]]; then # mbox does not exist, can't create alias echo "ERROR: Address to Alias To ($email) does not exist." exit 1 -elif [ "$mbox_id" -gt '1' ] ; then +elif [[ $mbox_id -gt 0 ]]; then # verified mbox, check for existing alias existing_alias=`mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE -s -r -N -e "SELECT vm_aliases.id FROM vm_aliases WHERE vm_aliases.alias='$alias' AND vm_aliases.mbox_id='$mbox_id';"` - if [ -z $existing_alias ]; then + if [[ -z $existing_alias ]]; then # existing alias does not exist, add new one now dbcmd="mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE -e 'INSERT INTO vm_aliases SET vm_aliases.alias=\"$alias\", vm_aliases.mbox_id=\"$mbox_id\";'" eval $dbcmd