X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=debian%2Fopenvswitch-switch.init;h=60cc369f54a376bb541cff089ac6645c72e65e86;hb=34edeccfd8d4273844d12c85fe38ec47002c47cd;hp=871ac2d4fa9faa45f4307f75d04a3ea9c1b0bc25;hpb=f3c51ad9cc6cbd87ef726a4b33e39bb9d6d24769;p=openvswitch diff --git a/debian/openvswitch-switch.init b/debian/openvswitch-switch.init index 871ac2d4..60cc369f 100755 --- a/debian/openvswitch-switch.init +++ b/debian/openvswitch-switch.init @@ -29,7 +29,7 @@ DODTIME=1 # Time to wait for the server to die, in seconds # let some servers to die gracefully and # 'restart' will not work -# Include ovs-openflowd defaults if available +# Include openvswitch-switch defaults if available unset OVSDB_SERVER_OPTS unset OVS_VSWITCHD_OPTS unset CORE_LIMIT @@ -193,8 +193,29 @@ unload_modules() { unload_module openvswitch_mod } +set_system_info() { + ovs_version=`ovs-vswitchd --version | sed 's/.*) //;1q'` + ovs-vsctl --no-wait --timeout=5 set Open_vSwitch . \ + ovs-version="$ovs_version" + + if (lsb_release --id) >/dev/null 2>&1; then + system_type=`lsb_release --id -s` + system_release=`lsb_release --release -s` + system_codename=`lsb_release --codename -s` + system_version="${system_release}-${system_codename}" + + ovs-vsctl --no-wait --timeout=5 set Open_vSwitch . \ + system-type="$system_type" \ + system-version="$system_version" + fi +} + case "$1" in start) + conf_file=/etc/openvswitch/conf.db + schema_file=/usr/share/openvswitch/vswitch.ovsschema + schema_ver=`ovsdb-tool schema-version "$schema_file"` + load_module openvswitch_mod if test -n "$CORE_LIMIT"; then @@ -202,18 +223,18 @@ case "$1" in fi # Create an empty configuration database if it doesn't exist. - if test ! -e /etc/openvswitch/conf.db; then - install -d -m 755 -o root -g root /etc/openvswitch - + if test ! -e $conf_file; then # Create configuration database. - ovsdb-tool -vANY:console:emer \ - create /etc/openvswitch/conf.db \ - /usr/share/openvswitch/vswitch.ovsschema - elif ! running ovsdb-server; then + ovsdb-tool -vANY:console:emer create $conf_file $schema_file + else + # If schema version changed, then back up the old version. + old_ver=`ovsdb-tool db-version "$conf_file"` + if test "X$old_ver" != "X$schema_ver"; then + cp "$conf_file" "$conf_file.backup$old_ver" + fi + # Upgrade or downgrade schema and compact database. - ovsdb-tool -vANY:console:emer \ - convert /etc/openvswitch/conf.db \ - /usr/share/openvswitch/vswitch.ovsschema + ovsdb-tool -vANY:console:emer convert $conf_file $schema_file fi if test "$ENABLE_MONITOR" = y; then @@ -236,12 +257,13 @@ case "$1" in # Start ovsdb-server. set -- - set -- "$@" /etc/openvswitch/conf.db + set -- "$@" $conf_file set -- "$@" --verbose=ANY:console:emer --verbose=ANY:syslog:err set -- "$@" --log-file=/var/log/openvswitch/ovsdb-server.log set -- "$@" --detach --no-chdir --pidfile $monitor_opt set -- "$@" --remote punix:/var/run/openvswitch/db.sock set -- "$@" --remote db:Open_vSwitch,managers + set -- "$@" --remote db:Open_vSwitch,manager_options set -- "$@" --private-key=db:SSL,private_key set -- "$@" --certificate=db:SSL,certificate set -- "$@" --bootstrap-ca-cert=db:SSL,ca_cert @@ -257,7 +279,9 @@ case "$1" in echo " ERROR." fi - ovs-vsctl --no-wait --timeout=5 init + ovs-vsctl --no-wait --timeout=5 init -- set Open_vSwitch . db-version="$schema_ver" + + set_system_info # Start ovs-vswitchd. set -- @@ -329,7 +353,7 @@ case "$1" in if running $daemon; then echo "running" else - echo " not running." + echo "not running." exit 1 fi done