#!/bin/sh -e # very simple dhclient-script. All it cares about is bringing the interface # up, and it does not even try to do anything else. LOG=/tmp/dhclient.$$.log ERR=/tmp/network.$$.err PATH=$PATH:/sbin:/usr/sbin . /lib/dracut-lib getarg rdnetdebug && { exec >/tmp/dhclient.$interface.$$.out exec 2>>/tmp/dhclient.$interface.$$.out set -x } log_err() { # avoid the need for cat on the image echo "On $netif, the following command:" > $ERR echo " " "$CMD" >> $ERR echo "had errors:" >> $ERR while read line; do echo " $line"; done < $LOG >> $ERR } # Catch unlikely initial errors trap 'echo Errors preparing to configure $netif > $ERR; exit 0' EXIT netif=$interface ip=$new_ip_address mtu=$new_interface_mtu mask=$new_subnet_mask bcast=$new_broadcast_address gw=${new_routers%%,*} domain=$new_domain_name search=$new_domain_search namesrv=$new_domain_name_servers hostname=$new_host_name [ -f /tmp/net.$interface.override ] && . /tmp/net.$interface.override # save the offending command and let udev move on if we have an error trap 'log_err; exit 0' EXIT run() { CMD="$@" "$@" >> $LOG 2>&1 } setup_interface() { [ -n "$mtu" ] && { run ip link set $netif down run ip link set $netif mtu $mtu run ip link set $netif up } run ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif [ -n "$gw" ] && run ip route add default via $gw [ -n "${search}${domain}" -a -n "$namesrv" ] && { echo search $search $domain > /etc/resolv.conf for s in $namesrv; do echo nameserver $s >> /etc/resolv.conf done } [ -e /tmp/hostname.set ] || { [ -n "$hostname" ] && mknod /tmp/hostname.set p && run hostname $hostname } : } case $reason in PREINIT) run /sbin/ip link set $netif up ;; BOUND) setup_interface set | while read line; do [ "${line#new_}" = "$line" ] && continue echo "$line" >>/tmp/net.$netif.dhcpopts done >/tmp/net.$netif.up echo online > /sys/class/net/$netif/uevent ;; *) ;; esac trap - EXIT exit 0