37 lines
1004 B
Bash
Executable File
37 lines
1004 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# bail immediatly if the interface is already up
|
|
[ -f "/net.$1.up" ] && exit 0
|
|
|
|
# loopback is always handled the same way
|
|
[ "$1" = "lo" ] && {
|
|
/sbin/ip link set lo up
|
|
/sbin/ip addr add 127.0.0.1/8 dev lo
|
|
exit 0
|
|
}
|
|
|
|
# spin through the kernel command line, looking for ip= lines
|
|
for p in $(cat /proc/cmdline); do
|
|
[ "${p%ip=*}" ] || continue
|
|
p=${p#ip=}
|
|
case $p in
|
|
none|off) exit 0;; # we were told to not configure anything
|
|
dhcp|on|any) >/net.$1.dhcp; exit 0;;
|
|
bootp|rarp|both) exit 0;; #dunno how to do this
|
|
*) echo ${ip#ip=} | \
|
|
(IFS=':' read client server gw netmask hostname device autoconf
|
|
if [ -z "$device" -o "$device" = "$1" ]; then
|
|
case $autoconf in
|
|
dhcp|on|any) >/net.$1.dhcp ;;
|
|
none|off|'') # do some basic configuration
|
|
/sbin/ip link set $1 up
|
|
/sbin/ip addr add $client/$netmask dev $1
|
|
[ "$gw" ] && /sbin/ip route add default via $gw dev $1
|
|
>/net.$1.up ;;
|
|
esac
|
|
fi
|
|
) ;;
|
|
*) continue;;
|
|
esac
|
|
done
|