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