4 # Required-Start: $local_fs $remote_fs
5 # Required-Stop: $local_fs $remote_fs
6 # Default-Start: 2 3 4 5
7 # Default-Stop: S 0 1 6
8 # Short-Description: Stargazer initscript
9 # Description: This file should be used to start and stop stargazer daemon
12 # Author: Boris Mikhailenko <stg34@stg.dp.ua>
16 # PATH should only include /usr/* if it runs after the mountnfs.sh script
17 PATH=/usr/sbin:/usr/bin:/sbin:/bin
20 DAEMON=/usr/sbin/$NAME
22 PIDFILE=/var/run/$NAME.pid
23 SCRIPTNAME=/etc/init.d/$NAME
25 # Exit if the package is not installed
26 [ -x "$DAEMON" ] || exit 0
28 # Read configuration variable file if it is present
29 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
31 # Load the VERBOSE setting and other rcS variables
32 [ -f /etc/default/rcS ] && . /etc/default/rcS
34 # Define LSB log_* functions.
35 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
36 . /lib/lsb/init-functions
39 # Function that starts the daemon/service
44 # 0 if daemon has been started
45 # 1 if daemon was already running
46 # 2 if daemon could not be started
47 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
50 # ps x | grep $DAEMON | grep -v grep | cut -f1 -d" " > $PIDFILE
52 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
56 # ps x | grep $DAEMON | grep -v grep | cut -f1 -d" " > $PIDFILE
57 # Add code here, if necessary, that waits for the process to be ready
58 # to handle requests from services started subsequently which depend
59 # on this one. As a last resort, sleep for some time.
63 # Function that stops the daemon/service
68 # 0 if daemon has been stopped
69 # 1 if daemon was already stopped
70 # 2 if daemon could not be stopped
71 # other if a failure occurred
72 start-stop-daemon --stop --quiet --retry=INT/60/KILL/5 --pidfile $PIDFILE --name $NAME
74 [ "$RETVAL" = 2 ] && return 2
75 # Wait for children to finish too if this is a daemon that forks
76 # and if the daemon is only ever run from this initscript.
77 # If the above conditions are not satisfied then add some other code
78 # that waits for the process to drop all resources that could be
79 # needed by services started subsequently. A last resort is to
80 # sleep for some time.
81 start-stop-daemon --stop --quiet --oknodo --retry=0/60/KILL/5 --exec $DAEMON
82 [ "$?" = 2 ] && return 2
83 # Many daemons don't delete their pidfiles when they exit.
89 # Function that sends a SIGHUP to the daemon/service
92 # If the daemon can reload its configuration without
93 # restarting (for example, when it is sent a SIGHUP),
94 # then implement that here.
95 start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
101 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
104 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
105 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
109 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
112 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
113 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
117 # If do_reload() is not implemented then leave this commented out
118 # and leave 'force-reload' as an alias for 'restart'.
119 log_daemon_msg "Reloading $DESC" "$NAME"
125 # If the "reload" option is implemented then remove the
126 # 'force-reload' alias
128 log_daemon_msg "Restarting $DESC" "$NAME"
135 1) log_end_msg 1 ;; # Old process is still running
136 *) log_end_msg 1 ;; # Failed to start
146 #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
147 echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2