X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=utils%2Fpb-udhcpc;h=7ed9035d5e9dad89f7880a0815e645320b8939d4;hp=91d40f6c01f37eb89ea468cd8ee9a8afca8b699e;hb=94fe62686228cf49dc055c50ce8f7ced3bf3cb96;hpb=e3ebf4d2ebe3464257655f059ea020565a536643 diff --git a/utils/pb-udhcpc b/utils/pb-udhcpc index 91d40f6..7ed9035 100644 --- a/utils/pb-udhcpc +++ b/utils/pb-udhcpc @@ -10,20 +10,54 @@ PBOOT_USER_EVENT_SOCKET="/tmp/petitboot.ev" log="/var/log/petitboot/pb-udhcpc.log" pb_add () { - k_server_ip=${rootpath%%:*} - k_root_dir=${rootpath#*:} + # Looks like udhcpc will give us different names, depending if the + # parameter was in the header, or specified by options + [ -z "$bootfile" ] && bootfile=${boot_file} - [ ${k_server_ip} != ${rootpath} ] || k_server_ip=${serverid} + mac=$(cat /sys/class/net/$interface/address) + paramstr='' - printf "add@/net/${interface}\0name=netboot\0image=tftp://${siaddr}/${boot_file}\0args=root=/dev/nfs ip=any nfsroot=${k_server_ip}:${k_root_dir}\0" | pb-event + # Collect relevant DHCP response parameters into $paramstr + for name in pxeconffile pxepathprefix bootfile mac ip siaddr \ + serverid tftp + do + value=$(eval "echo \${$name}") + [ -n "$value" ] || continue; + + paramstr="$paramstr $name=$value" + done + + pb-event dhcp@${interface} $paramstr + + # Check if an explicit boot file present. If there is, add it as + # an option directly. + if [ -z "${bootfile}" ] + then + return; + fi + + paramstr="" + + # Collect relevant parameters to add an option to the bootfile + # parameter + for name in rootpath siaddr bootfile + do + value=$(eval "echo \${$name}") + [ -n "$value" ] || continue; + + paramstr="$paramstr $name=$value" + done + + pb-event add@${interface} name="netboot $interface ($bootfile)" \ + $paramstr } pb_remove () { - printf "remove@/net/${interface}\0name=netboot\0" | pb-event + pb-event remove@${interface} } case "$1" in -bound | renew) +bound) pb_add ;; deconfig)