pb-udhcpc: Fix generation of TFTP URLs
[petitboot] / utils / pb-udhcpc
1 #!/bin/sh
2 #
3 # Petitboot udhcpc user script.  Should be run by udhcpc when
4 # there is a change in the dhcp configuration.  For more info
5 # see the udhcpc man page and the Linux kernel source file
6 # Documentation/filesystems/nfsroot.txt.
7 #
8
9 PBOOT_USER_EVENT_SOCKET="/tmp/petitboot.ev"
10 log="/var/log/petitboot/pb-udhcpc.log"
11
12 pb_add () {
13         k_server_ip=${rootpath%%:*}
14         k_root_dir=${rootpath#*:}
15
16         [ ${k_server_ip} != ${rootpath} ] || k_server_ip=${serverid}
17
18         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
19 }
20
21 pb_remove () {
22         printf "remove@/net/${interface}\0name=netboot\0" | pb-event
23 }
24
25 case "$1" in
26 bound | renew)
27         pb_add
28         ;;
29 deconfig)
30         pb_remove
31         ;;
32 *)
33         ;;
34 esac
35
36 printf "--- $1 ---\n" >> ${log}
37 set >> ${log}
38 printf "---------------\n" >> ${log}