give basic commandline help
[openwrt.git] / target / default / target_skeleton / sbin / ifup
1 #!/bin/ash
2 [ $# = 0 ] && { echo " $0 <group>"; exit; }
3 . /etc/functions.sh
4 type=$1
5 debug "### ifup $type ###"
6
7 if=$(nvram get ${type}_ifname)
8 [ "${if%%[0-9]}" = "ppp" ] && if=$(nvram get pppoe_ifname)
9
10 if_valid $if || exit
11 mac=$(nvram get ${type}_hwaddr)
12 $DEBUG ifconfig $if down 2>&-
13
14 if [ "${if%%[0-9]}" = "br" ]; then
15 stp=$(nvram get ${type}_stp)
16 $DEBUG brctl delbr $if 2>&-
17 $DEBUG brctl addbr $if
18 $DEBUG brctl setfd $if 0
19 $DEBUG brctl stp $if ${stp:-0}
20
21 for sif in $(nvram get ${type}_ifnames); do
22 if_valid $sif || continue
23 ${mac:+$DEBUG ifconfig $sif down hw ether $mac}
24 $DEBUG ifconfig $sif 0.0.0.0 up
25 $DEBUG brctl addif $if $sif
26 done
27 else
28 ${mac:+$DEBUG ifconfig $if down hw ether $mac}
29 fi
30
31 if_proto=$(nvram get ${type}_proto)
32 case "$if_proto" in
33 static)
34 ip=$(nvram get ${type}_ipaddr)
35 netmask=$(nvram get ${type}_netmask)
36 gateway=$(nvram get ${type}_gateway)
37
38 $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
39 ${gateway:+$DEBUG route add default gw $gateway}
40
41 [ -f /etc/resolv.conf ] && return
42
43 debug "# --- creating /etc/resolv.conf ---"
44 for dns in $(nvram get ${type}_dns); do
45 echo "nameserver $dns" >> /etc/resolv.conf
46 done
47 ;;
48 dhcp)
49 ip=$(nvram get ${type}_ipaddr)
50 [ -f $pidfile ] && $DEBUG kill $(cat $pidfile)
51 ${DEBUG:-eval} "udhcpc -R -i $if ${ip:+-r $ip} -b -p $pidfile &"
52 ;;
53 none|"")
54 ;;
55 *)
56 [ -x "/sbin/ifup.${if_proto}" ] && { $DEBUG /sbin/ifup.${if_proto} $*; exit; }
57 echo "### ifup $type: ignored ${type}_proto=\"$if_proto\" (not supported)"
58 ;;
59 esac
This page took 0.049814 seconds and 5 git commands to generate.