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.
29 ##### begin command line parsing ########
37 -p) persist
=true
; shift ;;
38 *) args
+=("$1"); shift ;;
44 read type host <<<"${args[@]}"
46 if [[ ! $type ]]; then
47 echo "$0: error: exptected 1 argument of type"
56 :|true
) persist
=true
;;
59 ##### end command line parsing ########
68 dhcp-option-force=209,boot/syslinux/archiso.cfg
69 dhcp-option-force=210,/arch/
70 dhcp-boot=${host_tag}/arch/boot/syslinux/lpxelinux.0
75 # if arch was used before, this additionally needs
76 # the tftp link in /mnt/usb to be changed.
78 dhcp-boot=${host_tag}pxelinux.0
85 dhcp-boot=${host_tag}fai/pxelinux.0,faiserver.lan,faiserver.lan
89 echo "setting config type: $type"
90 $type |
ssh wrt
"cedit pxe-server /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart #
91 if [[ $type == arch ]]; then arch-pxe-mount; fi"
98 regex
=".*DHCPACK.*$host_regex$"
101 while (( i
!= 2 )) && read line
; do
102 if [[ $line =~
$regex ]]; then
106 done < <(ssh wrt logread
-f)