vmail-stack/bin/vmail-webmail-disable.sh
Matthew Saunders Brown 3774665792 enable getopts
2023-02-18 16:20:03 -08:00

40 lines
1007 B
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 "Disable webmail for given domain"
echo ""
echo "usage: $thisfilename -d <domain> [-h]"
echo ""
echo " -h Print this help."
echo " -d <domain> Domain to disable webmail for."
}
vmail:getoptions "$@"
# check for domain
if [[ -z $domain ]]; then
echo "ERROR: domain name is required"
exit 1
fi
# disable webmail vhost & restart apache
if [ -h "/etc/apache2/sites-enabled/mail.$domain.conf" ]; then
/usr/sbin/a2dissite --quiet mail.$domain
/usr/bin/systemctl --quiet reload apache2
fi
if [ -f "/etc/apache2/sites-available/mail.$domain.conf" ]; then
rm /etc/apache2/sites-available/mail.$domain.conf
fi