update add-alias to link it to specified domain

This commit is contained in:
Nicolas Roman 2019-04-02 11:34:55 +02:00
parent cd6abd008d
commit d739a4838e

View file

@ -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