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