summaryrefslogtreecommitdiffstats
path: root/defaultenv-2/base/bin/ifup
blob: 37b986c44b2c76fef9226f7cfbd88958bee543dd (plain)
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
64
65
66
67
#!/bin/sh

mkdir -p /tmp/network

if [ $# != 1 ]; then
	echo "usage: ifup <interface>"
	exit 1
fi

interface="$1"

if [ -f /tmp/network/$interface ]; then
	exit 0
fi

cmd=/env/network/$interface

if [ ! -e $cmd ]; then
	echo "$f: no such file"
	exit 1
fi

ip=
ipaddr=
netmask=
gateway=
serverip=
ethaddr=

. $cmd

if [ $? != 0 ]; then
	echo "failed to bring up $interface"
	exit 1
fi

if [ -f /env/network/${interface}-discover ]; then
	/env/network/${interface}-discover
	if [ $? != 0 ]; then
		echo "failed to discover eth0"
		exit 1
	fi
fi

if [ -n "$ethaddr" ]; then
	${interface}.ethaddr=$ethaddr
fi

if [ "$ip" = static ]; then
	${interface}.ipaddr=$ipaddr
	${interface}.netmask=$netmask
	${interface}.serverip=$serverip
	${interface}.gateway=$gateway
	ret=0
elif [ "$ip" = dhcp ]; then
	dhcp
	ret=$?
	if [ $ret = 0 -a -n "$serverip" ]; then
		${interface}.serverip=$serverip
	fi
fi

if [ $ret = 0 ]; then
	echo -o /tmp/network/$interface up
fi

exit $ret