summaryrefslogtreecommitdiffstats
path: root/defaultenv-2/base/bin/ifup
blob: 9f6fd6bc49c41d540003d8a8afd974efd4b8e800 (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
#!/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
elif [ "$ip" = dhcp ]; then
	dhcp
	exit $?
fi

echo -o /tmp/network/$interface up