aboutsummaryrefslogtreecommitdiff
path: root/network/lighttpd/rc.lighttpd
diff options
context:
space:
mode:
Diffstat (limited to 'network/lighttpd/rc.lighttpd')
-rw-r--r--network/lighttpd/rc.lighttpd17
1 files changed, 11 insertions, 6 deletions
diff --git a/network/lighttpd/rc.lighttpd b/network/lighttpd/rc.lighttpd
index cb180c3e88ee4..2f31a40e69ce7 100644
--- a/network/lighttpd/rc.lighttpd
+++ b/network/lighttpd/rc.lighttpd
@@ -1,6 +1,5 @@
#!/bin/sh
# Copyright (c) 2007, Daniel de Kok <moc.mikciat@leinad>
-# Modified by Martin Lefebvre <dadexter@sekurity.com>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@@ -25,11 +24,15 @@ LIGHTTPD=/usr/sbin/lighttpd
PIDFILE=/var/run/lighttpd.pid
LIGHTTPD_OPTIONS="-f /etc/lighttpd/lighttpd.conf"
+is_pidof() {
+ local STATE=$(ps -p $1 -o cmd= | grep "$2" > /dev/null ; echo $?)
+ return $STATE
+}
+
lighttpd_start() {
echo "Starting lighttpd: $LIGHTTPD"
- if [ -r $PIDFILE ]; then
- echo "Already running or stale PID file"
- echo "If it's not running, remove $PIDFILE"
+ if [ -r $PIDFILE ] && is_pidof $(cat $PIDFILE) lighttpd ; then
+ echo "Already running!"
return
fi
$LIGHTTPD $LIGHTTPD_OPTIONS
@@ -37,9 +40,11 @@ lighttpd_start() {
lighttpd_stop() {
echo "Stopping lighttpd: $LIGHTTPD"
- if [ -r $PIDFILE ]; then
- kill -3 `cat $PIDFILE`
+ if [ -r $PIDFILE ] && is_pidof $(cat $PIDFILE) lighttpd ; then
+ kill $(cat $PIDFILE)
rm -f $PIDFILE
+ else
+ echo "Not running!"
fi
}