summaryrefslogtreecommitdiff
path: root/scripts/casper-bottom/23networking
blob: 8f4b698c7fdeb4efee5fdb6c6e95c39708bd68d7 (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
68
#! /bin/sh

PREREQ=""
DESCRIPTION="Preconfiguring networking..."
IFFILE="/root/etc/network/interfaces"

. /scripts/functions

prereqs()
{
       echo "$PREREQ"
}

case $1 in
# get pre-requisites
prereqs)
       prereqs
       exit 0
       ;;
esac

log_begin_msg "$DESCRIPTION"

if [ "${STATICIP}" == "frommedia" ] && [ -e  "$IFFILE" ] ; then
	# will use existent /etc/network/interfaces
	log_end_msg
	exit 0
fi

cat > "$IFFILE" <<EOF
auto lo
iface lo inet loopback

EOF

udevtrigger

if [ -z "${NETBOOT}" ] ; then
	if [ ! -z "${STATICIP}" ] && [ "${STATICIP}" != "frommedia" ]; then
		parsed=$(echo "${STATICIP}" | sed -e 's/:/ /g')
		for ifline in ${parsed}; do
			ifname="$(echo ${ifline} | cut -f1 -d ',')"
			ifaddress="$(echo ${ifline} | cut -f2 -d ',')"
			ifnetmask="$(echo ${ifline} | cut -f3 -d ',')"
			ifgateway="$(echo ${ifline} | cut -f4 -d ',')"
			cat >> "$IFFILE" <<EOF
auto ${ifname}
iface ${ifname} inet static
    address ${ifaddress}
    netmask ${ifnetmask}
    gateway ${ifgateway}

EOF
		done
	else
		for interface in /sys/class/net/eth* /sys/class/net/ath* /sys/class/net/wlan*; do
			[ -e $interface ] || continue
			i="$(basename $interface)"
			cat >> "$IFFILE" <<EOF
auto $i
iface $i inet dhcp

EOF
		done
	fi
fi

log_end_msg