#!/bin/bash # # vmail-stack # https://git.stack-source.com/msb/vmail-stack # MIT License Copyright (c) 2021 Matthew Saunders Brown # load include file source $(dirname $0)/vmail.sh help() { thisfilename=$(basename -- "$0") echo "$thisfilename" echo "Return default vmail database info." echo "" echo "usage: $thisfilename [-c] [-h]" echo "" echo " -h Print this help." echo " -c Output in cvs format." echo echo " Returns defaults configured in the vm_domains table schema." exit } vmail:getoptions "$@" dbcmd="mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE" dbcmdopts="-s -N -e" # get "status" default dbquery="SELECT COLUMN_DEFAULT FROM information_schema.columns WHERE TABLE_SCHEMA = 'vmail' AND TABLE_NAME = 'vm_domains' AND COLUMN_NAME = 'status'" status=`eval $dbcmd $dbcmdopts "\"$dbquery\"" $cvs` # get "mbox_limit" default dbquery="SELECT COLUMN_DEFAULT FROM information_schema.columns WHERE TABLE_SCHEMA = 'vmail' AND TABLE_NAME = 'vm_domains' AND COLUMN_NAME = 'mbox_limit'" mbox_limit=`eval $dbcmd $dbcmdopts "\"$dbquery\"" $cvs` # get "mbox_quota_default" default dbquery="SELECT COLUMN_DEFAULT FROM information_schema.columns WHERE TABLE_SCHEMA = 'vmail' AND TABLE_NAME = 'vm_domains' AND COLUMN_NAME = 'mbox_quota_default'" mbox_quota_default=`eval $dbcmd $dbcmdopts "\"$dbquery\"" $cvs` # get "mbox_ratelimit_default" default dbquery="SELECT COLUMN_DEFAULT FROM information_schema.columns WHERE TABLE_SCHEMA = 'vmail' AND TABLE_NAME = 'vm_domains' AND COLUMN_NAME = 'mbox_ratelimit_default'" mbox_ratelimit_default=`eval $dbcmd $dbcmdopts "\"$dbquery\"" $cvs` # create newline var NL=$'\n' output="status mbox_limit mbox_quota_default mbox_ratelimit_default${NL}$status $mbox_limit $mbox_quota_default $mbox_ratelimit_default" if [[ $cvs ]]; then echo "$output" | tr " " "," else echo "$output" | column -t fi