Fix problems with web-add.sh add-alias

All uses of the VHOST_PATH variable in the code append a slash to
it, so it is easier to remove the trailing slash in it's instantiation.

Also simplifies the sed(1) invocation.
This commit is contained in:
Patrick Marchand 2018-11-22 16:28:24 +01:00
parent a06f31e80a
commit d64cfa4e8b

View file

@ -26,7 +26,7 @@ SSH_GROUP="evolinux-ssh"
# Set to nginx if you use nginx and not apache
WEB_SERVER="apache"
if [ "$WEB_SERVER" == "apache" ]; then
VHOST_PATH="/etc/apache2/sites-available/"
VHOST_PATH="/etc/apache2/sites-available"
TPL_VHOST="$SCRIPTS_PATH/vhost"
TPL_MAIL="$SCRIPTS_PATH/web-mail.tpl"
@ -767,7 +767,7 @@ op_aliasadd() {
vhost="${1}.conf"
alias=$2
[ -f $VHOST_PATH/"$vhost" ] && sed -i -e "s/\\(ServerName .*\\)/\\1\\n\\tServerAlias $alias/" "$VHOST_PATH"/"$vhost" --follow-symlinks
[ -f $VHOST_PATH/"$vhost" ] && sed -i "/ServerName .*/a \\\tServerAlias $alias" "$VHOST_PATH"/"$vhost" --follow-symlinks
apache2ctl configtest 2>/dev/null
/etc/init.d/apache2 force-reload >/dev/null