56 lines
2.0 KiB
Bash
Executable File
56 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# vmail-stack
|
|
# https://git.stack-source.com/msb/vmail-stack
|
|
# Copyright (c) 2022 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# 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
|