better error output
[automated-distro-installer] / pxe-server
1 #!/bin/bash -x
2
3 # Setup dhcp server to point to tftp server,
4 # and depending on the type, setup the tftp server.
5
6 # usage: $0 TYPE
7 # default distro is the base debian/fedora type. others are fai & arch
8
9 set -eE -o pipefail
10 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
11
12 if [[ ! $1 ]]; then
13 echo "$0: error: exptected 1 argument of type"
14 fi
15 action=$1
16
17 arch() {
18 default
19 cat <<'EOF'
20 dhcp-option-force=209,boot/syslinux/archiso.cfg
21 dhcp-option-force=210,/arch/
22 dhcp-boot=/arch/boot/syslinux/lpxelinux.0
23 EOF
24 }
25
26 plain-tftp() {
27 # if arch was used before, this additionally needs
28 # the tftp link in /mnt/usb to be changed.
29 cat <<'EOF'
30 enable-tftp
31 tftp-root=/mnt/usb/tftpboot
32 dhcp-boot=pxelinux.0
33 EOF
34 }
35
36 fai() {
37 cat <<'EOF'
38 dhcp-boot=fai/pxelinux.0,faiserver.lan,faiserver.lan
39 EOF
40 }
41
42
43 $action | ssh wrt "cedit pxe-server /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart
44 if [[ $action == arch ]]; then arch-pxe-mount; fi"