Compare commits
No commits in common. "3fb93b8359c4ebfa5cd45bd870421135ce639e47" and "f858d03ff932f52dc126ac6dc46fd01ec68abf28" have entirely different histories.
3fb93b8359
...
f858d03ff9
42
buildiso.sh
42
buildiso.sh
|
@ -32,33 +32,23 @@ show_help() {
|
|||
echo -e " -k: Preserve live-build config."
|
||||
}
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "${1}" in
|
||||
-h|\?)
|
||||
while getopts "h?o:u:ak" opt; do
|
||||
case "$opt" in
|
||||
h|\?)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
-o)
|
||||
isofilename="${2}"
|
||||
shift 2
|
||||
o)
|
||||
isofilename=$OPTARG
|
||||
;;
|
||||
-u)
|
||||
deployusername="${2}"
|
||||
shift 2
|
||||
u)
|
||||
deployusername=$OPTARG
|
||||
;;
|
||||
-a)
|
||||
a)
|
||||
preserve_artifacts='y'
|
||||
shift
|
||||
;;
|
||||
-k)
|
||||
k)
|
||||
preserve_livebuild='y'
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option: ${1}"
|
||||
echo
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
@ -67,12 +57,8 @@ PACKAGE_LIST_MAIN="live-tools linux-image-amd64 mdadm lvm2 parted gdisk debootst
|
|||
PACKAGE_LIST_NONFREE="firmware-bnx2 firmware-bnx2x"
|
||||
|
||||
mkdir -p artifacts/lb
|
||||
pushd artifacts/lb &>/dev/null
|
||||
pushd artifacts/lb
|
||||
|
||||
echo "Pre-cleaning live-build environment..."
|
||||
sudo lb clean
|
||||
|
||||
echo "Initializing config..."
|
||||
# Initialize the live-build config
|
||||
lb config --distribution buster --architectures amd64 --archive-areas "main contrib non-free" --apt-recommends false
|
||||
|
||||
|
@ -137,7 +123,6 @@ sed -i "s/XXDATEXX/$(date)/g" config/includes.chroot/install.sh
|
|||
sed -i "s/XXDEPLOYUSERXX/${deployusername}/g" config/includes.chroot/install.sh
|
||||
|
||||
# Build the live image
|
||||
echo "Building live image..."
|
||||
sudo lb build
|
||||
|
||||
# Move the ISO image out
|
||||
|
@ -145,18 +130,13 @@ cp live-image-amd64.hybrid.iso ../../${isofilename}
|
|||
|
||||
# Clean up the artifacts
|
||||
if [[ -z ${preserve_artifacts} ]]; then
|
||||
echo "Cleaning live-build environment..."
|
||||
sudo lb clean
|
||||
fi
|
||||
|
||||
popd &>/dev/null
|
||||
popd
|
||||
|
||||
# Clean up the config
|
||||
if [[ -z ${preserve_livebuild} ]]; then
|
||||
echo -n "Removing artifacts... "
|
||||
sudo rm -rf artifacts/lb
|
||||
echo "done."
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Build completed. ISO file: ${isofilename}"
|
||||
|
|
147
buildpxe.sh
147
buildpxe.sh
|
@ -1,147 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Generate a PVC autoinstaller PXE configuration
|
||||
|
||||
fail() {
|
||||
echo "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
test -f /usr/lib/PXELINUX/pxelinux.0 &>/dev/null || fail "This script requires pxelinux and syslinux-common"
|
||||
test -f /usr/lib/syslinux/modules/bios/ldlinux.c32 &>/dev/null || fail "This script requires pxelinux and syslinux-common"
|
||||
sudo -n true &>/dev/null || fail "The user running this script must have sudo privileges."
|
||||
|
||||
outputdir="pvc-installer-pxe_$(date +%Y-%m-%d)/"
|
||||
deployusername="deploy"
|
||||
|
||||
show_help() {
|
||||
echo -e "PVC install PXE generator"
|
||||
echo
|
||||
echo -e " Generates a mostly-automated installer PXE image for a PVC node base system."
|
||||
echo -e " This setup is designed to be used with the pvcbootstrapd system; for a normal"
|
||||
echo -e " installation, use buildiso.sh instead."
|
||||
echo
|
||||
echo -e "Usage: $0 [-h] [-o <outputdirectory>] [-u username]"
|
||||
echo
|
||||
echo -e " -h: Display this help message."
|
||||
echo -e " -o: Create the PXE images under <outputdirectory> instead of the default."
|
||||
echo -e " -u: Change 'deploy' user to a new username."
|
||||
echo -e " -a: Preserve live-build artifacts (passed through to buildiso.sh)."
|
||||
echo -e " -k: Preserve live-build config (passed through to buildiso.sh)."
|
||||
echo -e " -i: Preserve live-build ISO image."
|
||||
}
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "${1}" in
|
||||
-h|\?)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
-o)
|
||||
outputdir="${2}"
|
||||
shift 2
|
||||
;;
|
||||
-u)
|
||||
deployusername="${2}"
|
||||
shift 2
|
||||
;;
|
||||
-a)
|
||||
preserve_artifacts='-a'
|
||||
shift
|
||||
;;
|
||||
-k)
|
||||
preserve_livebuild='-k'
|
||||
shift
|
||||
;;
|
||||
-i)
|
||||
preserve_liveiso='y'
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Invalid option: ${1}"
|
||||
echo
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
cleanup() {
|
||||
echo -n "Cleaning up... "
|
||||
echo "done."
|
||||
echo
|
||||
}
|
||||
|
||||
fail() {
|
||||
echo $@
|
||||
cleanup
|
||||
exit 1
|
||||
}
|
||||
|
||||
build_iso() {
|
||||
if [[ ! -f pvc-installer_pxe-tmp.iso ]]; then
|
||||
./buildiso.sh \
|
||||
-o pvc-installer_pxe-tmp.iso \
|
||||
-u ${deployusername} \
|
||||
${preserve_artifacts} \
|
||||
${preserve_livebuild} || fail "Failed to build ISO."
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
build_pxe() {
|
||||
mkdir -p ${outputdir} ${outputdir}/boot
|
||||
|
||||
echo -n "Mounting temporary ISO file... "
|
||||
tmpdir=$( mktemp -d )
|
||||
sudo mount pvc-installer_pxe-tmp.iso ${tmpdir} &>/dev/null
|
||||
echo "done."
|
||||
|
||||
echo -n "Copying live boot files... "
|
||||
cp ${tmpdir}/live/filesystem.squashfs ${outputdir}/
|
||||
cp ${tmpdir}/live/vmlinuz ${outputdir}/
|
||||
cp ${tmpdir}/live/initrd.img ${outputdir}/
|
||||
echo "done."
|
||||
|
||||
echo -n "Unmounting and removing temporary ISO file... "
|
||||
sudo umount ${tmpdir}
|
||||
rmdir ${tmpdir}
|
||||
echo "done."
|
||||
|
||||
echo -n "Creating base iPXE configuration... "
|
||||
cat <<EOF > ${outputdir}/boot.pxe
|
||||
#!ipxe
|
||||
|
||||
# Set global variables
|
||||
set root-url tftp://\${next-server}
|
||||
set host-url tftp://\${next-server}/host
|
||||
|
||||
# Load host/mac-*.ipxe if present (per-host host-args configuration)
|
||||
chain --autofree \${host-url}/mac-\${mac:hexraw}.ipxe ||
|
||||
|
||||
set menu-default pvc-installer
|
||||
set submenu-default pvc-installer
|
||||
|
||||
:pvc-installer
|
||||
kernel \${root-url}/vmlinuz
|
||||
initrd \${root-url}/initrd.img
|
||||
imgargs vmlinuz console=tty0 console=ttyS0,115200n8 boot=live components timezone=America/Toronto fetch=\${root-url}/filesystem.squashfs username=root \${host-args}
|
||||
boot
|
||||
EOF
|
||||
echo "done."
|
||||
|
||||
sudo chown -R $(whoami) ${outputdir}
|
||||
sudo chmod -R u+w ${outputdir}
|
||||
|
||||
if [[ -z ${preserve_liveiso} ]]; then
|
||||
echo -n "Removing temporary ISO... "
|
||||
rm pvc-installer_pxe-tmp.iso &>/dev/null
|
||||
echo "done."
|
||||
fi
|
||||
}
|
||||
|
||||
build_iso
|
||||
build_pxe
|
||||
cleanup
|
||||
|
||||
echo "PVC Live Installer PXE generation complete."
|
Loading…
Reference in New Issue