Checking in changes prior to tagging of version 2.73.
[MogileFS-Server.git] / debian / mogilefsd.init
blobb17a70e0985af0a96ba5bd1cfbdd7a448ea8d1f0
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides: mogilefsd
4 # Required-Start: $local_fs $remote_fs $network $syslog
5 # Required-Stop: $local_fs $remote_fs $network $syslog
6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 1 6
8 # Short-Description: Start/Stop the mogilefsd daemon
9 # Description: Start/Stop the mogilefsd daemon.
10 ### END INIT INFO
12 # PATH should only include /usr/* if it runs after the mountnfs.sh script
13 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
14 DAEMON=/usr/bin/mogilefsd
15 NAME=mogilefsd
16 DESC=mogilefsd
17 DEFAULTS=/etc/default/$NAME
18 PIDDIR=/var/run/$NAME
19 PIDFILE=$PIDDIR/$NAME.pid
20 SCRIPTNAME=/etc/init.d/$NAME
22 # Exit if the package is not installed
23 [ -x "$DAEMON" ] || exit 0
25 # Read configuration variable file if it is present
26 if [ -r $DEFAULTS ] ; then
28 . $DEFAULTS
30 if [ -z "$MOGILEFSD_RUNASUSER" ]; then
31 echo "Cannot determine user to run as, even though defaults file ($DEFAULTS) exists."
32 echo "Please run dpkg-reconfigure $NAME to correct the problem."
33 exit 0
35 else
36 echo "Can't start $NAME. Defaults file ($DEFAULTS) doesn't exist."
37 echo "Please run dpkg-reconfigure $NAME to correct the problem."
38 exit 0
41 # Load the VERBOSE setting and other rcS variables
42 . /lib/init/vars.sh
44 set -e
47 # Function that starts the daemon/service
49 do_start()
52 if ! test -d ${PIDDIR}
53 then
54 mkdir ${PIDDIR}
55 chown ${MOGILEFSD_RUNASUSER} ${PIDDIR}
58 if [ -e $PIDFILE ]
59 then
61 if [ -d /proc/`cat $PIDFILE`/ ]
62 then
64 echo "$NAME already running."
65 exit 0;
66 else
67 rm -f $PIDFILE
72 start-stop-daemon --start --quiet --exec $DAEMON -b --name $NAME --chuid $MOGILEFSD_RUNASUSER -- $MOGILEFSD_EXTRA_OPTS
76 # Function that stops the daemon/service
78 do_stop()
80 start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --name $NAME --user $MOGILEFSD_RUNASUSER
81 rm -f $PIDFILE
84 case "$1" in
85 start)
86 echo -n "Starting $DESC: "
87 do_start
88 echo "$NAME."
90 stop)
91 echo -n "Stopping $DESC: "
92 do_stop
93 echo "$NAME."
96 restart|force-reload)
98 # If the "reload" option is implemented, move the "force-reload"
99 # option to the "reload" entry above. If not, "force-reload" is
100 # just the same as "restart".
102 echo -n "Restarting $DESC: "
103 do_stop
104 sleep 1
105 do_start
106 echo "$NAME."
109 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
110 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
111 exit 3
113 esac