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-switchui
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 monitor
36 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
38 DAEMON=/usr/bin/ovs-switchui
39 NAME=openvswitch-switchui
40 DESC="Open vSwitch switch monitor"
42 PIDFILE=/var/run/$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 server
52 DODTIME=10 # Time to wait for the server to die, in seconds
53 # If this value is set too low you might not
54 # let some servers 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 -n "$EZIO3_DEVICE"; then
87 # Make ezio-term detach and create the pidfile.
88 WRAPPER="/usr/sbin/ezio-term"
89 WRAPPER_OPTS="--detach --pidfile=$PIDFILE --ezio=$EZIO3_DEVICE --input=vt"
91 # openvt will detach, so instead make ovs-switchui make the pidfile.
94 DAEMON_OPTS="--pidfile=$PIDFILE"
96 start-stop-daemon --start --quiet --pidfile $PIDFILE \
97 --exec $WRAPPER -- $WRAPPER_OPTS -- $DAEMON $DAEMON_OPTS \
98 --log-file $SWITCH_VCONN
100 # Wait up to 3 seconds for the daemon to start.
114 # Force the process to die killing it manually
115 [ ! -e "$PIDFILE" ] && return
124 echo "Cannot kill $NAME (pid=$pid)!"
135 log_daemon_msg "Starting $DESC " "$NAME"
136 # Check if it's running first
138 log_progress_msg "apparently already running"
142 if start_server && running ; then
143 # It's ok, the server started and is running
146 # Either we could not start it or it is not running
148 # NOTE: Some servers might die some time after they start,
149 # this code does not try to detect this and might give
150 # a false positive (use 'status' for that)
155 log_daemon_msg "Stopping $DESC" "$NAME"
157 # Only stop the server if we see it running
161 # If it's not running don't do anything
162 log_progress_msg "apparently not running"
168 # First try to stop gracefully the program
171 # If it's still running try to kill it more forcefully
172 log_daemon_msg "Stopping (force) $DESC" "$NAME"
177 restart|force-reload)
178 log_daemon_msg "Restarting $DESC" "$NAME"
180 # Wait some sensible amount, some server need this
181 [ -n "$DIETIME" ] && sleep $DIETIME
188 log_daemon_msg "Checking status of $DESC" "$NAME"
190 log_progress_msg "running"
193 log_progress_msg "apparently not running"
198 # Use this if the daemon cannot reload
200 log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
201 log_warning_msg "cannot re-read the config file (use restart)."
205 echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2