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-monitor
27 # Required-Start: $network $local_fs $remote_fs
28 # Required-Stop: $remote_fs
29 # Should-Start: $named $syslog openvswitch-switch
31 # Default-Start: 2 3 4 5
33 # Short-Description: Open vSwitch switch monitor
36 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
38 DAEMON=/usr/sbin/ovs-monitor
40 DESC="Open vSwitch switch monitor"
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 $THRESHOLD != 0; then
87 start-stop-daemon --start --quiet -m --background --pidfile $PIDFILE \
88 --exec $DAEMON -- -c $THRESHOLD -i $INTERVAL -l $LOG_FILE \
89 -s $SWITCH_VCONN $DAEMON_OPTS
92 # Wait up to 3 seconds for the daemon to start.
102 start-stop-daemon -o --stop --pidfile $PIDFILE
108 log_daemon_msg "Starting $DESC " "$NAME"
109 # Check if it's running first
111 log_progress_msg "apparently already running"
115 if start_daemon && running ; then
116 # It's ok, the daemon started and is running
119 # Either we could not start it or it is not running
121 # NOTE: Some daemons might die some time after they start,
122 # this code does not try to detect this and might give
123 # a false positive (use 'status' for that)
128 log_daemon_msg "Stopping $DESC" "$NAME"
130 # Only stop the daemon if we see it running
134 # If it's not running don't do anything
135 log_progress_msg "apparently not running"
140 restart|force-reload)
141 log_daemon_msg "Restarting $DESC" "$NAME"
144 # Wait some sensible amount, some daemons need this
145 [ -n "$DIETIME" ] && sleep $DIETIME
152 log_daemon_msg "Checking status of $DESC" "$NAME"
154 log_progress_msg "running"
157 log_progress_msg "apparently not running"
162 # Use this if the daemon cannot reload
164 log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
165 log_warning_msg "cannot re-read the config file (use restart)."
169 echo "Usage: $N {start|stop|restart|force-reload|status}" >&2