moved getopts up

This commit is contained in:
Matthew Saunders Brown 2021-02-11 14:09:07 -08:00
parent bef09f6e33
commit 319e8208ef

View File

@ -27,6 +27,27 @@ help()
exit
}
# set any options that were passed
while getopts "achs" opt; do
case "${opt}" in
a )
aliassearch=true
;;
c )
cvs="| sed 's/\t/,/g'"
;;
h )
help
exit;;
s )
dbcmdopts="-s -N $dbcmdopts"
;;
\? )
echo "Invalid option: $OPTARG" 1>&2
exit;;
esac
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"
@ -54,27 +75,6 @@ if [ -n "$1" ]; then
fi
fi
# set any options that were passed
while getopts "achs" opt; do
case "${opt}" in
a )
aliassearch=true
;;
c )
cvs="| sed 's/\t/,/g'"
;;
h )
help
exit;;
s )
dbcmdopts="-s -N $dbcmdopts"
;;
\? )
echo "Invalid option: $OPTARG" 1>&2
exit;;
esac
done
# build query
if [ -n "$domain" ]; then
# add specific domain