X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=utils%2Fpb-udhcpc;h=4ff0dcf2dc9328d71cd8deaff2b69e4120a2dc58;hp=45c801909f3a72c62dbf0c80cea434b0ce76c74d;hb=44e10d816427c001d60eb5e7b3e75b740e5a2823;hpb=e7815dc27286b66bd67e4727a1a4f51a5b862b0d diff --git a/utils/pb-udhcpc b/utils/pb-udhcpc index 45c8019..4ff0dcf 100644 --- a/utils/pb-udhcpc +++ b/utils/pb-udhcpc @@ -10,20 +10,51 @@ 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=$(< /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 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 config file present + if [ -n "${conffile}" ] + then + return; + fi + + # Finally, add an option for the boot_file parameter + paramstr='name=netboot' + + # Collect relevant parameters to add an option to the boot_file parameter + for name in rootpath siaddr boot_file + do + value=$(eval "echo \${$name}") + [ -n "$value" ] || continue; + + paramstr="$paramstr $name=$value" + done + + pb-event add@{interface} $paramstr } pb_remove () { - printf "remove@/net/${interface}\0name=netboot\0" | pb-event + pb-event remove@${interface} name=netboot } case "$1" in -bound | renew) +bound) pb_add ;; deconfig)