HEX
Server: Apache/2.4.63 (Unix)
System: Linux TOMS-220NAS 4.4.302+ #86009 SMP Wed Nov 26 18:19:17 CST 2025 x86_64
User: flavio87 (1026)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: /volume1/@appstore/WebStation/tools/fix_apache_alias.sh
#!/bin/bash

if [ -z "$1" ] || [ -z "$2" ]; then
    echo "Usage: $0 alias service_id"
    exit -1
fi

alias=$1
service_id=$2

apache_conf=("/usr/local/etc/apache24/conf-enabled/" "/usr/local/etc/apache24/conf-available/")
readarray -t unique < <(comm -23 <(grep -HRl 'Alias "/'${alias}'"' "${apache_conf[@]}" | sort) <(grep -HRl ${service_id} "${apache_conf[@]}" | sort ))

apache_temp="/usr/local/etc/apache24/conf-conflict"
success=0
if [ ${#unique[@]} -gt 0 ]; then
    mkdir -p $apache_temp
    for i in "${unique[@]}"
    do
        if [ -L "$i" ]; then
            rm $i
        else
            mv $i $apache_temp
        fi
        success=1
    done
fi
exit $success