]> pd.if.org Git - startuptools/commitdiff
fix shell errors with IFS
authorNathan Wagner <nw@hydaspes.if.org>
Tue, 28 May 2013 05:40:03 +0000 (05:40 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Tue, 28 May 2013 05:40:03 +0000 (05:40 +0000)
scripts/ifdown
scripts/ifup
scripts/localhost.net [new file with mode: 0644]

index 784b1e28d4dbbeacf3459c099fa0096873bdcefc..fa92831c408d314ec04e8488a27a6dd026975dd8 100755 (executable)
@@ -2,10 +2,10 @@
 
 net=$1
 
+saveifs="$IFS"
 IFS=';'
 
-# TODO allow for /etc/sysconfig/$net also
-test -f /etc/sysconfig/$net.net || echo "unknown network configuration '$net'" >&2 && exit 1
+test -f /etc/networks/$net || (echo "unknown network configuration '$net'" >&2 && exit 1)
  
 ifdown_post() {
        return 0
@@ -15,20 +15,25 @@ ifdown_pre() {
        return 0
 }
 
-. /etc/sysconfig/$net.net
+. /etc/networks/$net
 
-#if [ $enable = 'no' || $enable -eq 0 ]; then; exit 0; fi
+if [ $enable = 'no' ]; then exit 0; fi
+#if [ $enable -eq 0 ]; then exit 0; fi
 
 ifdown_pre
 
 #ip link set dev $dev up
 
 for r in $route; do
+       IFS="$saveifs"
        ip route del $r
+       IFS=';'
 done
 
 for address in $addr do
+       IFS="$saveifs"
        ip addr del $address dev $dev
+       IFS=';'
 done
 
 # how do we determine if we should bring the link down?
index 98b5c59be30969454bf591edadc681e6f27420b6..d9f2df42814ae77bbdffa16adffd3ed47f6dda49 100755 (executable)
@@ -2,10 +2,10 @@
 
 net=$1
 
+saveifs="$IFS"
 IFS=';'
 
-# TODO allow for /etc/sysconfig/$net also
-test -f /etc/sysconfig/$net.net || echo "unknown network configuration '$net'" >&2 && exit 1
+test -f /etc/networks/$net || (echo "unknown network configuration '$net'" >&2 && exit 1)
  
 ifup_post() {
        return 0
@@ -15,20 +15,25 @@ ifup_pre() {
        return 0
 }
 
-. /etc/sysconfig/$net.net
+. /etc/networks/$net
 
-if [ $enable = 'no' || $enable -eq 0 ]; then; exit 0; fi
+if [ "$enable" = 'no' ]; then exit 0; fi
+#if [ "$enable" -eq 0 ]; then exit 0; fi
 
 ifup_pre
 
 ip link set dev $dev up
 
 for address in $addr do
+       IFS="$saveifs"
        ip addr add $address dev $dev
+       IFS=';'
 done
 
 for r in $route; do
+       IFS="$saveifs"
        ip route add $r
+       IFS=';'
 done
 
 ifup_post
diff --git a/scripts/localhost.net b/scripts/localhost.net
new file mode 100644 (file)
index 0000000..b295a28
--- /dev/null
@@ -0,0 +1,4 @@
+dev=lo
+#addr=127.0.0.1
+addr=
+route=