2021-04-04 13:28:22 -07:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# vhost-stack
|
|
|
|
# https://git.stack-source.com/msb/vhost-stack
|
|
|
|
# MIT License Copyright (c) 2021 Matthew Saunders Brown
|
|
|
|
|
2021-04-04 14:15:16 -07:00
|
|
|
# load include file
|
|
|
|
source $(dirname $0)/vhost.sh
|
2021-04-04 13:28:22 -07:00
|
|
|
|
|
|
|
# check for and set virtualhost
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
virtualhost=$1
|
|
|
|
else
|
|
|
|
echo "virtualhost not set"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# First check for virtualhost. Redundant
|
|
|
|
# as vhost-del.sh run later does this same check
|
|
|
|
# but prevents connecting to all nodes unnecessarily
|
|
|
|
if [ ! -d /srv/www/$virtualhost ]; then
|
|
|
|
echo "virtualhost dir does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check for userdel option and set username if enabled
|
|
|
|
if [ -n "$2" ] && [ $2 = "userdel" ]; then
|
|
|
|
username=$(stat -c '%U' /srv/www/$virtualhost)
|
|
|
|
fi
|
|
|
|
|
2021-08-14 13:04:46 -07:00
|
|
|
/usr/local/bin/vhost-del.sh $virtualhost
|
2021-04-04 13:28:22 -07:00
|
|
|
|
|
|
|
# check for userdel option
|
|
|
|
if [ -n "$2" ] && [ $2 = "userdel" ] && [ -n $username ]; then
|
2021-08-14 13:04:46 -07:00
|
|
|
/usr/local/bin/vhost-user-del.sh $username
|
2021-04-04 13:28:22 -07:00
|
|
|
fi
|