]> git.ozlabs.org Git - petitboot/blobdiff - utils/pb-udhcpc
utils/pb-udhcp: Don't add a new option on renew
[petitboot] / utils / pb-udhcpc
index 808f12ab51ec5ab90a2fd63741c5e5468f81bb3d..dd291b9a0fa61441f072b2b75251abdf160056b5 100644 (file)
@@ -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
@@ -35,17 +36,17 @@ resolve_url() {
 do_pxe() {
        basedir=$1
 
-       params="conf@/net/${interface} method=dhcp"
+       params="conf@${interface} method=dhcp"
 
        # first, try by MAC
-       mac=$(cat /sys/class/net/$interface/address)
-       pb-event $params url=$basedir/$mac
+       mac=$(tr ':' '-' < /sys/class/$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,17 +58,17 @@ 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
+               pb-event conf@${interface} url=$url method=dhcp
                return
        fi
 
        # 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,24 +90,24 @@ 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}"
        fi
 
-       pb-event add@/net/${interface} \
+       pb-event add@${interface} \
                name=netboot \
                image=tftp://${siaddr}/${boot_file} \
                args="$args"
 }
 
 pb_remove () {
-       pb-event remove@/net/${interface} name=netboot
+       pb-event remove@${interface} name=netboot
 }
 
 case "$1" in
-bound | renew)
+bound)
        pb_add
        ;;
 deconfig)