File rc.curvedns of Package curvedns
#!/bin/sh
#
# (C) 2011 Peter Conrad <conrad@quisquis.de>
#
# This file is licensed under the terms of the
# GNU General Public License Version 2. A copy of these terms should be
# enclosed as "COPYING" in the package containing this file.
#
# init.d/curvedns
#
### BEGIN INIT INFO
# Provides: curvedns
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Default-Start: 2 3 5
# Default-Stop: 0 1 4 6
# Short-Description: Start curvedns proxy
# Description: Start curvedns proxy
### END INIT INFO
. /etc/rc.status
rc_reset
CONFIGFILE=
PIDFILE=
SERVICEDIR=
[ -r "$CONFIGFILE" ] && . "$CONFIGFILE"
PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH
running() {
if [ ! -r "$PIDFILE" ]; then
return 1
fi
read pid <"$PIDFILE"
if [ -z "$pid" ]; then
return 1
fi
if [ ! -r "/proc/$pid/cmdline" ]; then
return 1
fi
grep -q curvedns "/proc/$pid/cmdline"
}
case "$1" in
start)
if running; then
:
else
echo -n "Starting curvedns..."
(( "$SERVICEDIR"/run &
echo $! >"$PIDFILE" ) | \
"$SERVICEDIR"/log/run ) &
sleep 1
$0 status
rc_status -v
fi
;;
stop)
if running; then
echo -n "Shutting down curvedns..."
kill "`cat "$PIDFILE"`"
fi
rc_status -v
;;
restart)
"$0" stop && "$0" start
;;
condrestart|try-restart|reload|force-reload)
if running; then
"$0" restart
fi
;;
reload)
:
;;
status)
if running; then
exit 0
fi
if [ -r "$PIDFILE" ]; then
exit 1
fi
exit 2
;;
*)
echo "Usage: $0 {start|stop|restart|condrestart|try-restart|force-reload|status}"
exit 1
esac
exit 0