-
Notifications
You must be signed in to change notification settings - Fork 6
/
pxe.sh
executable file
·53 lines (47 loc) · 957 Bytes
/
pxe.sh
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
#!/bin/sh
set -eux
PATH="/home/test/bin:$PATH"
echo "turn $1 pxe boot for machine $machine"
case "$1" in
"on")
action="host $machine { \
hardware ethernet $hwaddr; \
fixed-address $ipaddr; \
next-server $tftpserver; \
filename \"boot\"; \
} #$machine"
;;
"install")
action="host $machine { \
hardware ethernet $hwaddr; \
fixed-address $ipaddr; \
next-server $tftpserver; \
filename \"auto_install\"; \
} #$machine"
;;
"upgrade")
action="host $machine { \
hardware ethernet $hwaddr; \
fixed-address $ipaddr; \
next-server $tftpserver; \
filename \"auto_upgrade\"; \
} #$machine"
;;
"off")
action="host $machine { \
hardware ethernet $hwaddr; \
fixed-address $ipaddr; \
next-server $tftpserver; \
filename \"invalid\"; \
} #$machine"
;;
*)
echo "unknown command $1"
exit 1
;;
esac
temp_file=`mktemp`
sed -e "s,^.*#$machine$,$action," /etc/dhcpd.conf > $temp_file
cat $temp_file > /etc/dhcpd.conf
rm -f $temp_file
doas /etc/rc.d/dhcpd restart