Debian Codegraph @

debian/init

raw
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides: cubemap
4 # Required-Start: $remote_fs $syslog
5 # Required-Stop: $remote_fs $syslog
6 # Default-Start: 2 3 4 5
7 # Default-Stop: 0 1 6
8 # Short-Description: Cubemap stream relay
9 # Description: Cubemap is a scalable video reflector, designed
10 # to be used with VLC
11 ### END INIT INFO
12
13 # Do NOT "set -e"
14
15 # PATH should only include /usr/* if it runs after the mountnfs.sh script
16 PATH=/sbin:/usr/sbin:/bin:/usr/bin
17 DESC="Cubemap stream relay"
18 NAME=cubemap
19 DAEMON=/usr/bin/$NAME
20 DAEMON_ARGS="/etc/cubemap.config"
21 PIDFILE=/var/run/$NAME.pid
22 SCRIPTNAME=/etc/init.d/$NAME
23
24 # Exit if the package is not installed
25 [ -x "$DAEMON" ] || exit 0
26
27 # Read configuration variable file if it is present
28 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
29
30 # Load the VERBOSE setting and other rcS variables
31 . /lib/init/vars.sh
32
33 # Define LSB log_* functions.
34 # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
35 # and status_of_proc is working.
36 . /lib/lsb/init-functions
37
38 #
39 # Function that starts the daemon/service
40 #
41 do_start()
42 {
43 # Return
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 \
48 || return 1
49 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
50 $DAEMON_ARGS \
51 || return 2
52 # Add code here, if necessary, that waits for the process to be ready
53 # to handle requests from services started subsequently which depend
54 # on this one. As a last resort, sleep for some time.
55 }
56
57 #
58 # Function that stops the daemon/service
59 #
60 do_stop()
61 {
62 # Return
63 # 0 if daemon has been stopped
64 # 1 if daemon was already stopped
65 # 2 if daemon could not be stopped
66 # other if a failure occurred
67 start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
68 RETVAL="$?"
69 [ "$RETVAL" = 2 ] && return 2
70 # Wait for children to finish too if this is a daemon that forks
71 # and if the daemon is only ever run from this initscript.
72 # If the above conditions are not satisfied then add some other code
73 # that waits for the process to drop all resources that could be
74 # needed by services started subsequently. A last resort is to
75 # sleep for some time.
76 start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
77 [ "$?" = 2 ] && return 2
78 # Many daemons don't delete their pidfiles when they exit.
79 rm -f $PIDFILE
80 return "$RETVAL"
81 }
82
83 #
84 # Function that sends a SIGHUP to the daemon/service
85 #
86 do_reload() {
87 start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
88 return 0
89 }
90
91 case "$1" in
92 start)
93 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
94 do_start
95 case "$?" in
96 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
97 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
98 esac
99 ;;
100 stop)
101 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
102 do_stop
103 case "$?" in
104 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
105 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
106 esac
107 ;;
108 status)
109 status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
110 ;;
111 reload|force-reload)
112 log_daemon_msg "Reloading $DESC" "$NAME"
113 do_reload
114 log_end_msg $?
115 ;;
116 restart)
117 log_daemon_msg "Restarting $DESC" "$NAME"
118 do_stop
119 case "$?" in
120 0|1)
121 do_start
122 case "$?" in
123 0) log_end_msg 0 ;;
124 1) log_end_msg 1 ;; # Old process is still running
125 *) log_end_msg 1 ;; # Failed to start
126 esac
127 ;;
128 *)
129 # Failed to stop
130 log_end_msg 1
131 ;;
132 esac
133 ;;
134 *)
135 echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
136 exit 3
137 ;;
138 esac
139
140 :