Use "start-stop-daemon --status" for debian init.d
@@ -30,7 +30,10 @@ get_pid() {
}
is_running() {
- [ -f "$pidfile" ] && ps -p `get_pid` > /dev/null 2>&1
+ start-stop-daemon --status \
+ --pidfile $pidfile \
+ --name $name \
+ --user $user
}
case "$1" in
@@ -58,7 +61,12 @@ case "$1" in
--make-pidfile \
-- -c "exec $cmd >> $logfile 2>&1"
- if [ $? -eq 0 ]; then
+ for i in 0 1 2 3 4 5 6 7 8 9; do
+ is_running && break
+ sleep 1
+ done
+
+ if is_running; then
echo "Started. Logs will go to $logfile"
exit 0
else
