fix bugs, support multiple distros via subvolumes
[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 $?"' ERR
11
12 action=${1:-default}
13
14 arch() {
15 default
16 cat <<'EOF'
17 dhcp-option-force=209,boot/syslinux/archiso.cfg
18 dhcp-option-force=210,/arch/
19 dhcp-boot=/arch/boot/syslinux/lpxelinux.0
20 EOF
21 }
22
23 default() {
24 cat <<'EOF'
25 enable-tftp
26 tftp-root=/mnt/usb/tftpboot
27 dhcp-boot=pxelinux.0
28 EOF
29 }
30
31 fai() {
32 cat <<'EOF'
33 dhcp-boot=fai/pxelinux.0,faiserver.lan,faiserver.lan
34 EOF
35 }
36
37
38 $action | ssh wrt "cedit pxe-server /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart
39 if [[ $action == arch ]]; then arch-pxe-mount; fi"