5 # initramfs-tools header
23 if [ -n "${NONETWORKING}" ]
28 .
/scripts
/live-functions
30 log_begin_msg
"Preconfiguring networking"
34 IFFILE
="/root/etc/network/interfaces"
36 if [ "${STATICIP}" = "frommedia" -a -e "${IFFILE}" ]
38 # will use existent /etc/network/interfaces
43 cat > "${IFFILE}" << EOF
45 iface lo inet loopback
52 if [ -z "${NETBOOT}" -a -n "${STATICIP}" -a "${STATICIP}" != "frommedia" ]
54 parsed
=$
(echo "${STATICIP}" |
sed -e 's/:/ /g')
56 for ifline
in ${parsed}
58 ifname
="$(echo ${ifline} | cut -f1 -d ',')"
59 ifaddress
="$(echo ${ifline} | cut -f2 -d ',')"
60 ifnetmask
="$(echo ${ifline} | cut -f3 -d ',')"
61 ifgateway
="$(echo ${ifline} | cut -f4 -d ',')"
63 cat >> "${IFFILE}" << EOF
65 iface ${ifname} inet static
74 if [ -z "${NETBOOT}" ] ||
[ -n "${DHCP}" ]
76 # default, dhcp assigned
79 # make sure that the preconfigured interface would not get reassigned by dhcp
80 # on startup by ifup script - otherwise our root fs might be disconnected!
84 # iterate the physical interfaces and add them to the interfaces list
85 if [ "${method}" != dhcp
] ||
([ ! -x /root
/usr
/sbin
/NetworkManager
] && [ ! -x /root
/usr
/sbin
/wicd
])
87 for interface
in /sys
/class
/net
/eth
* /sys
/class
/net
/ath
* /sys
/class
/net
/wlan
*
89 [ -e ${interface} ] ||
continue
90 i
="$(basename ${interface})"
92 cat >> "${IFFILE}" << EOF
94 iface ${i} inet ${method}
101 if [ ! -f /root
/etc
/resolv.conf
] ||
[ -z "$(cat /root/etc/resolv.conf)" ]
103 if [ -f /netboot.config
]
105 # create a resolv.conf if it is not present or empty
106 cp /netboot.config
/root
/var
/log
/netboot.config
108 rc_search
=$
(cat netboot.config |
awk '/domain/{print $3}')
109 rc_server0
=$
(cat netboot.config |
awk '/dns0/{print $5}')
110 rc_server1
=$
(cat netboot.config |
awk '/dns0/{print $8}')
111 rc_server0
="nameserver ${rc_server0}"
113 if [ "${rc_server1}" = "0.0.0.0" ]
117 rc_server1
="nameserver ${rc_server1}"
120 cat > /root
/etc
/resolv.conf
<< EOF
122 # Autogenerated by live-boot
129 cat /root
/etc
/resolv.conf
>> /root
/var
/log
/netboot.config
134 #if [ ! -x /root/usr/sbin/NetworkManager ]
136 # for i in eth0 eth1 eth2 ath0 wlan0
138 # grep -q "iface ${i}" ${IFFILE} && continue
140 #cat >> "${IFFILE}" << EOF
142 #iface ${i} inet dhcp