vmail-stack/bin/vmail-webmail-disable.sh

30 lines
797 B
Bash
Raw Normal View History

2021-02-10 16:16:23 -08: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)
2021-02-10 16:16:23 -08:00
2021-03-19 11:59:41 -07:00
# must be root to disable apache config
if [ "$USER" != "root" ]; then
exec su "$0" -- "$@"
fi
2021-02-10 16:16:23 -08:00
# check for and set virtualhost
if [ -n "$1" ]; then
virtualhost=$1
else
echo "virtualhost not set"
exit 1
fi
2021-03-19 11:59:41 -07:00
# disable webmail vhost & restart apache
2021-02-10 16:16:23 -08:00
if [ -h "/etc/apache2/sites-enabled/mail.$virtualhost.conf" ]; then
/usr/sbin/a2dissite --quiet mail.$virtualhost
/usr/bin/systemctl --quiet reload apache2
fi
2021-03-19 11:59:41 -07:00
2021-02-10 16:16:23 -08:00
if [ -f "/etc/apache2/sites-available/mail.$virtualhost.conf" ]; then
rm /etc/apache2/sites-available/mail.$virtualhost.conf
fi