From d739a4838e24fea2047d39682801322050540e9a Mon Sep 17 00:00:00 2001 From: Nicolas Roman Date: Tue, 2 Apr 2019 11:34:55 +0200 Subject: [PATCH] update add-alias to link it to specified domain --- scripts/web-add.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/web-add.sh b/scripts/web-add.sh index dc0528f..9c63351 100755 --- a/scripts/web-add.sh +++ b/scripts/web-add.sh @@ -114,9 +114,10 @@ check-vhosts -f List suggested changes to vhosts, apply fixes with -f -add-alias VHOST ALIAS +add-alias VHOST ALIAS DOMAIN Add a ServerAlias to an Apache vhost + If DOMAIN is not specified, apply to the whole file del-alias VHOST ALIAS @@ -820,11 +821,12 @@ op_listvhost() { } op_aliasadd() { - if [ $# -eq 2 ]; then + if [ $# -ge 2 ] && [ $# -le 3 ]; then vhost="${1}.conf" alias=$2 + domain=${3:-''} - [ -f $VHOST_PATH/"$vhost" ] && sed -i "/ServerName .*/a \\\tServerAlias $alias" "$VHOST_PATH"/"$vhost" --follow-symlinks + [ -f $VHOST_PATH/"$vhost" ] && sed -i "/ServerName $domain/a \\\tServerAlias $alias" "$VHOST_PATH"/"$vhost" --follow-symlinks apache2ctl configtest 2>/dev/null /etc/init.d/apache2 force-reload >/dev/null