use strict;
use warnings;
+# XXX should support configuring SWITCH_NETMASK and SWITCH_GATEWAY
+# when the mode is in-band.
+
my $debconf_owner = 'openflow-switch';
my $default = '/etc/default/openflow-switch';
# configured statically or dynamically:
#
# * For static configuration, specify the switch's IP address as a
-# string.
+# string. In this case you may also set SWITCH_NETMASK and
+# SWITCH_GATEWAY appropriately.
#
# * For dynamic configuration with DHCP (the most common case),
# specify "dhcp". Configuration with DHCP will only work reliably
#
# This setting has no effect unless MODE is set to 'in-band'.
SWITCH_IP=dhcp
+#SWITCH_NETMASK=255.255.255.0
+#SWITCH_GATEWAY=192.168.1.1
# CONTROLLER: Location of controller.
# One of the following formats:
if test "$SWITCH_IP" = dhcp; then
must_succeed "Temporarily disabling of0" ifconfig of0 down
else
- must_succeed "Configuring of0 as $SWITCH_IP" ifconfig of0 $SWITCH_IP
+ COMMAND="ifconfig of0 $SWITCH_IP"
+ if test -n "$SWITCH_NETMASK"; then
+ COMMAND="$COMMAND netmask $SWITCH_NETMASK"
+ fi
+ must_succeed "Configuring of0: $COMMAND" $COMMAND
+ if test -n "$SWITCH_GATEWAY"; then
+ # This can fail because the route already exists,
+ # so we don't insist that it succeed.
+ COMMAND="route add default gw $SWITCH_GATEWAY"
+ check_op "Adding default route: $COMMAND" $COMMAND
+ fi
fi
else
must_succeed "Disabling of0" ifconfig of0 down