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.
19 # Requires manually downloading image to /a/opt, and set it's name below.
22 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
24 x
="$(readlink -f "$BASH_SOURCE")"
27 iso
="archlinux-2016.05.01-dual"
28 sfs
=$iso/arch
/x86_64
/airootfs.sfs
31 sed -i --follow-symlinks -f - $iso/arch
/boot
/syslinux
/archiso_pxe64.cfg
<<EOF
33 /^LABEL arch64_nfs/a menu default
34 s/^APPEND .*/\0 script=arch-iso-init/
36 # based on https://blog.chendry.org/2015/02/06/automating-arch-linux-installation.html
37 # and https://wiki.archlinux.org/index.php/Remastering_the_Install_ISO
39 s
rm -rf squashfs-root
# remove any existing folder
41 s mkdir
-p squashfs-root
/root
/.
ssh
42 s
chmod 755 squashfs-root
/root
/.
ssh
43 s
cp ~
/.ssh
/id_rsa.pub squashfs-root
/root
/.ssh
/authorized_keys
45 s
cp $script_dir/arch-iso-init squashfs-root
/root
47 s mksquashfs squashfs-root
$sfs -comp xz
48 # file transfer to wrt is slow, so remove some useless files
49 rm $iso/arch
/i686
/airootfs.sfs
$iso/arch
/boot
/i686
/archiso.img
50 c $
(dirname $sfs); md5sum ${sfs##*/} > airootfs.md5
; b
52 # seems if you've done a pxe boot, mounted the nfs,
53 # then shutdown, it's still busy.
54 ssh wrt
"/etc/init.d/nfsd stop; \
55 { ! mount | grep /run/archiso/bootmnt || umount /run/archiso/bootmnt; } && \
57 scp
-r $iso wrt
:/mnt
/usb
58 ssh wrt
"cd /mnt/usb && rm -f tftpboot && ln -s $iso tftpboot"
60 # The default settings in the installer expect to find the NFS at /run/archiso/bootmnt
62 pxe-server default arch
65 # great documentation at https://wiki.archlinux.org/index.php/PXE
66 # background: arch can do netboot like ubuntu etc, but the docs look a little complicated, so fuck it,
67 # we use nfs cuz it's easy
70 s
rm -rf squashfs-root