3 # Example init.d script with LSB support.
5 # Please read this init.d carefully and modify the sections to
6 # adjust it to the program you want to run.
8 # Copyright (c) 2007, 2009 Javier Fernandez-Sanguino <jfs@debian.org>
10 # This is free software; you may redistribute it and/or modify
11 # it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation; either version 2,
13 # or (at your option) any later version.
15 # This is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License with
21 # the Debian operating system, in /usr/share/common-licenses/GPL; if
22 # not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA 02111-1307 USA
26 # Provides: openvswitch-wdt
27 # Required-Start: $network $local_fs
29 # Should-Start: $named $syslog openvswitch-switch
31 # Default-Start: 2 3 4 5
33 # Short-Description: Open vSwitch switch watchdog
36 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
38 DAEMON=/usr/sbin/ovs-wdt
40 DESC="Open vSwitch watchdog"
42 PIDFILE=/var/run/openvswitch/$NAME.pid
44 test -x $DAEMON || exit 0
46 . /lib/lsb/init-functions
48 # Default options, these can be overriden by the information
49 # at /etc/default/$NAME
50 DAEMON_OPTS="" # Additional options given to the daemon
52 DODTIME=10 # Time to wait for the daemon to die, in seconds
53 # If this value is set too low you might not
54 # let some daemons to die gracefully and
55 # 'restart' will not work
57 # Include defaults if available
58 if [ -f /etc/default/$NAME ] ; then
65 # Check if a given process pid's cmdline matches a given name
68 [ -z "$pid" ] && return 1
69 [ ! -d /proc/$pid ] && return 1
74 # Check if the process is running looking at /proc
75 # (works for all users)
77 # No pidfile, probably no daemon present
78 [ ! -f "$PIDFILE" ] && return 1
80 running_pid $pid $DAEMON || return 1
85 # Start the process using the wrapper
86 if test $WDT_TIMEOUT != 0; then
87 start-stop-daemon --start --quiet -m --background --pidfile $PIDFILE \
88 --exec $DAEMON -- --timeout=$WDT_TIMEOUT --interval=$WDT_INTERVAL $DAEMON_OPTS
91 # Wait up to 3 seconds for the daemon to start.
99 echo $OOPS_REBOOT_TIME > /proc/sys/kernel/panic
100 echo 1 > /proc/sys/kernel/panic_on_oops
104 start-stop-daemon -o --stop --pidfile $PIDFILE
110 log_daemon_msg "Starting $DESC " "$NAME"
111 # Check if it's running first
113 log_progress_msg "apparently already running"
117 if start_daemon && running ; then
118 # It's ok, the daemon started and is running
121 # Either we could not start it or it is not running
123 # NOTE: Some daemons might die some time after they start,
124 # this code does not try to detect this and might give
125 # a false positive (use 'status' for that)
130 log_daemon_msg "Stopping $DESC" "$NAME"
132 # Only stop the daemon if we see it running
136 # If it's not running don't do anything
137 log_progress_msg "apparently not running"
142 restart|force-reload)
143 log_daemon_msg "Restarting $DESC" "$NAME"
146 # Wait some sensible amount, some daemons need this
147 [ -n "$DIETIME" ] && sleep $DIETIME
154 log_daemon_msg "Checking status of $DESC" "$NAME"
156 log_progress_msg "running"
159 log_progress_msg "apparently not running"
164 # Use this if the daemon cannot reload
166 log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
167 log_warning_msg "cannot re-read the config file (use restart)."
171 echo "Usage: $N {start|stop|restart|force-reload|status}" >&2