X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=debian%2Fopenvswitch-switch.init;h=3a7f2924406dfeba0b887e909f53fb8cd18fe19b;hb=89521e3f79d53523fda9f284e74f0f7aa21332b4;hp=bf71e7df7f898b1960cbd7524dd7a6f2ec89a304;hpb=6c1b89ed0e6b9934d63ae4d71ba885bfcb87891a;p=openvswitch diff --git a/debian/openvswitch-switch.init b/debian/openvswitch-switch.init index bf71e7df..3a7f2924 100755 --- a/debian/openvswitch-switch.init +++ b/debian/openvswitch-switch.init @@ -33,11 +33,14 @@ DODTIME=1 # Time to wait for the server to die, in seconds unset OVSDB_SERVER_OPTS unset OVS_VSWITCHD_OPTS unset CORE_LIMIT +unset ENABLE_MONITOR default=/etc/default/openvswitch-switch if [ -f $default ] ; then - . $default + . $default fi +: ${ENABLE_MONITOR:=y} + set -e # running_pid pid name @@ -201,54 +204,70 @@ case "$1" in check_op "Setting core limit to $CORE_LIMIT" ulimit -c "$CORE_LIMIT" fi + # Create an empty configuration database if it doesn't exist. + if test ! -e /etc/openvswitch-switch/conf; then + # Create configuration database. + ovsdb-tool -vANY:console:emer \ + create /etc/openvswitch-switch/conf \ + /usr/share/openvswitch/vswitch.ovsschema + fi + + if test "$ENABLE_MONITOR" = y; then + monitor_opt=--monitor + else + monitor_opt= + fi + # Start ovsdb-server. set -- set -- "$@" --verbose=ANY:console:emer --verbose=ANY:syslog:err set -- "$@" --log-file - set -- "$@" --detach --pidfile - set -- "$@" --listen punix:/var/run/ovsdb-server + set -- "$@" --detach --pidfile $monitor_opt + set -- "$@" --remote punix:/var/run/ovsdb-server set -- "$@" /etc/openvswitch-switch/conf set -- "$@" $OVSDB_SERVER_OPTS - echo -n "Starting ovsdb-server: " - start-stop-daemon --start --quiet --pidfile /var/run/ovsdb-server.pid \ - --exec $ovsdb_server -- "$@" + echo -n "Starting ovsdb-server: " + start-stop-daemon --start --quiet --pidfile /var/run/ovsdb-server.pid \ + --exec $ovsdb_server -- "$@" if running ovsdb-server; then echo "ovsdb-server." else echo " ERROR." fi + ovs-vsctl --no-wait init + # Start ovs-vswitchd. set -- set -- "$@" --verbose=ANY:console:emer --verbose=ANY:syslog:err set -- "$@" --log-file - set -- "$@" --detach --pidfile + set -- "$@" --detach --pidfile $monitor_opt set -- "$@" unix:/var/run/ovsdb-server set -- "$@" $OVS_VSWITCHD_OPTS - echo -n "Starting ovs-vswitchd: " - start-stop-daemon --start --quiet --pidfile /var/run/ovs-vswitchd.pid \ - --exec $ovs_vswitchd -- "$@" + echo -n "Starting ovs-vswitchd: " + start-stop-daemon --start --quiet --pidfile /var/run/ovs-vswitchd.pid \ + --exec $ovs_vswitchd -- "$@" if running ovs-vswitchd; then echo "ovs-vswitchd." else echo " ERROR." fi - ;; + ;; stop) - echo -n "Stopping ovs-vswitchd: " - start-stop-daemon --stop --quiet --oknodo \ + echo -n "Stopping ovs-vswitchd: " + start-stop-daemon --stop --quiet --oknodo \ --pidfile /var/run/ovs-vswitchd.pid \ --exec $ovs_vswitchd - echo "ovs-vswitchd." + echo "ovs-vswitchd." - echo -n "Stopping ovsdb-server: " - start-stop-daemon --stop --quiet --oknodo \ + echo -n "Stopping ovsdb-server: " + start-stop-daemon --stop --quiet --oknodo \ --pidfile /var/run/ovsdb-server.pid \ --exec $ovsdb_server - echo "ovsdb-server." - ;; + echo "ovsdb-server." + ;; force-stop) - echo -n "Forcefully stopping ovs-vswitchd: " + echo -n "Forcefully stopping ovs-vswitchd: " force_stop ovs-vswitchd if ! running ovs-vswitchd; then echo "ovs-vswitchd." @@ -256,28 +275,28 @@ case "$1" in echo " ERROR." fi - echo -n "Forcefully stopping ovsdb-server: " + echo -n "Forcefully stopping ovsdb-server: " force_stop ovsdb-server if ! running ovsdb-server; then echo "ovsdb-server." else echo " ERROR." fi - ;; + ;; unload) - unload_modules - ;; + unload_modules + ;; reload) ;; force-reload) # Nothing to do, since ovs-vswitchd automatically reloads # whenever its configuration changes, and ovsdb-server doesn't # have anything to reload. - ;; + ;; restart) $0 stop || true $0 start - ;; + ;; status) for daemon in ovs-vswitchd ovsdb-server; do echo -n "$daemon is " @@ -290,10 +309,10 @@ case "$1" in done ;; *) - N=/etc/init.d/$NAME - echo "Usage: $N {start|stop|restart|force-reload|status|force-stop|unload}" >&2 - exit 1 - ;; + N=/etc/init.d/$NAME + echo "Usage: $N {start|stop|restart|force-reload|status|force-stop|unload}" >&2 + exit 1 + ;; esac exit 0