From 5ca71ae195dc63669d3c56b363f9bdad59953748 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Sat, 14 Aug 2021 13:33:58 -0700 Subject: [PATCH] added validate_domain checks --- bin/vhost-add.sh | 7 ++++++- bin/vhost-deploy.sh | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/vhost-add.sh b/bin/vhost-add.sh index 6fa21c4..beb5ce0 100644 --- a/bin/vhost-add.sh +++ b/bin/vhost-add.sh @@ -9,7 +9,12 @@ source $(dirname $0)/vhost.sh # check for and set virtualhost 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 echo "virtualhost not set" exit 1 diff --git a/bin/vhost-deploy.sh b/bin/vhost-deploy.sh index fc0ad95..55970ab 100644 --- a/bin/vhost-deploy.sh +++ b/bin/vhost-deploy.sh @@ -41,7 +41,13 @@ done if [ ! -n "$virtualhost" ]; then echo "virtualhost not set" 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" exit 1 fi