5 # initramfs-tools header
23 if [ -n "${NONETWORKING}" ]
28 # FIXME: stop hardcoding overloading of initramfs-tools functions
30 . /lib/live/boot/initramfs-tools.sh
32 log_begin_msg "Preconfiguring networking"
36 IFFILE="/root/etc/network/interfaces"
38 if [ "${STATICIP}" = "frommedia" -a -e "${IFFILE}" ]
40 # will use existent /etc/network/interfaces
45 cat > "${IFFILE}" << EOF
47 iface lo inet loopback
54 if [ -z "${NETBOOT}" -a -n "${STATICIP}" -a "${STATICIP}" != "frommedia" ]
56 parsed=$(echo "${STATICIP}" | sed -e 's/,/ /g')
58 for ifline in ${parsed}
60 ifname="$(echo ${ifline} | cut -f1 -d ':')"
61 ifaddress="$(echo ${ifline} | cut -f2 -d ':')"
62 ifnetmask="$(echo ${ifline} | cut -f3 -d ':')"
63 ifgateway="$(echo ${ifline} | cut -f4 -d ':')"
65 cat >> "${IFFILE}" << EOF
66 allow-hotplug ${ifname}
67 iface ${ifname} inet static
72 if [ -n "${ifgateway}" ]
75 cat >> "${IFFILE}" << EOF
84 if [ -z "${NETBOOT}" ] || [ -n "${DHCP}" ]
86 # default, dhcp assigned
89 # make sure that the preconfigured interface would not get reassigned by dhcp
90 # on startup by ifup script - otherwise our root fs might be disconnected!
94 # iterate the physical interfaces and add them to the interfaces list and also add when ethdevice= called on cmdline
95 if [ "${method}" != dhcp ] || ([ ! -x /root/usr/sbin/NetworkManager ] && [ ! -x /root/usr/sbin/wicd ]) || [ ! -z "${ETHDEVICE}" ]
97 for interface in /sys/class/net/eth* /sys/class/net/ath* /sys/class/net/wlan*
99 [ -e ${interface} ] || continue
100 i="$(basename ${interface})"
102 cat >> "${IFFILE}" << EOF
104 iface ${i} inet ${method}
111 if [ ! -f /root/etc/resolv.conf ] || [ -z "$(cat /root/etc/resolv.conf)" ]
113 if [ -f /netboot.config ]
115 # create a resolv.conf if it is not present or empty
116 cp /netboot.config /root/var/log/netboot.config
118 rc_search=$(cat netboot.config | awk '/domain/{print $3}')
119 rc_server0=$(cat netboot.config | awk '/dns0/{print $5}')
120 rc_server1=$(cat netboot.config | awk '/dns0/{print $8}')
121 rc_server0="nameserver ${rc_server0}"
123 if [ "${rc_server1}" = "0.0.0.0" ]
127 rc_server1="nameserver ${rc_server1}"
130 cat > /root/etc/resolv.conf << EOF
132 # Autogenerated by live-boot
139 cat /root/etc/resolv.conf >> /root/var/log/netboot.config
144 #if [ ! -x /root/usr/sbin/NetworkManager ]
146 # for i in eth0 eth1 eth2 ath0 wlan0
148 # grep -q "iface ${i}" ${IFFILE} && continue
150 #cat >> "${IFFILE}" << EOF
152 #iface ${i} inet dhcp