2022-05-23 08:53:20 -07:00
#!/bin/bash
#
# vmail-stack
# https://git.stack-source.com/msb/vmail-stack
2022-08-22 13:34:20 -07:00
# 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)
2022-05-23 08:53:20 -07:00
# 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."
2023-11-27 09:13:59 -08:00
echo " -c Output in csv format."
2022-05-23 08:53:20 -07:00
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'"
2023-11-27 09:13:59 -08:00
status = ` eval $dbcmd $dbcmdopts " \" $dbquery \" " $csv `
2022-05-23 08:53:20 -07:00
# 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'"
2023-11-27 09:13:59 -08:00
mbox_limit = ` eval $dbcmd $dbcmdopts " \" $dbquery \" " $csv `
2022-05-23 08:53:20 -07:00
# 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'"
2023-11-27 09:13:59 -08:00
mbox_quota_default = ` eval $dbcmd $dbcmdopts " \" $dbquery \" " $csv `
2022-05-23 08:53:20 -07:00
# 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'"
2023-11-27 09:13:59 -08:00
mbox_ratelimit_default = ` eval $dbcmd $dbcmdopts " \" $dbquery \" " $csv `
2022-05-23 08:53:20 -07:00
# 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 "
2023-11-27 09:13:59 -08:00
if [ [ $csv ] ] ; then
2022-05-23 08:53:20 -07:00
echo " $output " | tr " " ","
else
echo " $output " | column -t
fi