-p option

This commit is contained in:
Matthew Saunders Brown 2021-09-04 15:42:13 -07:00
parent 6a025b52b8
commit 0d4f7a31ef

View File

@ -18,6 +18,7 @@ help()
echo " -c Output in cvs format." echo " -c Output in cvs format."
echo " -h Print this help." echo " -h Print this help."
echo " -s Be more silent - use tabs instead of tables for output, do not display column headers." echo " -s Be more silent - use tabs instead of tables for output, do not display column headers."
echo " -p Include encrypt password in output."
echo " -w Wildcard search when searching for username." echo " -w Wildcard search when searching for username."
echo "" echo ""
echo " Search term is optional. If nothing specified all email acccounts for all domains will be returned." echo " Search term is optional. If nothing specified all email acccounts for all domains will be returned."
@ -32,7 +33,6 @@ help()
dbcmd="mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE" dbcmd="mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE"
dbcmdopts="-e" dbcmdopts="-e"
dbquery="SELECT vm_mboxes.mbox, vm_domains.domain, vm_mboxes.status, vm_mboxes.quota FROM vm_domains, vm_mboxes WHERE vm_domains.id=vm_mboxes.domain_id"
# check for and set email search term(s) # check for and set email search term(s)
if [ -n "$1" ]; then if [ -n "$1" ]; then
@ -53,7 +53,7 @@ if [ -n "$1" ]; then
fi fi
# set any options that were passed # set any options that were passed
while getopts "chsw" opt; do while getopts "chspw" opt; do
case "${opt}" in case "${opt}" in
c ) c )
cvs="| sed 's/\t/,/g'" cvs="| sed 's/\t/,/g'"
@ -64,6 +64,9 @@ while getopts "chsw" opt; do
s ) s )
dbcmdopts="-s -N $dbcmdopts" dbcmdopts="-s -N $dbcmdopts"
;; ;;
p )
includepassword=true
;;
w ) w )
wildcardsearch=true wildcardsearch=true
;; ;;
@ -74,6 +77,11 @@ while getopts "chsw" opt; do
done done
# build query # build query
dbquery="SELECT vm_mboxes.mbox, vm_domains.domain"
if [ -n "$includepassword" ]; then
dbquery="$dbquery, vm_mboxes.passwd"
fi
dbquery="$dbquery, vm_mboxes.status, vm_mboxes.quota FROM vm_domains, vm_mboxes WHERE vm_domains.id=vm_mboxes.domain_id"
if [ -n "$mbox" ] && [ -n "$domain" ]; then if [ -n "$mbox" ] && [ -n "$domain" ]; then
# search for specific email address # search for specific email address
dbquery="$dbquery AND vm_domains.domain='$domain' AND vm_mboxes.mbox='$mbox'" dbquery="$dbquery AND vm_domains.domain='$domain' AND vm_mboxes.mbox='$mbox'"