added validate_domain checks

This commit is contained in:
Matthew Saunders Brown 2021-08-14 13:33:58 -07:00
parent 5280467700
commit 5ca71ae195
2 changed files with 13 additions and 2 deletions

View File

@ -9,7 +9,12 @@ source $(dirname $0)/vhost.sh
# check for and set virtualhost # check for and set virtualhost
if [ -n "$1" ]; then if [ -n "$1" ]; then
virtualhost=$1 if vhost::validate_domain $1; then
virtualhost=$1
else
echo "ERROR: $1 is not a valid domain name."
exit 1
fi
else else
echo "virtualhost not set" echo "virtualhost not set"
exit 1 exit 1

View File

@ -41,7 +41,13 @@ done
if [ ! -n "$virtualhost" ]; then if [ ! -n "$virtualhost" ]; then
echo "virtualhost not set" echo "virtualhost not set"
exit 1 exit 1
elif [ -d /srv/www/$virtualhost ] || [ -f /etc/apache2/sites-available/$virtualhost.conf ]; then
if ! vhost::validate_domain $virtualhost; then
echo "ERROR: $virtualhost is not a valid domain name."
exit 1
fi
if [ -d /srv/www/$virtualhost ] || [ -f /etc/apache2/sites-available/$virtualhost.conf ]; then
echo "virtualhost for $virtualhost already installed" echo "virtualhost for $virtualhost already installed"
exit 1 exit 1
fi fi