1
0
Fork 0
mirror of https://github.com/pygos/init-scripts.git synced 2024-11-09 14:47:10 +01:00
init-scripts/scripts/ifcfg.sh.in
David Oberhollenzer b6c97e117c Remove possible bashisms
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-11-17 16:40:15 +01:00

71 lines
1.1 KiB
Bash
Executable file

#!/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