You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

36 lines
973 B

#!/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" ] && {
ip link set lo up
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
ip link set $1 up
ip addr add $client/$netmask dev $1
[ "$gw" ] && ip route add default via $gw dev $1
>/net.$1.up ;;
esac
fi
) ;;
*) continue;;
esac
done