onsdag 17 januari 2007

thttpd bug in init script

I use the wonderful little web server thttpd (see http://www.acme.com/software/thttpd/)
which is available in debian. When used around the clock, it fails to work properly because of a bug in the init script.

For reasons I do not know, the fix has yet not made it to etch, but it is really easy to fix manually: just download the init script proposed by Carlos Rodrigues and put it in /etc/init.d, replacing the old one. Make sure the rights, group and ownership are the same.

Unfortunately, some more modifications are required to get everything running with logrotate as well (which we want, don't we?:-)

So here is /etc/init.d:
#! /bin/sh
#
# Written by Carlos Rodrigues .
# modified by Paul Sundvall (www.paulsundvall.net)

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/sbin/thttpd
CONFFILE=/etc/thttpd/thttpd.conf
PIDFILE=/var/run/thttpd.pid
OPTIONS="-C $CONFFILE -i $PIDFILE"


test -x $DAEMON || exit 0
test -f $CONFFILE || exit 1

case "$1" in
start)
start-stop-daemon --start --verbose --pidfile $PIDFILE --exec $DAEMON -- $OPTIONS
;;
stop)
start-stop-daemon --stop --verbose --pidfile $PIDFILE --exec $DAEMON
rm -f $PIDFILE
;;
force-reload)
start-stop-daemon --stop --verbose --pidfile $PIDFILE --exec $DAEMON
rm -f $PIDFILE
sleep 1
start-stop-daemon --start --verbose --pidfile $PIDFILE --exec $DAEMON -- $OPTIONS
;;
restart)
start-stop-daemon --stop --verbose --pidfile $PIDFILE --exec $DAEMON
rm -f $PIDFILE
sleep 1
start-stop-daemon --start --verbose --pidfile $PIDFILE --exec $DAEMON --
$OPTIONS
;;
*)
echo "Usage: /etc/init.d/thttpd {start|stop|force-reload}"
exit 1
;;
esac

exit 0
...and here is the updated /etc/logrotate.d/thttpd:
/var/log/thttpd.log {
rotate 14
daily
compress
missingok
delaycompress
postrotate
if [ -f /var/run/thttpd.pid ]; then
/etc/init.d/thttpd restart > /dev/null 2>&1
fi
endscript
}
The original was from the debian thttpd package.

Inga kommentarer: