diff options
author | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-11-05 15:28:18 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-11-05 16:11:47 +0100 |
commit | 021fa432447bd7b447ca39738040698db39d751b (patch) | |
tree | 66c0e46dfd952ce6de6043916f3eb9e2d92e62e2 /scripts/ifcfg.sh.in |
Initial commitv1
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'scripts/ifcfg.sh.in')
-rwxr-xr-x | scripts/ifcfg.sh.in | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/scripts/ifcfg.sh.in b/scripts/ifcfg.sh.in new file mode 100755 index 0000000..f8396c6 --- /dev/null +++ b/scripts/ifcfg.sh.in @@ -0,0 +1,71 @@ +#!/bin/sh +CFGPATH="@ETCPATH@/netcfg" + +[ -d "$CFGPATH" ] || exit 0 + +# configure interfaces +for IFPATH in /sys/class/net/*; do + [ "$IFPATH" == "/sys/class/net/lo" ] && continue + + IF=`basename $IFPATH` + CFGFILE="$CFGPATH/$IF" + + [ -f "$CFGFILE" ] || continue + + ip link set dev "$IF" down + + while read LINE; + do + trimmed=`echo -- $LINE` + [ ! -z "$trimmed" ] || continue + set $trimmed + + case "$1" in + address|addr|ip|ip6|ipv6) + shift + ip address add $@ dev "$IF" + ;; + arp|multicast|mtu) + ip link set dev "$IF" $@ + ;; + offload) + shift + ethtool -K "$IF" $@ + ;; + *) + ;; + esac + done < "$CFGFILE" +done + +# configure static routs +if [ -f "$CFGPATH/routes" ]; then + while read LINE; + do + trimmed=`echo -- $LINE` + [ ! -z "$trimmed" ] || continue + set $trimmed + + case "$1" in + route) + shift + ip route add $@ + ;; + rule) + shift + ip rule add $@ + ;; + *) + ;; + esac + done < "$CFGFILE" +fi + +# activate interfaces +for IFPATH in /sys/class/net/*; do + [ "$IFPATH" == "/sys/class/net/lo" ] && continue + + IF=`basename $IFPATH` + + [ ! -f "$CFGPATH/$IF" ] || ip link set dev "$IF" up +done |