diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:38:32 +0100 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:50:20 +0100 |
commit | e2e6f6fe07049f33cb6348780fa975162752e421 (patch) | |
tree | b1813295411235d1297a0ed642b1346b24fdfb12 /meta/recipes-core/busybox/files/simple.script | |
download | poky-e2e6f6fe07049f33cb6348780fa975162752e421.tar.gz |
initial commit of Enea Linux 3.1
Migrated from the internal git server on the dora-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'meta/recipes-core/busybox/files/simple.script')
-rw-r--r-- | meta/recipes-core/busybox/files/simple.script | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/files/simple.script b/meta/recipes-core/busybox/files/simple.script new file mode 100644 index 0000000000..78ac4242a8 --- /dev/null +++ b/meta/recipes-core/busybox/files/simple.script | |||
@@ -0,0 +1,86 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # udhcpc script edited by Tim Riker <Tim@Rikers.org> | ||
4 | |||
5 | [ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1 | ||
6 | |||
7 | RESOLV_CONF="/etc/resolv.conf" | ||
8 | [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" | ||
9 | [ -n "$subnet" ] && NETMASK="netmask $subnet" | ||
10 | |||
11 | # return 0 if root is mounted on a network filesystem | ||
12 | root_is_nfs() { | ||
13 | sed -n 's/^[^ ]* \([^ ]*\) \([^ ]*\) .*$/\1 \2/p' /proc/mounts | | ||
14 | grep -q "^/ \(nfs\|smbfs\|ncp\|coda\)$" | ||
15 | } | ||
16 | |||
17 | have_bin_ip=0 | ||
18 | if [ -x /sbin/ip ]; then | ||
19 | have_bin_ip=1 | ||
20 | fi | ||
21 | |||
22 | case "$1" in | ||
23 | deconfig) | ||
24 | if [ -x /sbin/resolvconf ]; then | ||
25 | /sbin/resolvconf -d "${interface}.udhcpc" | ||
26 | fi | ||
27 | if ! root_is_nfs ; then | ||
28 | if [ $have_bin_ip -eq 1 ]; then | ||
29 | ip addr flush dev $interface | ||
30 | ip link set dev $interface up | ||
31 | else | ||
32 | /sbin/ifconfig $interface 0.0.0.0 | ||
33 | fi | ||
34 | fi | ||
35 | ;; | ||
36 | |||
37 | renew|bound) | ||
38 | if [ $have_bin_ip -eq 1 ]; then | ||
39 | ip addr add dev $interface local $ip/$mask $BROADCAST | ||
40 | else | ||
41 | /sbin/ifconfig $interface $ip $BROADCAST $NETMASK | ||
42 | fi | ||
43 | |||
44 | if [ -n "$router" ] ; then | ||
45 | if ! root_is_nfs ; then | ||
46 | if [ $have_bin_ip -eq 1 ]; then | ||
47 | while ip route del default 2>/dev/null ; do | ||
48 | : | ||
49 | done | ||
50 | else | ||
51 | while route del default gw 0.0.0.0 dev $interface 2>/dev/null ; do | ||
52 | : | ||
53 | done | ||
54 | fi | ||
55 | fi | ||
56 | |||
57 | metric=0 | ||
58 | for i in $router ; do | ||
59 | if [ $have_bin_ip -eq 1 ]; then | ||
60 | ip route add default via $i metric $metric | ||
61 | else | ||
62 | route add default gw $i dev $interface metric $metric 2>/dev/null | ||
63 | fi | ||
64 | metric=$(($metric + 1)) | ||
65 | done | ||
66 | fi | ||
67 | |||
68 | # Update resolver configuration file | ||
69 | R="" | ||
70 | [ -n "$domain" ] && R="domain $domain | ||
71 | " | ||
72 | for i in $dns; do | ||
73 | echo "$0: Adding DNS $i" | ||
74 | R="${R}nameserver $i | ||
75 | " | ||
76 | done | ||
77 | |||
78 | if [ -x /sbin/resolvconf ]; then | ||
79 | echo -n "$R" | /sbin/resolvconf -a "${interface}.udhcpc" | ||
80 | else | ||
81 | echo -n "$R" > "$RESOLV_CONF" | ||
82 | fi | ||
83 | ;; | ||
84 | esac | ||
85 | |||
86 | exit 0 | ||