diff --git a/bin/vmail-mboxes-get.sh b/bin/vmail-mboxes-get.sh index e64898b..41f8c44 100755 --- a/bin/vmail-mboxes-get.sh +++ b/bin/vmail-mboxes-get.sh @@ -18,6 +18,7 @@ help() echo " -c Output in cvs format." echo " -h Print this help." 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 "" 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" 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) if [ -n "$1" ]; then @@ -53,7 +53,7 @@ if [ -n "$1" ]; then fi # set any options that were passed -while getopts "chsw" opt; do +while getopts "chspw" opt; do case "${opt}" in c ) cvs="| sed 's/\t/,/g'" @@ -64,6 +64,9 @@ while getopts "chsw" opt; do s ) dbcmdopts="-s -N $dbcmdopts" ;; + p ) + includepassword=true + ;; w ) wildcardsearch=true ;; @@ -74,6 +77,11 @@ while getopts "chsw" opt; do done # 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 # search for specific email address dbquery="$dbquery AND vm_domains.domain='$domain' AND vm_mboxes.mbox='$mbox'"