1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Unlink existing 50-raspap-router in conf-enabled

This commit is contained in:
billz 2021-04-01 16:46:07 +01:00
parent 98bd74372f
commit 41cb105b2a

View File

@ -25,6 +25,7 @@ readonly raspap_wlan0="/etc/dnsmasq.d/090_wlan0.conf"
readonly raspap_adblock="/etc/dnsmasq.d/090_adblock.conf" readonly raspap_adblock="/etc/dnsmasq.d/090_adblock.conf"
readonly raspap_sysctl="/etc/sysctl.d/90_raspap.conf" readonly raspap_sysctl="/etc/sysctl.d/90_raspap.conf"
readonly raspap_network="$raspap_dir/networking/" readonly raspap_network="$raspap_dir/networking/"
readonly raspap_router="/etc/lighttpd/conf-available/50-raspap-router.conf"
readonly rulesv4="/etc/iptables/rules.v4" readonly rulesv4="/etc/iptables/rules.v4"
readonly notracking_url="https://raw.githubusercontent.com/notracking/hosts-blocklists/master/" readonly notracking_url="https://raw.githubusercontent.com/notracking/hosts-blocklists/master/"
webroot_dir="/var/www/html" webroot_dir="/var/www/html"
@ -220,20 +221,25 @@ function _install_lighttpd_configs() {
CONFSRC="$webroot_dir/config/50-raspap-router.conf" CONFSRC="$webroot_dir/config/50-raspap-router.conf"
LTROOT=$(grep "server.document-root" /etc/lighttpd/lighttpd.conf | awk -F '=' '{print $2}' | tr -d " \"") LTROOT=$(grep "server.document-root" /etc/lighttpd/lighttpd.conf | awk -F '=' '{print $2}' | tr -d " \"")
# compare values and get difference # Compare values and get difference
HTROOT=${webroot_dir/$LTROOT} HTROOT=${webroot_dir/$LTROOT}
# remove trailing slash if present # Remove trailing slash if present
HTROOT=$(echo "$HTROOT" | sed -e 's/\/$//') HTROOT=$(echo "$HTROOT" | sed -e 's/\/$//')
# substitute values # Substitute values
awk "{gsub(\"/REPLACE_ME\",\"$HTROOT\")}1" $CONFSRC > /tmp/50-raspap-router.conf awk "{gsub(\"/REPLACE_ME\",\"$HTROOT\")}1" $CONFSRC > /tmp/50-raspap-router.conf
# copy into place # Copy into place
sudo cp /tmp/50-raspap-router.conf /etc/lighttpd/conf-available/ || _install_status 1 "Unable to copy lighttpd config file into place." sudo cp /tmp/50-raspap-router.conf /etc/lighttpd/conf-available/ || _install_status 1 "Unable to copy lighttpd config file into place."
# link into conf-enabled # Link into conf-enabled
echo "Creating link to /etc/lighttpd/conf-enabled" echo "Creating link to /etc/lighttpd/conf-enabled"
if ! [ -L $raspap_router ]; then
echo "Existing 50-raspap-router.conf found. Unlinking."
sudo unlink "/etc/lighttpd/conf-enabled/50-raspap-router.conf"
fi
echo "Linking 50-raspap-router.conf to /etc/lighttpd/conf-enabled/"
sudo ln -s "/etc/lighttpd/conf-available/50-raspap-router.conf" "/etc/lighttpd/conf-enabled/50-raspap-router.conf" || _install_status 1 "Unable to symlink lighttpd config file (this is normal if the link already exists)." sudo ln -s "/etc/lighttpd/conf-available/50-raspap-router.conf" "/etc/lighttpd/conf-enabled/50-raspap-router.conf" || _install_status 1 "Unable to symlink lighttpd config file (this is normal if the link already exists)."
sudo systemctl restart lighttpd.service || _install_status 1 "Unable to restart lighttpd" sudo systemctl restart lighttpd.service || _install_status 1 "Unable to restart lighttpd"
_install_status 0 _install_status 0