Add SETUP conf var
[snf-network] / snf-network-masq-on
index 4c0864d..016f4d1 100755 (executable)
@@ -4,9 +4,27 @@ source /etc/default/snf-network
 
 source $CONF
 
-INFRA=$STATE_DIR/infra
+if [ ! -e $STATE_DIR/infra ]; then
+  echo No infra file found!
+  echo run: snf-network-build-node-infra
+  exit 1
+fi
+
+source $STATE_DIR/infra
+
+if [ $# -ne 3 ]; then
+  echo "Usage: $0 <masq bridge> <subnet> <gateway>"
+  exit 1
+fi
+
+#TODO include this in infra file
+MASQ_BRIDGE=$1
+SUBNET=$2
+GATEWAY=$3
+
 
 NETMASK=$(ipcalc $SUBNET | grep Netmask | awk '{print $4}')
-ip addr add $GATEWAY/$NETMASK dev $BRIDGE
+
+ip addr add $GATEWAY/$NETMASK dev $MASQ_BRIDGE
 iptables -t nat -A POSTROUTING -s $SUBNET \! -d $SUBNET -j MASQUERADE