3 # Setup dhcp server to point to tftp server,
4 # and depending on the type, setup the tftp server.
7 # default distro is the base debian/fedora type. others are fai & arch.
8 # for no pxe server, use a no-op like : or true.
11 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
16 Usage: ${0##*/} [OPTIONS] TYPE [HOST]
19 TYPE is one of arch, plain, fai, or : for no pxe server.
20 HOST makes the pxe server only for that specific host
22 -h|--help Print help and exit
23 -- Subsequent arguments are never treated as options
24 -p Persist. Otherwise, wait for 2 dhcp acks then remove.
25 -r Don't redeploy fai config.
30 ##### begin command line parsing ########
39 -r) redep
=false
; shift ;;
40 -p) persist
=true
; shift ;;
41 *) args
+=("$1"); shift ;;
47 read type host <<<"${args[@]}"
49 if [[ ! $type ]]; then
50 echo "$0: error: exptected 1 argument of type"
59 :|true
) persist
=true
;;
62 ##### end command line parsing ########
71 dhcp-option-force=209,boot/syslinux/archiso.cfg
72 dhcp-option-force=210,/arch/
73 dhcp-boot=${host_tag}/arch/boot/syslinux/lpxelinux.0
78 # if arch was used before, this additionally needs
79 # the tftp link in /mnt/usb to be changed.
81 dhcp-boot=${host_tag}pxelinux.0
88 dhcp-boot=${host_tag}fai/pxelinux.0,faiserver.lan,faiserver.lan
97 regex
=".*DHCPACK.*$host_regex$"
100 while (( i
!= wait_count
)) && read line
; do
101 if [[ $line =~
$regex ]]; then
105 done < <(ssh wrt logread
-f)
110 ${1:-$type} |
ssh wrt
"cedit pxe-server /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart
111 if [[ $type == arch ]]; then arch-pxe-mount; fi"
116 if [[ $type == fai
]]; then
124 echo "waiting for 2 dhcp acks then disabling pxe"
127 if [[ $type == fai
]]; then
128 # fai server can contain sensitive info, so turn it off
129 # when it's not in use.
130 echo "waiting for 1 dhcp ack then disabling fai server"