QOL improvements to scripts and script

This commit is contained in:
Joshua Boniface 2023-09-01 15:41:55 -04:00
parent a2cb5a6fec
commit 4cf98e06a7
2 changed files with 19 additions and 14 deletions

View File

@ -27,7 +27,7 @@ srcliveisofilename="$( wget -O- ${srcliveisopath}/ | grep 'debian-live-.*-amd64-
srcliveisourl="${srcliveisopath}/${srcliveisofilename}" srcliveisourl="${srcliveisopath}/${srcliveisofilename}"
show_help() { show_help() {
echo -e "PVC install ISO generator" echo -e "PVC install ISO generator"
echo echo
echo -e " Generates a mostly-automated installer ISO for a PVC node base system. The ISO" echo -e " Generates a mostly-automated installer ISO for a PVC node base system. The ISO"
echo -e " boots, then runs 'install.sh' to perform the installation to a target server." echo -e " boots, then runs 'install.sh' to perform the installation to a target server."
@ -54,11 +54,11 @@ while getopts "h?o:s:a" opt; do
exit 0 exit 0
;; ;;
o) o)
isofilename=$OPTARG isofilename=$OPTARG
;;
s)
srcliveisourl=$OPTARG
;; ;;
s)
srcliveisourl=$OPTARG
;;
a) a)
usecachedsquashfs='y' usecachedsquashfs='y'
;; ;;
@ -99,7 +99,7 @@ prepare_iso() {
echo -n "Extracting Debian Live ISO files... " echo -n "Extracting Debian Live ISO files... "
iso_tempdir=$( mktemp -d ) iso_tempdir=$( mktemp -d )
sudo mount artifacts/${srcliveisofile} ${iso_tempdir} &>/dev/null || fail "Error mounting Live ISO file." sudo mount artifacts/${srcliveisofile} ${iso_tempdir} &>/dev/null || fail "Error mounting Live ISO file."
sudo rsync -au --exclude live/filesystem.squashfs ${iso_tempdir}/ ${tempdir}/installer/ &>/dev/null || fail "Error extracting Live ISO files." sudo rsync -au --exclude live/filesystem.squashfs ${iso_tempdir}/ ${tempdir}/installer/ &>/dev/null || fail "Error extracting Live ISO files."
sudo umount ${iso_tempdir} &>/dev/null || fail "Error unmounting Live ISO file." sudo umount ${iso_tempdir} &>/dev/null || fail "Error unmounting Live ISO file."
rmdir ${iso_tempdir} &>/dev/null rmdir ${iso_tempdir} &>/dev/null
echo "done." echo "done."
@ -129,7 +129,8 @@ prepare_rootfs() {
sudo tee ${tempdir}/rootfs/etc/resolv.conf <<<"nameserver 8.8.8.8" &>/dev/null || fail "Error setting resolv.conf" sudo tee ${tempdir}/rootfs/etc/resolv.conf <<<"nameserver 8.8.8.8" &>/dev/null || fail "Error setting resolv.conf"
sudo tee -a ${tempdir}/rootfs/root/.bashrc <<<"/install.sh" &>/dev/null || fail "Error setting bashrc." sudo tee -a ${tempdir}/rootfs/root/.bashrc <<<"/install.sh" &>/dev/null || fail "Error setting bashrc."
sudo chroot ${tempdir}/rootfs/ /usr/bin/passwd -d root &>/dev/null || fail "Error disabling root password." sudo chroot ${tempdir}/rootfs/ /usr/bin/passwd -d root &>/dev/null || fail "Error disabling root password."
sudo cp install.sh ${tempdir}/rootfs/ &>/dev/null || fail "Error copying install.sh to tempdir." sudo cp install.sh ${tempdir}/rootfs/ &>/dev/null || fail "Error copying install.sh to tempdir."
sudo sed -i "s/XXISOXX/${isofilename}/g" ${tempdir}/rootfs/install.sh &>/dev/null || fail "Error editing install.sh script."
echo "done." echo "done."
echo -n "Generating squashfs image of live installation... " echo -n "Generating squashfs image of live installation... "

View File

@ -12,16 +12,19 @@ debpkglist="lvm2,parted,gdisk,grub-pc,grub-efi-amd64,linux-image-amd64,sudo,vim,
clear clear
echo "------------------------------------------------" echo "-----------------------------------------------------"
echo "| Preparing to install a PVC node base system. |" echo "| PVC Node installer (XXISOXX) |"
echo "------------------------------------------------" echo "-----------------------------------------------------"
echo
echo "This LiveCD will install a PVC node base system ready for bootstrapping with 'pvc-ansible'."
echo echo
echo "NOTE: If you make a mistake and need to restart the installer while answering" echo "NOTE: If you make a mistake and need to restart the installer while answering"
echo " the questions below, you may do so by typing ^C to cancel the script," echo " the questions below, you may do so by typing ^C to cancel the script,"
echo " then re-running it by calling /install.sh in the resulting shell." echo " then re-running it by calling /install.sh in the resulting shell."
echo echo
echo "1) Please enter a fully-qualified hostname for the system." echo "1) Please enter a fully-qualified hostname for the system. This should match the hostname"
echo "in the 'pvc-ansible' inventory."
while [[ -z ${target_hostname} ]]; do while [[ -z ${target_hostname} ]]; do
echo echo
echo -n "> " echo -n "> "
@ -46,7 +49,8 @@ disks="$(
echo "2) Please enter the disk to install the PVC base system to. This disk will be" echo "2) Please enter the disk to install the PVC base system to. This disk will be"
echo "wiped, an LVM PV created on it, and the system installed to this LVM." echo "wiped, an LVM PV created on it, and the system installed to this LVM."
echo "NOTE: PVC requires a disk of >16GB to be installed to. 32GB is the recommended minimum." echo "NOTE: PVC requires a disk of >16GB to be installed to. 32GB is the recommended"
echo "minimum size, and disks larger than 64GB are not particularly useful."
echo echo
echo "Available disks:" echo "Available disks:"
echo echo
@ -71,8 +75,8 @@ interfaces="$(
ip address | grep '^[0-9]' | grep 'eno\|enp\|ens\|wlp' | awk '{ print $2"\t"$3 }' | tr -d ':' ip address | grep '^[0-9]' | grep 'eno\|enp\|ens\|wlp' | awk '{ print $2"\t"$3 }' | tr -d ':'
)" )"
echo "3a) Please enter the primary network interface for external connectivity. If" echo "3a) Please enter the primary network interface for external connectivity. If"
echo " no entries are shown here, ensure a cable is connected, then restart the" echo "no entries are shown here, ensure a cable is connected, then restart the"
echo " installer." echo "installer."
echo echo
echo "Available interfaces:" echo "Available interfaces:"
echo echo