Created
August 5, 2010 02:14
-
-
Save lox/509114 to your computer and use it in GitHub Desktop.
Init.d script for scribed for Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# scribed Start and Stop the scribe daemon | |
# | |
### BEGIN INIT INFO | |
# Provides: scribed | |
# Required-Start: $local_fs $remote_fs $network $syslog | |
# Required-Stop: $local_fs $remote_fs $network $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start/Stop the scribed daemon | |
# Description: Start/Stop the scribed daemon. | |
### END INIT INFO | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
DAEMON=/usr/local/bin/scribed | |
NAME=scribed | |
DESC=scribed | |
PIDFILE=/var/run/$NAME.pid | |
USER=root | |
SCRIPTNAME=/etc/init.d/$NAME | |
# Exit if the package is not installed | |
[ -x "$DAEMON" ] || exit 0 | |
set -e | |
# Read configuration variable file if it is present | |
#[ -r /etc/default/$NAME ] && . /etc/default/$NAME | |
[ -r /etc/default/$NAME ] && . /etc/default/$NAME | |
# Load the VERBOSE setting and other rcS variables | |
. /lib/init/vars.sh | |
# | |
# Function that starts the daemon/service | |
# | |
do_start() | |
{ | |
if [ -e $PIDFILE ] | |
then | |
if [ -d /proc/`cat $PIDFILE`/ ] | |
then | |
echo "$NAME already running." | |
exit 0; | |
else | |
rm -f $PIDFILE | |
fi | |
fi | |
start-stop-daemon --start --quiet --exec $DAEMON --pidfile $PIDFILE -b -m --name $NAME --user $USER | |
} | |
# | |
# Function that stops the daemon/service | |
# | |
do_stop() | |
{ | |
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --name $NAME --user $USER | |
rm -f $PIDFILE | |
} | |
case "$1" in | |
start) | |
echo -n "Starting $DESC: " | |
do_start | |
echo "$NAME." | |
;; | |
stop) | |
echo -n "Stopping $DESC: " | |
do_stop | |
echo "$NAME." | |
;; | |
restart|force-reload) | |
# | |
# If the "reload" option is implemented, move the "force-reload" | |
# option to the "reload" entry above. If not, "force-reload" is | |
# just the same as "restart". | |
# | |
echo -n "Restarting $DESC: " | |
do_stop | |
sleep 1 | |
do_start | |
echo "$NAME." | |
;; | |
*) | |
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 | |
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 | |
exit 3 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing that!