vmail-stack/etc/vmail.conf

65 lines
1.2 KiB
Plaintext
Raw Normal View History

2021-02-10 16:16:23 -08:00
# vmail configs
2021-03-01 12:04:51 -08:00
# any script that includes this conf file will force user to be vmail
if [ "$USER" != "vmail" ]; then
exec su --shell /bin/bash "vmail" "$0" -- "$@"
fi
2021-02-10 16:16:23 -08:00
# constants
readonly MYSQL_CONNECTION_INFO_FILE=/usr/local/etc/vmail-db-info.conf
readonly VMAIL_DIR=/var/vmail
readonly VMAIL_DB=vmail
# functions
# crude but good enough domain name format validation
function vmail::validate_domain () {
local my_domain=$1
if [[ $my_domain =~ ^(([a-zA-Z](-?[a-zA-Z0-9])*)\.)+[a-zA-Z]{2,}$ ]] ; then
return 0
else
return 1
fi
}
# yesno prompt
#
# Examples:
# loop until y or n: if vmail::yesno "Continue?"; then
# default y: if vmail::yesno "Continue?" Y; then
# default n: if vmail::yesno "Continue?" N; then
function vmail::yesno() {
local prompt default reply
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
prompt="y/N"
default=N
else
prompt="y/n"
default=
fi
while true; do
read -p "$1 [$prompt] " -n 1 -r reply
# Default?
if [ -z "$reply" ]; then
reply=$default
fi
# Check if the reply is valid
case "$reply" in
Y*|y*) return 0 ;;
N*|n*) return 1 ;;
esac
done
2021-03-01 12:04:51 -08:00
}