mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 23:08:07 +00:00
lighttpd: do not overwrite /etc/lighttpd/lighttpd.conf
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
This commit is contained in:
parent
0d5d3a1b22
commit
c6342ed84c
@ -65,11 +65,5 @@ $HTTP["host"] == "pi.hole" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# (safe to enable after pihole ceases to support Debian 10 (Buster))
|
# (keep this on one line for basic-install.sh filtering during install)
|
||||||
# (For lighttpd 1.4.56+ which ignores duplicated server.modules entries)
|
server.modules += ( "mod_access", "mod_redirect", "mod_fastcgi", "mod_setenv" )
|
||||||
#server.modules += (
|
|
||||||
# "mod_access",
|
|
||||||
# "mod_redirect",
|
|
||||||
# "mod_fastcgi",
|
|
||||||
# "mod_setenv",
|
|
||||||
#)
|
|
||||||
|
@ -1401,35 +1401,13 @@ installConfigs() {
|
|||||||
|
|
||||||
# If the user chose to install the dashboard,
|
# If the user chose to install the dashboard,
|
||||||
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
|
if [[ "${INSTALL_WEB_SERVER}" == true ]]; then
|
||||||
# and if the Web server conf directory does not exist,
|
if grep -q -F "FILE AUTOMATICALLY OVERWRITTEN BY PI-HOLE" "${lighttpdConfig}"; then
|
||||||
if [[ ! -d "/etc/lighttpd" ]]; then
|
# Attempt to preserve backwards compatibility with older versions
|
||||||
# make it and set the owners
|
|
||||||
install -d -m 755 -o "${USER}" -g root /etc/lighttpd
|
|
||||||
# Otherwise, if the config file already exists
|
|
||||||
elif [[ -f "${lighttpdConfig}" ]]; then
|
|
||||||
# back up the original
|
|
||||||
mv "${lighttpdConfig}"{,.orig}
|
|
||||||
fi
|
|
||||||
# and copy in the config file Pi-hole needs
|
|
||||||
install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/advanced/${LIGHTTPD_CFG} "${lighttpdConfig}"
|
install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/advanced/${LIGHTTPD_CFG} "${lighttpdConfig}"
|
||||||
# If there is a custom block page in the html/pihole directory, replace 404 handler in lighttpd config
|
# If there is a custom block page in the html/pihole directory, replace 404 handler in lighttpd config
|
||||||
if [[ -f "${PI_HOLE_404_DIR}/custom.php" ]]; then
|
if [[ -f "${PI_HOLE_404_DIR}/custom.php" ]]; then
|
||||||
sed -i 's/^\(server\.error-handler-404\s*=\s*\).*$/\1"\/pihole\/custom\.php"/' "${lighttpdConfig}"
|
sed -i 's/^\(server\.error-handler-404\s*=\s*\).*$/\1"\/pihole\/custom\.php"/' "${lighttpdConfig}"
|
||||||
fi
|
fi
|
||||||
# Copy the config file to include for pihole admin interface
|
|
||||||
if [[ -d "/etc/lighttpd/conf.d" ]]; then
|
|
||||||
install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/advanced/pihole-admin.conf /etc/lighttpd/conf.d/pihole-admin.conf
|
|
||||||
elif [[ -d "/etc/lighttpd/conf-available" ]]; then
|
|
||||||
conf=/etc/lighttpd/conf-available/15-pihole-admin.conf
|
|
||||||
install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/advanced/pihole-admin.conf $conf
|
|
||||||
if is_command lighty-enable-mod ; then
|
|
||||||
lighty-enable-mod pihole-admin > /dev/null || true
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# lighttpd config include dir not found
|
|
||||||
printf " %b Warning: lighttpd config include dir not found\\n" "${INFO}"
|
|
||||||
printf " Please manually install pihole-admin.conf\\n"
|
|
||||||
fi
|
|
||||||
# Make the directories if they do not exist and set the owners
|
# Make the directories if they do not exist and set the owners
|
||||||
mkdir -p /run/lighttpd
|
mkdir -p /run/lighttpd
|
||||||
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /run/lighttpd
|
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /run/lighttpd
|
||||||
@ -1438,6 +1416,49 @@ installConfigs() {
|
|||||||
mkdir -p /var/cache/lighttpd/uploads
|
mkdir -p /var/cache/lighttpd/uploads
|
||||||
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/uploads
|
chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/uploads
|
||||||
fi
|
fi
|
||||||
|
# Copy the config file to include for pihole admin interface
|
||||||
|
if [[ -d "/etc/lighttpd/conf.d" ]]; then
|
||||||
|
install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/advanced/pihole-admin.conf /etc/lighttpd/conf.d/pihole-admin.conf
|
||||||
|
if grep -q -F 'include "/etc/lighttpd/conf.d/pihole-admin.conf"' "${lighttpdConfig}"; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo 'include "/etc/lighttpd/conf.d/pihole-admin.conf"' >> "${lighttpdConfig}"
|
||||||
|
fi
|
||||||
|
# Avoid some warnings trace from lighttpd, which might break tests
|
||||||
|
conf=/etc/lighttpd/conf.d/pihole-admin.conf
|
||||||
|
if lighttpd -f "${lighttpdConfig}" -tt 2>&1 | grep -q -F "WARNING: unknown config-key: dir-listing\."; then
|
||||||
|
echo '# Avoid some warnings trace from lighttpd, which might break tests' >> $conf
|
||||||
|
echo 'server.modules += ( "mod_dirlisting" )' >> $conf
|
||||||
|
fi
|
||||||
|
if lighttpd -f "${lighttpdConfig}" -tt 2>&1 | grep -q -F "warning: please use server.use-ipv6"; then
|
||||||
|
echo '# Avoid some warnings trace from lighttpd, which might break tests' >> $conf
|
||||||
|
echo 'server.use-ipv6 := "disable"' >> $conf
|
||||||
|
fi
|
||||||
|
elif [[ -d "/etc/lighttpd/conf-available" ]]; then
|
||||||
|
conf=/etc/lighttpd/conf-available/15-pihole-admin.conf
|
||||||
|
install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/advanced/pihole-admin.conf $conf
|
||||||
|
# disable server.modules += ( ... ) in $conf to avoid module dups
|
||||||
|
# (needed until Debian 10 no longer supported by pi-hole)
|
||||||
|
# (server.modules duplication is ignored in lighttpd 1.4.56+)
|
||||||
|
if awk '!/^server\.modules/{print}' $conf > $conf.$$ && mv $conf.$$ $conf; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
rm $conf.$$
|
||||||
|
fi
|
||||||
|
chmod 644 $conf
|
||||||
|
if is_command lighty-enable-mod ; then
|
||||||
|
lighty-enable-mod pihole-admin access redirect fastcgi setenv > /dev/null || true
|
||||||
|
else
|
||||||
|
# Otherwise, show info about installing them
|
||||||
|
printf " %b Warning: 'lighty-enable-mod' utility not found\\n" "${INFO}"
|
||||||
|
printf " Please ensure fastcgi is enabled if you experience issues\\n"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# lighttpd config include dir not found
|
||||||
|
printf " %b Warning: lighttpd config include dir not found\\n" "${INFO}"
|
||||||
|
printf " Please manually install pihole-admin.conf\\n"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
install_manpage() {
|
install_manpage() {
|
||||||
@ -1913,15 +1934,6 @@ installPihole() {
|
|||||||
# Give lighttpd access to the pihole group so the web interface can
|
# Give lighttpd access to the pihole group so the web interface can
|
||||||
# manage the gravity.db database
|
# manage the gravity.db database
|
||||||
usermod -a -G pihole ${LIGHTTPD_USER}
|
usermod -a -G pihole ${LIGHTTPD_USER}
|
||||||
# If the lighttpd command is executable,
|
|
||||||
if is_command lighty-enable-mod ; then
|
|
||||||
# enable fastcgi and fastcgi-php
|
|
||||||
lighty-enable-mod fastcgi fastcgi-php > /dev/null || true
|
|
||||||
else
|
|
||||||
# Otherwise, show info about installing them
|
|
||||||
printf " %b Warning: 'lighty-enable-mod' utility not found\\n" "${INFO}"
|
|
||||||
printf " Please ensure fastcgi is enabled if you experience issues\\n"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Install base files and web interface
|
# Install base files and web interface
|
||||||
|
@ -131,6 +131,7 @@ removeNoPurge() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if package_check lighttpd > /dev/null; then
|
if package_check lighttpd > /dev/null; then
|
||||||
|
# Attempt to preserve backwards compatibility with older versions
|
||||||
if [[ -f /etc/lighttpd/lighttpd.conf.orig ]]; then
|
if [[ -f /etc/lighttpd/lighttpd.conf.orig ]]; then
|
||||||
${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
|
${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
|
||||||
fi
|
fi
|
||||||
@ -142,6 +143,16 @@ removeNoPurge() {
|
|||||||
# Fedora-based
|
# Fedora-based
|
||||||
if [[ -f /etc/lighttpd/conf.d/pihole-admin.conf ]]; then
|
if [[ -f /etc/lighttpd/conf.d/pihole-admin.conf ]]; then
|
||||||
${SUDO} rm /etc/lighttpd/conf.d/pihole-admin.conf
|
${SUDO} rm /etc/lighttpd/conf.d/pihole-admin.conf
|
||||||
|
conf=/etc/lighttpd/lighttpd.conf
|
||||||
|
tconf=/tmp/lighttpd.conf.$$
|
||||||
|
if awk '!/^include "\/etc\/lighttpd\/conf\.d\/pihole-admin\.conf"$/{print}' \
|
||||||
|
$conf > $tconf && mv $tconf $conf; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
rm $tconf
|
||||||
|
fi
|
||||||
|
${SUDO} chown root:root $conf
|
||||||
|
${SUDO} chmod 644 $conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Debian-based
|
# Debian-based
|
||||||
|
@ -416,7 +416,7 @@ def test_installPihole_fresh_install_readableBlockpage(host, test_webpage):
|
|||||||
usergroup="${{LIGHTTPD_USER}}:${{LIGHTTPD_GROUP}}",
|
usergroup="${{LIGHTTPD_USER}}:${{LIGHTTPD_GROUP}}",
|
||||||
chmodarg="{{}}",
|
chmodarg="{{}}",
|
||||||
config="/etc/lighttpd/lighttpd.conf",
|
config="/etc/lighttpd/lighttpd.conf",
|
||||||
run="/var/run/lighttpd",
|
run="/run/lighttpd",
|
||||||
cache="/var/cache/lighttpd",
|
cache="/var/cache/lighttpd",
|
||||||
uploads="/var/cache/lighttpd/uploads",
|
uploads="/var/cache/lighttpd/uploads",
|
||||||
compress="/var/cache/lighttpd/compress",
|
compress="/var/cache/lighttpd/compress",
|
||||||
|
Loading…
Reference in New Issue
Block a user