--- lighttpd.initd-1.4.13-r1 2007-01-09 21:06:31 +0000 +++ /etc/init.d/lighttpd 2007-03-01 11:23:32 +0000 @@ -3,7 +3,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/www-servers/lighttpd/files/lighttpd.initd-1.4.13-r1,v 1.2 2007/01/09 20:56:24 robbat2 Exp $ -opts="depend checkconfig start stop reload graceful" +opts="reload graceful" depend() { need net @@ -13,7 +13,7 @@ } checkconfig() { - if [[ ! -f ${LIGHTTPD_CONF} ]] ; then + if [ ! -f "${LIGHTTPD_CONF}" ] ; then ewarn "${LIGHTTPD_CONF} does not exist." return 1 fi @@ -26,46 +26,43 @@ ebegin "Starting lighttpd" start-stop-daemon --start --quiet \ - --background --pidfile ${LIGHTTPD_PID} \ - --exec /usr/sbin/lighttpd -- -f ${LIGHTTPD_CONF} + --background --pidfile "${LIGHTTPD_PID}" \ + --exec /usr/sbin/lighttpd -- -f "${LIGHTTPD_CONF}" eend $? } stop() { local rv=0 ebegin "Stopping lighttpd" - if start-stop-daemon --stop --quiet --pidfile ${LIGHTTPD_PID} \ - --signal 2 ; then - rm -f ${LIGHTTPD_PID} - else - rv=1 - fi - eend $rv + start-stop-daemon --stop --quiet --pidfile "${LIGHTTPD_PID}" + eend $? } reload() { - if [ ! -f ${LIGHTTPD_PID} ]; then - eerror "lighttpd isn't running" + if ! service_started "${SVCNAME}" ; then + eerror "${SVCNAME} isn't running" return 1 fi checkconfig || return 1 + ebegin "Re-opening lighttpd log files" - kill -HUP $(<${LIGHTTPD_PID}) &>/dev/null + start-stop-daemon --stop --oknodo --quiet --pidfile "${LIGHTTPD_PID}" \ + --signal HUP eend $? } graceful() { - if ! service_started "${myservice}" ; then - eerror "Lighttpd is not running! Please start it before trying to reload it." - else - checkconfig || return 1 - ebegin "Gracefully stopping lighttpd" - ## s-s-d for consistency or kill because it's cleaner? - ## s-s-d causes a 5 second delay here - #start-stop-daemon --stop --quiet --pidfile ${LIGHTTPD_PID} \ - # --signal SIGINT - kill -INT $(<${LIGHTTPD_PID}) - rm -f ${LIGHTTPD_PID} + if ! service_started "${SVCNAME}" ; then + eerror "${SVCNAME} isn't running" + return 1 + fi + checkconfig || return 1 + + ebegin "Gracefully stopping lighttpd" + start-stop-daemon --stop --oknodo --quiet --pidfile "${LIGHTTPD_PID}" \ + --signal INT + if eend $? ; then + rm -f "${LIGHTTPD_PID}" start fi }