]> pd.if.org Git - startuptools/blobdiff - scripts/ifup
fix test in ifup
[startuptools] / scripts / ifup
index 98b5c59be30969454bf591edadc681e6f27420b6..200d431c83f03bb5a1f54382f37196db8f8eb9a8 100755 (executable)
@@ -1,11 +1,13 @@
 #!/bin/sh
 
+set -e
+
 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 +17,32 @@ 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
 
+# need to check to make sure the link exists
+ip link show dev $dev >/dev/null 2>&1 || exit 1
+
 ip link set dev $dev up
 
-for address in $addr do
-       ip addr add $address dev $dev
-done
+if [ "$addr" = 'dhcp' ]; then
+       /sbin/dhcpcd -q $dev
+else
+       for address in $addr; do
+               IFS="$saveifs"
+               ip addr add $address dev $dev
+               IFS=';'
+       done
+fi
 
 for r in $route; do
+       IFS="$saveifs"
        ip route add $r
+       IFS=';'
 done
 
 ifup_post