summaryrefslogtreecommitdiffstats
path: root/utils/pb-udhcpc
blob: 91d40f6c01f37eb89ea468cd8ee9a8afca8b699e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
#
# Petitboot udhcpc user script.  Should be run by udhcpc when
# there is a change in the dhcp configuration.  For more info
# see the udhcpc man page and the Linux kernel source file
# Documentation/filesystems/nfsroot.txt.
#

PBOOT_USER_EVENT_SOCKET="/tmp/petitboot.ev"
log="/var/log/petitboot/pb-udhcpc.log"

pb_add () {
	k_server_ip=${rootpath%%:*}
	k_root_dir=${rootpath#*:}

	[ ${k_server_ip} != ${rootpath} ] || k_server_ip=${serverid}

	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
}

pb_remove () {
	printf "remove@/net/${interface}\0name=netboot\0" | pb-event
}

case "$1" in
bound | renew)
	pb_add
	;;
deconfig)
	pb_remove
	;;
*)
	;;
esac

printf "--- $1 ---\n" >> ${log}
set >> ${log}
printf "---------------\n" >> ${log}
OpenPOWER on IntegriCloud