moved getopts up
This commit is contained in:
parent
bb87bf83f1
commit
198afdfd63
|
@ -21,33 +21,6 @@ help()
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
dbcmd="mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE"
|
|
||||||
dbcmdopts="-e"
|
|
||||||
dbquery="SELECT vm_aliases.alias, vm_mboxes.mbox, vm_domains.domain FROM vm_aliases, vm_mboxes, vm_domains WHERE vm_aliases.mbox_id = vm_mboxes.id AND vm_mboxes.domain_id = vm_domains.id"
|
|
||||||
|
|
||||||
# check for and set alias search term(s)
|
|
||||||
if [ -n "$1" ]; then
|
|
||||||
if [ $1 == "-h" ]; then
|
|
||||||
help
|
|
||||||
elif [[ ! $1 =~ ^- ]] ; then
|
|
||||||
searchterm=$1
|
|
||||||
shift
|
|
||||||
if [[ $searchterm =~ "@" ]] ; then
|
|
||||||
alias=${searchterm%@*}
|
|
||||||
domain=${searchterm##*@}
|
|
||||||
if ! vmail::validate_domain $domain; then
|
|
||||||
echo "ERROR: $searchterm is not a valid email address."
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
elif vmail::validate_domain $searchterm; then
|
|
||||||
domain=$searchterm
|
|
||||||
else
|
|
||||||
echo "ERROR: $searchterm is not a valid search term."
|
|
||||||
help
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# set any options that were passed
|
# set any options that were passed
|
||||||
while getopts "achs" opt; do
|
while getopts "achs" opt; do
|
||||||
case "${opt}" in
|
case "${opt}" in
|
||||||
|
@ -69,6 +42,35 @@ while getopts "achs" opt; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
dbcmd="mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE"
|
||||||
|
dbcmdopts="-e"
|
||||||
|
dbquery="SELECT vm_aliases.alias, vm_mboxes.mbox, vm_domains.domain FROM vm_aliases, vm_mboxes, vm_domains WHERE vm_aliases.mbox_id = vm_mboxes.id AND vm_mboxes.domain_id = vm_domains.id"
|
||||||
|
|
||||||
|
# check for and set alias search term(s)
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
if [ $1 == "-h" ]; then
|
||||||
|
help
|
||||||
|
elif [[ ! $1 =~ ^- ]] ; then
|
||||||
|
searchterm=$1
|
||||||
|
shift
|
||||||
|
if [[ $searchterm =~ "@" ]] ; then
|
||||||
|
alias=${searchterm%@*}
|
||||||
|
domain=${searchterm##*@}
|
||||||
|
if ! vmail::validate_domain $domain; then
|
||||||
|
echo "ERROR: $searchterm is not a valid email address."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
elif vmail::validate_domain $searchterm; then
|
||||||
|
domain=$searchterm
|
||||||
|
else
|
||||||
|
echo "ERROR: $searchterm is not a valid search term."
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# build query
|
# build query
|
||||||
if [ -n "$domain" ]; then
|
if [ -n "$domain" ]; then
|
||||||
# add specific domain
|
# add specific domain
|
||||||
|
|
Loading…
Reference in New Issue
Block a user