# Scripts to setup the environment for the install
+arch-pxe # Setup arch pxe boot server from an arch base image
fai-redep # Deploy fai configuration to host "faiserver"
faiserver-revm # using pxe & preseed, create a vm which is a fai server
faiserver-uninstall # uninstall fai-server
export HOSTNAME="$1"
mirror=$2
-TPPASS="$(cat /root/shadow/traci-simple)"
(( $# >= 1 )) || { echo "$0: error: need 1 or 2 arguments"; exit 1; }
if ! $already_partitioned; then
mount -o subvol=root_$DISTRO $ROOT_PARTITION /mnt
- mkdir -p /mnt/{a,home,boot}
- mount -o subvol=a $ROOT_PARTITION /mnt/a
+ mkdir -p /mnt/boot
mount -o subvol=boot_$DISTRO $BOOT_PARTITION /mnt/boot
fi
mount -o bind $source $mountpoint
}
bindmount /root/shadow /mnt/q/root/shadow
+bindmount /a /mnt/a
mkdir -p /mnt/etc/ssh
cp /etc/ssh/ssh_host_* /mnt/etc/ssh
root=/dev/mapper/crypt_dev_${first_root_dev##*/}
resume=${first_root_dev%[0-9]}$swapn
)
-extra_encrypt_hooks=()
# If we have more than 1 to decrypt, arch wiki lead me onto
# a sort of hacky way run the encrypt hook multiple times.
-base=/usr/lib/initcpio
-
-
# https://wiki.archlinux.org/index.php/Dm-crypt/Encrypting_an_entire_system#Configuring_mkinitcpio_2
# used to have lvm2 after encrypt for lvm, but not using lvm anymore
for x in encrypt btrfs; do
EOF
echo "$0: FILES:"
grep FILES /etc/mkinitcpio.conf
-k_args="${k_args[*]}"
-echo "$0: grub cmdline additions: $k_args"
+echo "$0: grub cmdline additions: ${k_args[*]}"
sed -ri --follow-symlinks -f - /etc/default/grub <<EOF
-\%$k_args%!s%^ *GRUB_CMDLINE_LINUX_DEFAULT *= *"%\0$k_args %
+\%${k_args[*]}%!s%^ *GRUB_CMDLINE_LINUX_DEFAULT *= *"%\0${k_args[*]} %
EOF
mkinitcpio -p linux
darkhttpd /var/cache/pacman/pkg &
mirror=http://$HOSTNAME:8080
fi
-faid=/a/bin/fai
rsync -rlpthvi --relative /a/bin/fai/ root@$host:/
rsync /a/bin/fai/ root@$host:/a/bin/fai/
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Setup arch pxe boot server from the base image.
-# Requires manually downloading image to /a/opt, and set it's name below.
+#
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+usage() {
+ cat <<EOF
+Usage: ${0##*/}
+Setup arch pxe boot server from the base image
+
+Requires manually downloading image. Image path is hardcoded below to
+/a/opt/image_name. Run pxe-server HOST|default arch to enable it.
+
+-h|--help Print help and exit.
+EOF
+ exit $1
+}
+
+case $1 in
+ -h|--help) usage ;;
+esac
+
+
x="$(readlink -f "$BASH_SOURCE")"
script_dir="${x%/*}"
cd /a/opt
-iso="archlinux-2016.05.01-dual"
+iso="archlinux-2017.02.01-dual"
sfs=$iso/arch/x86_64/airootfs.sfs
rm -rf $iso
ex $iso.iso
s mksquashfs squashfs-root $sfs -comp xz
# file transfer to wrt is slow, so remove some useless files
rm $iso/arch/i686/airootfs.sfs $iso/arch/boot/i686/archiso.img
-c $(dirname $sfs); md5sum ${sfs##*/} > airootfs.md5; b
+pushd $(dirname $sfs); md5sum ${sfs##*/} > airootfs.md5; popd
# seems if you've done a pxe boot, mounted the nfs,
# then shutdown, it's still busy.
# The default settings in the installer expect to find the NFS at /run/archiso/bootmnt
-pxe-server default arch
-
-# background:
-# great documentation at https://wiki.archlinux.org/index.php/PXE
-# background: arch can do netboot like ubuntu etc, but the docs look a little complicated, so fuck it,
-# we use nfs cuz it's easy
+# background: great documentation at
+# https://wiki.archlinux.org/index.php/PXE
+# arch can do netboot like ubuntu etc, but the docs look a little
+# complicated, so fuck it, we use nfs cuz it's easy
rm -rf $iso
s rm -rf squashfs-root
Note, sometimes shutting down the existing demohost vm
fails. Just run again if that happens.
--r Do not reboot.
+-r Do not boot after install is complete
-n Create new qcow2(s) for vm
-h|--help Print help and exit.
new_disk=false
-reboot=true
temp=$(getopt -l help hnr "$@") || usage 1
eval set -- "$temp"
while true; do
case $1 in
-n) new_disk=true; shift ;;
- -r) reboot=false; shift ;;
+ -r) reboot_arg=--noreboot; shift ;;
-h|--help) usage ;;
--) shift; break ;;
*) echo "$0: Internal error!" ; exit 1 ;;
#
# uniq is to stop gtk-warning spam
e s virt-install --os-variant $variant -n $name --pxe -r 2048 --vcpus 1 \
- ${disk_arg[*]} -w bridge=br0,mac=52:54:00:9c:ef:ad \
+ ${disk_arg[*]} -w bridge=br0,mac=52:54:00:9c:ef:ad $reboot_arg \
--graphics spice,listen=0.0.0.0 $console_arg |& grep -v '^ *$' | uniq &
if [[ $SSH_CLIENT ]]; then
##### begin command line parsing ########
-args=()
redep=true
acks=2
wait=false
esac
done
-read host type <<<"$@"
+read -r host type <<<"$@"
case $# in
0|2);;
fai() {
cat <<EOF
-$set_host_tag
dhcp-boot=${host_tag}pxelinux.0,faiserver.lan,faiserver.lan
EOF
}
fi
regex=".*DHCPACK.*$host_regex$"
i=0
- tmp=$(mktemp)
- while (( i != wait_count )) && read line; do
+ while (( i != wait_count )) && read -r line; do
if [[ $line =~ $regex ]]; then
i=$((i+1))
echo $line
# doesn't go into the firmware. build new firmware if you want
# lots of upgrades.
f=(/tmp/opkg-lists/*)
- f=${f[0]}
if ! (( $(date -r $f +%s) + 60*60*24 > $(date +%s) )); then
opkg update
fi