debian: Move ofp-switch-setup and manpage into correct package.
[sliver-openvswitch.git] / debian / openflow-switch.init
index 323c7f8..fa17d2b 100755 (executable)
@@ -45,6 +45,8 @@ unset CACERT_MODE
 unset MGMT_VCONNS
 unset COMMANDS
 unset DAEMON_OPTS
+unset CORE_LIMIT
+unset DATAPATH_ID
 default=/etc/default/openflow-switch
 if [ -f $default ] ; then
        . $default
@@ -95,7 +97,7 @@ force_stop() {
             kill -9 $pid
             [ -n "$DODTIME" ] && sleep "$DODTIME"s
             if running ; then
-                echo "Cannot kill $LABEL (pid=$pid)!"
+                echo "Cannot kill $NAME (pid=$pid)!"
                 exit 1
             fi
         fi
@@ -221,6 +223,20 @@ case "$1" in
             must_succeed "Adding $netdev to datapath" dpctl addif nl:0 $netdev
         done
 
+        xx='[0-9abcdefABCDEF][0-9abcdefABCDEF]'
+        case $DATAPATH_ID in
+            '')
+                ;;
+            $xx:$xx:$xx:$xx:$xx:$xx)
+                ifconfig of0 down
+                must_succeed "Setting of0 MAC address to $DATAPATH_ID" ifconfig of0 hw ether $DATAPATH_ID
+                ifconfig of0 up
+                ;;
+            *)
+                echo "DATAPATH_ID is not a valid MAC address in the form XX:XX:XX:XX:XX:XX, ignoring" >&2
+                ;;
+        esac
+
         if test "$MODE" = in-band; then
             if test "$SWITCH_IP" = dhcp; then
                 must_succeed "Temporarily disabling of0" ifconfig of0 down
@@ -246,6 +262,11 @@ case "$1" in
             MGMT_OPTS="$MGMT_OPTS --listen=$vconn"
         done
 
+        MONITOR_OPT=
+        if test -n "$MONITOR_VCONN"; then
+            MONITOR_OPT="--monitor=$MONITOR_VCONN"
+        fi
+
         COMMAND_OPT=
         if test -n "$COMMANDS"; then
             COMMAND_OPT="--command-acl=$COMMANDS"
@@ -255,11 +276,15 @@ case "$1" in
             DAEMON_OPTS="$DAEMON_OPTS --out-of-band"
         fi
 
+        if test -n "$CORE_LIMIT"; then
+            check_op "Setting core limit to $CORE_LIMIT" ulimit -c "$CORE_LIMIT"
+        fi
+
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --pidfile $PIDFILE \
            --exec $DAEMON -- nl:0 $CONTROLLER --detach --pidfile=$PIDFILE \
             --verbose=ANY:console:emer --verbose=ANY:syslog:err --log-file \
-            $DAEMON_OPTS $MGMT_OPTS $SSL_OPTS "$COMMAND_OPT"
+            $DAEMON_OPTS $MGMT_OPTS $MONITOR_OPT $SSL_OPTS "$COMMAND_OPT"
         if running; then
             echo "$NAME."
         else
@@ -294,6 +319,7 @@ case "$1" in
             check_op "Removing $netdev from datapath" dpctl delif nl:0 $netdev
         done
         check_op "Deleting datapath" dpctl deldp nl:0
+        check_op "Unloading kernel module" modprobe -r openflow_mod
        ;;
     force-stop)
        echo -n "Forcefully stopping $DESC: "
@@ -317,7 +343,7 @@ case "$1" in
         $0 start
        ;;
     status)
-        echo -n "$LABEL is "
+        echo -n "$NAME is "
         if running ;  then
             echo "running"
         else