ff231780829630dd4823c7c56396acb8ab760e1a
[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         pb-event add@/net/${interface} \
19                 name=netboot \
20                 image=tftp://${siaddr}/${boot_file} \
21                 args="root=/dev/nfs ip=any nfsroot=${k_server_ip}:${k_root_dir}"
22 }
23
24 pb_remove () {
25         pb-event remove@/net/${interface} name=netboot
26 }
27
28 case "$1" in
29 bound | renew)
30         pb_add
31         ;;
32 deconfig)
33         pb_remove
34         ;;
35 *)
36         ;;
37 esac
38
39 printf "--- $1 ---\n" >> ${log}
40 set >> ${log}
41 printf "---------------\n" >> ${log}