From: Nathan Wagner Date: Tue, 28 May 2013 05:40:03 +0000 (+0000) Subject: fix shell errors with IFS X-Git-Url: https://pd.if.org/git/?p=startuptools;a=commitdiff_plain;h=4fe655b1905363af2df163a5ee9ab89ca7790c49 fix shell errors with IFS --- diff --git a/scripts/ifdown b/scripts/ifdown index 784b1e2..fa92831 100755 --- a/scripts/ifdown +++ b/scripts/ifdown @@ -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? diff --git a/scripts/ifup b/scripts/ifup index 98b5c59..d9f2df4 100755 --- a/scripts/ifup +++ b/scripts/ifup @@ -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 index 0000000..b295a28 --- /dev/null +++ b/scripts/localhost.net @@ -0,0 +1,4 @@ +dev=lo +#addr=127.0.0.1 +addr= +route=