fix various arch issues
[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 # for no pxe server, use a no-op like : or true.
9
10 set -eE -o pipefail
11 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
12
13 if [[ ! $1 ]]; then
14 echo "$0: error: exptected 1 argument of type"
15 fi
16 action=$1
17
18 arch() {
19 plain-tftp
20 cat <<'EOF'
21 dhcp-option-force=209,boot/syslinux/archiso.cfg
22 dhcp-option-force=210,/arch/
23 dhcp-boot=/arch/boot/syslinux/lpxelinux.0
24 EOF
25 }
26
27 plain-tftp() {
28 # if arch was used before, this additionally needs
29 # the tftp link in /mnt/usb to be changed.
30 cat <<'EOF'
31 enable-tftp
32 tftp-root=/mnt/usb/tftpboot
33 dhcp-boot=pxelinux.0
34 EOF
35 }
36
37 fai() {
38 cat <<'EOF'
39 dhcp-boot=fai/pxelinux.0,faiserver.lan,faiserver.lan
40 EOF
41 }
42
43
44 $action | ssh wrt "cedit pxe-server /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart
45 if [[ $action == arch ]]; then arch-pxe-mount; fi"