2 # Copyright (C) 2016 Ian Kelling
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Setup arch pxe boot server from the base image.
22 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
27 Setup arch pxe boot server from the base image
29 Requires manually downloading image. Image path is hardcoded below to
30 /a/opt/image_name without .iso on the end. adjust the code for a new image. After this, run pxe-server.
31 HOST|default arch to enable it.
33 -h|--help Print help and exit.
43 x
="$(readlink -f "$BASH_SOURCE")"
46 iso
="parabola-systemd-cli-x86_64-netinstall-2017.10.18-00.07-alpha"
50 if [[ ! -e $iso/parabola
]]; then
53 sfs
=$iso/$n/x86_64
/*.sfs
55 sed -i --follow-symlinks -f - $iso/$n/boot
/syslinux
/${n}iso_pxe64.cfg
<<EOF
57 /^LABEL arch64_nfs/a menu default
58 s/^APPEND .*/\0 script=arch-iso-init/
60 # based on https://blog.chendry.org/2015/02/06/automating-arch-linux-installation.html
61 # and https://wiki.archlinux.org/index.php/Remastering_the_Install_ISO
63 s
rm -rf squashfs-root
# remove any existing folder
65 s mkdir
-p squashfs-root
/root
/.
ssh
66 s
chmod 755 squashfs-root
/root
/.
ssh
67 s
cp ~
/.ssh
/id_rsa.pub squashfs-root
/root
/.ssh
/authorized_keys
69 s
cp $script_dir/arch-iso-init squashfs-root
/root
71 s mksquashfs squashfs-root
$sfs -comp xz
72 # file transfer to wrt is slow, so remove some useless files
73 rm -f $iso/$n/i686
/airootfs.sfs
$iso/$n/boot
/i686
/${n}iso.img
74 pushd $
(dirname $sfs); md5sum ${sfs##*/} > airootfs.md5
; popd
76 # seems if you've done a pxe boot, mounted the nfs,
77 # then shutdown, it's still busy.
78 ssh wrt
"/etc/init.d/nfsd stop; \
79 { ! mount | grep /run/archiso/bootmnt || umount /run/archiso/bootmnt; } && \
81 scp
-r $iso wrt
:/mnt
/usb
82 ssh wrt
"cd /mnt/usb && rm -f tftpboot && ln -s $iso tftpboot"
84 # The default settings in the installer expect to find the NFS at /run/archiso/bootmnt
86 # background: great documentation at
87 # https://wiki.archlinux.org/index.php/PXE
88 # arch can do netboot like ubuntu etc, but the docs look a little
89 # complicated, so fuck it, we use nfs cuz it's easy
92 s
rm -rf squashfs-root