#!/bin/bash -x # Setup dhcp server to point to tftp server, # and depending on the type, setup the tftp server. # usage: $0 TYPE # default distro is the base debian/fedora type. others are fai & arch set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR if [[ ! $1 ]]; then echo "$0: error: exptected 1 argument of type" fi action=$1 arch() { default cat <<'EOF' dhcp-option-force=209,boot/syslinux/archiso.cfg dhcp-option-force=210,/arch/ dhcp-boot=/arch/boot/syslinux/lpxelinux.0 EOF } plain-tftp() { # if arch was used before, this additionally needs # the tftp link in /mnt/usb to be changed. cat <<'EOF' enable-tftp tftp-root=/mnt/usb/tftpboot dhcp-boot=pxelinux.0 EOF } fai() { cat <<'EOF' dhcp-boot=fai/pxelinux.0,faiserver.lan,faiserver.lan EOF } $action | ssh wrt "cedit pxe-server /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart if [[ $action == arch ]]; then arch-pxe-mount; fi"