2022-07-12 16:18:33 +02:00
|
|
|
#!/command/with-contenv bash
|
2017-05-06 04:48:03 +02:00
|
|
|
|
|
|
|
s6-echo "Starting lighttpd"
|
2022-01-26 19:29:14 +01:00
|
|
|
|
2022-01-26 09:04:32 +01:00
|
|
|
if [[ 1 -eq ${WEBLOGS_STDOUT:-0} ]]; then
|
|
|
|
#lighthttpd cannot use /dev/stdout https://redmine.lighttpd.net/issues/2731
|
2022-06-12 18:56:47 +02:00
|
|
|
for fi in /var/log/lighttpd/access-pihole.log /var/log/lighttpd/error-pihole.log
|
2022-01-28 08:12:40 +01:00
|
|
|
do
|
|
|
|
if [[ ! -p ${fi} ]]; then
|
|
|
|
rm -f ${fi}
|
|
|
|
mkfifo -m 600 ${fi}
|
|
|
|
fi
|
|
|
|
done
|
2022-01-26 09:04:32 +01:00
|
|
|
chown -R www-data:www-data /var/log/lighttpd
|
|
|
|
service lighttpd-access-log start
|
|
|
|
service lighttpd-error-log start
|
|
|
|
sleep 2
|
|
|
|
else
|
2022-01-28 08:12:40 +01:00
|
|
|
#remove fifo if exists
|
2022-06-12 14:37:39 +02:00
|
|
|
[[ -p /var/log/lighttpd/access-pihole.log ]] && rm -Rf /var/log/lighttpd/access-pihole.log
|
|
|
|
[[ -p /var/log/lighttpd/error-pihole.log ]] && rm -Rf /var/log/lighttpd/error-pihole.log
|
2022-03-31 20:00:47 +02:00
|
|
|
|
2022-04-01 20:45:16 +02:00
|
|
|
# install /dev/null log files to ensure they exist (create if non-existing, preserve if existing)
|
2022-06-12 14:37:39 +02:00
|
|
|
[[ ! -f /var/log/lighttpd/access-pihole.log ]] && install /dev/null /var/log/lighttpd/access-pihole.log
|
|
|
|
[[ ! -f /var/log/lighttpd/error-pihole.log ]] && install /dev/null /var/log/lighttpd/error-pihole.log
|
2022-01-26 19:29:14 +01:00
|
|
|
|
2022-01-26 09:04:32 +01:00
|
|
|
# Ensure that permissions are set so that lighttpd can write to the logs
|
|
|
|
chown -R www-data:www-data /var/log/lighttpd
|
2022-06-12 14:37:39 +02:00
|
|
|
chmod 0644 /var/log/lighttpd/access-pihole.log /var/log/lighttpd/error-pihole.log
|
2022-01-26 09:04:32 +01:00
|
|
|
fi
|
2022-01-26 19:29:14 +01:00
|
|
|
|
2017-05-06 04:48:03 +02:00
|
|
|
lighttpd -D -f /etc/lighttpd/lighttpd.conf
|