summaryrefslogtreecommitdiffstats
path: root/build/rootfs/etc/udhcpc.default.script
blob: 0ea5cd55254486702a5c6e8cba2d3d9e90e76024 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
# Busybox udhcpc dispatcher script. Copyright (C) 2009 by Axel Beckert.
#
# Based on the busybox example scripts and the old udhcp source
# package default.* scripts.

RESOLV_CONF="/etc/resolv.conf"

case $1 in
    bound|renew)
	[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
	[ -n "$subnet" ] && NETMASK="netmask $subnet"

        ip addr add $ip/$(ipcalc -s -p $ip $subnet|sed s/.*=//) dev $interface
        ip route add default via $router  
	
	# read filename from fbgui.conf where ip config should be saved.
	ipconf=$(cat /etc/fbgui.conf | grep ip_config | cut -d '=' -f2)

	echo "ip=$ip" > $ipconf
        echo "subnet=$subnet" >> $ipconf
        echo "broadcast=$broadcast" >> $ipconf
	echo "gateway=$router" >> $ipconf

	# Update resolver configuration file
	R=""
	[ -n "$domain" ] && R="domain $domain
"
	count=1;
	for i in $dns; do
	    echo "$0: Adding DNS $i"
	    R="${R}nameserver $i
"
	    count=$((count+1));
	done

	if [ -x /sbin/resolvconf ]; then
	    echo -n "$R" | resolvconf -a "${interface}.udhcpc"
	else
	    echo -n "$R" > "$RESOLV_CONF"
	fi
	trigger=$(cat /etc/fbgui.conf | grep file_trigger | cut -d '=' -f2)
	
        echo "gogo" >> $trigger
	;;

    deconfig)

	;;

    leasefail)
	echo "$0: Lease failed: $message"
	;;

    nak)
	echo "$0: Received a NAK: $message"
	;;

    *)
	echo "$0: Unknown udhcpc command: $1";
	exit 1;
	;;
esac