Create .acl file first
[vsys.git] / factory / setup-link
index be8c949..1eedfab 100755 (executable)
@@ -37,6 +37,8 @@ iptables -t mangle -A FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
 
 ### Create "grab link" script
 GRAB=/vsys/grab-$ETUN0
+echo $SLICE > $GRAB.acl 
+rm -f $GRAB
 cat > $GRAB <<EOF
 #!/bin/sh
 
@@ -45,13 +47,16 @@ read PID
 chcontext --ctx 1 -- echo \$PID > /sys/class/net/$ETUN0/new_ns_pid 
 EOF
 chmod +x $GRAB
-echo $SLICE > $GRAB.acl 
 
 ### Create "delete link" script
 DELETE=/vsys/delete-$ETUN0
+echo $SLICE > $DELETE.acl 
+rm -f $DELETE
 cat > $DELETE <<EOF
 #!/bin/sh
 
+read NULL
+
 # Remove iptables rule
 iptables -t mangle -D FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
 
@@ -66,11 +71,10 @@ brctl delbr $BRIDGE
 ip tunnel del $EGRE
 
 # Clean up files
-rm $GRAB
-rm $DELETE
+rm -f $GRAB $GRAB.acl
+rm -f $DELETE $DELETE.acl
 
 EOF
 chmod +x $DELETE
-echo $SLICE > $DELETE.acl