blob: 2bdf9b0ebfe6a5f9b577e41c2abb2f6fdeb6c515 (
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
69
70
71
72
73
74
75
76
|
#! /bin/sh
PREREQ=""
DESCRIPTION="Preconfiguring networking..."
IFFILE="/root/etc/network/interfaces"
. /scripts/casper-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}" -a -n "${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
if [ -z "${NETBOOT}" ]; then
# default, dhcp assigned
method="dhcp"
else
# make sure that the preconfigured interface would not get reassigned by dhcp
# on startup by ifup script - otherwise our root fs might be disconnected!
method="manual"
fi
# iterate the physical interfaces and add them to the interfaces list
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 ${method}
EOF
done
fi
log_end_msg
|