7 if [ -n "${NONETWORKING}" ]
12 # FIXME: stop hardcoding overloading of initramfs-tools functions
14 .
/lib
/live
/boot
/9990-initramfs-tools.sh
16 log_begin_msg
"Preconfiguring networking"
18 IFFILE
="/root/etc/network/interfaces"
19 DNSFILE
="/root/etc/resolv.conf"
21 if [ "${STATICIP}" = "frommedia" ] && [ -e "${IFFILE}" ]
23 # will use existent /etc/network/interfaces
28 cat > "${IFFILE}" << EOF
30 iface lo inet loopback
37 if [ -z "${NETBOOT}" ] && [ -n "${STATICIP}" ] && [ "${STATICIP}" != "frommedia" ]
39 parsed
=$
(echo "${STATICIP}" |
sed -e 's|,| |g')
41 for ifline
in ${parsed}
43 ifname
="$(echo ${ifline} | cut -f1 -d ':')"
44 ifaddress
="$(echo ${ifline} | cut -f2 -d ':')"
45 ifnetmask
="$(echo ${ifline} | cut -f3 -d ':')"
46 ifgateway
="$(echo ${ifline} | cut -f4 -d ':')"
47 nameserver
="$(echo ${ifline} | cut -f5 -d ':')"
49 cat >> "${IFFILE}" << EOF
50 allow-hotplug ${ifname}
51 iface ${ifname} inet static
56 if [ -n "${ifgateway}" ]
59 cat >> "${IFFILE}" << EOF
66 if [ -n "${nameserver}" ]
68 if [ -e "${DNSFILE}" ]
70 grep -v ^nameserver
"${DNSFILE}" > "${DNSFILE}.tmp"
71 mv "${DNSFILE}.tmp" "${DNSFILE}"
74 echo "nameserver ${nameserver}" >> "${DNSFILE}"
78 if [ -z "${NETBOOT}" ] ||
[ -n "${DHCP}" ]
80 # default, dhcp assigned
83 # make sure that the preconfigured interface would not get reassigned by dhcp
84 # on startup by ifup script - otherwise our root fs might be disconnected!
88 # iterate the physical interfaces and add them to the interfaces list and also add when ethdevice= called on cmdline
89 if [ "${method}" != dhcp
] ||
([ ! -x /root
/usr
/sbin
/NetworkManager
] && [ ! -x /root
/usr
/sbin
/wicd
]) ||
[ ! -z "${ETHDEVICE}" ]
91 for interface
in /sys
/class
/net
/eth
* /sys
/class
/net
/ath
* /sys
/class
/net
/wlan
*
93 [ -e ${interface} ] ||
continue
94 i
="$(basename ${interface})"
96 cat >> "${IFFILE}" << EOF
98 iface ${i} inet ${method}
105 if [ ! -f /root
/etc
/resolv.conf
] ||
[ -z "$(cat /root/etc/resolv.conf)" ]
107 if [ -f /netboot.config
]
109 # create a resolv.conf if it is not present or empty
110 cp /netboot.config
/root
/var
/log
/netboot.config
112 rc_search
=$
(cat netboot.config |
awk '/domain/ { print $3 }')
113 rc_server0
="$(cat netboot.config | awk '/dns0/ { print $5 }')"
115 cat > /root
/etc
/resolv.conf
<< EOF
118 nameserver ${rc_server0}
121 rc_server1
=$
(cat netboot.config |
awk '/dns0/ { print $8 }')
123 if [ "${rc_server1}" ! = "0.0.0.0" ]
125 echo "nameserver ${rc_server1}" >> /root
/etc
/resolv.conf
128 cat /root
/etc
/resolv.conf
>> /root
/var
/log
/netboot.config