blob: 4495266e4614ee31bd6cf3068acf15e591300b06 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/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 () {
# Looks like udhcpc will give us different names, depending if the
# parameter was in the header, or specified by options
[ -z "$bootfile" ] && bootfile=${boot_file}
mac=$(cat /sys/class/net/$interface/address)
paramstr=''
# Collect relevant DHCP response parameters into $paramstr
for name in pxeconffile pxepathprefix bootfile mac ip siaddr \
serverid tftp
do
value=$(eval "echo \${$name}")
[ -n "$value" ] || continue;
paramstr="$paramstr $name=$value"
done
pb-event dhcp@${interface} $paramstr
# Check if an explicit boot file present. If there is, add it as
# an option directly.
if [ -z "${bootfile}" ]
then
return;
fi
paramstr=""
# Collect relevant parameters to add an option to the bootfile
# parameter
for name in rootpath siaddr bootfile mac
do
value=$(eval "echo \${$name}")
[ -n "$value" ] || continue;
paramstr="$paramstr $name=$value"
done
pb-event add@${interface} name="netboot $interface ($bootfile)" \
$paramstr
}
pb_remove () {
mac=$(cat /sys/class/net/$interface/address)
pb-event remove@${interface} mac=$mac
}
case "$1" in
bound)
pb_add
;;
deconfig)
pb_remove
;;
*)
;;
esac
printf "--- $1 ---\n" >> ${log}
set >> ${log}
printf "---------------\n" >> ${log}
|