X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=utils%2Fpb-udhcpc;h=d641e9917b6bd459340ec5dc44c9007cc5d25562;hb=1513dd5d05f6408a64e19ea18cfaeb0cb8c5fb73;hp=808f12ab51ec5ab90a2fd63741c5e5468f81bb3d;hpb=c3f79834be3fe862388432d01f15f727c8b7cd7c;p=petitboot diff --git a/utils/pb-udhcpc b/utils/pb-udhcpc index 808f12a..d641e99 100644 --- a/utils/pb-udhcpc +++ b/utils/pb-udhcpc @@ -13,10 +13,11 @@ resolve_url() { file="$1" # URL? use as-is. - tmp=${file#://*} + tmp=${file%://*} if [ "$tmp" != "$file" ] then echo "$file" + return fi # Otherwise, TFTP using an appropriate host. Start with the @@ -38,14 +39,14 @@ do_pxe() { params="conf@/net/${interface} method=dhcp" # first, try by MAC - mac=$(cat /sys/class/net/$interface/address) - pb-event $params url=$basedir/$mac + mac=$(tr ':' '-' < /sys/class/net/$interface/address) + pb-event $params url=$basedir/01-$mac # try decreasing fragments of IP lease ip_hex=$(printf '%02X%02X%02X%02X' $(echo $ip | tr '.' ' ')) for i in $(seq 8 -1 1) do - frag=${hex_ip:0:$i} + frag=${ip_hex:0:$i} pb-event $params url=$basedir/$frag done @@ -57,7 +58,7 @@ pb_add () { # Look for an explicit config file location in the DHCP config-file # parameter - if [ -n ${conffile} ] + if [ -n "${conffile}" ] then url=$(resolve_url ${conffile}) pb-event conf@/net/${interface} url=$url method=dhcp @@ -67,7 +68,7 @@ pb_add () { # Otherwise, we'll need the boot-file parameter. Looks like udhcpc # will give us different names, depending if the parameter was in # the header, or specified by options - [ -n "$bootfile" ] && bootfile=${boot_file} + [ -z "$bootfile" ] && bootfile=${boot_file} if [ -z "$bootfile" ] then @@ -89,7 +90,7 @@ pb_add () { k_root_dir=${rootpath#*:} args= - if [ -n $rootpath ] + if [ -n "$rootpath" ] then [ ${k_server_ip} != ${rootpath} ] || k_server_ip=${serverid} args="root=/dev/nfs ip=any nfsroot=${k_server_ip}:${k_root_dir}"