#!/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 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 } run() { CMD="$@" "$@" >> $LOG 2>&1 } setup_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.$netif.override ] && . /tmp/net.$netif.override if [ -n "$mtu" ] ; then run ip link set $netif down run ip link set $netif mtu $mtu run ip link set $netif up fi run ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif [ -n "$gw" ] && run ip route add default via $gw if [ -n "${search}${domain}" -a -n "$namesrv" ] ; then echo search $search $domain > /etc/resolv.conf for s in $namesrv; do echo nameserver $s >> /etc/resolv.conf done fi if [ ! -e /tmp/hostname.set ] ; then [ -n "$hostname" ] && mknod /tmp/hostname.set p && run hostname $hostname fi : } PATH=$PATH:/sbin:/usr/sbin . /lib/dracut-lib if getarg rdnetdebug ; then exec >/tmp/dhclient.$interface.$$.out exec 2>>/tmp/dhclient.$interface.$$.out set -x fi # Huh? Interface configured? [ -f "/tmp/net.$netif.up" ] && exit 0 # save offending commands and let udev move on if we have an error trap 'log_err; exit 0' EXIT # We already need a set netif here netif=$interface case $reason in PREINIT) run ip link set $netif up ;; BOUND) setup_interface set | while read line; do [ "${line#new_}" = "$line" ] && continue echo "$line" done >/tmp/dhclient.$netif.dhcpopts >/tmp/net.$netif.up echo online > /sys/class/net/$netif/uevent ;; *) ;; esac trap - EXIT exit 0