2021-06-26 13:04:06 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-06-26 20:46:22 +00:00
|
|
|
# Simple script that runs a Rocky Raspberry pi creation (via appliance-creator), then inserts a UUID to the kernel boot line of the image
|
|
|
|
# after-the-fact
|
|
|
|
#
|
|
|
|
# Usage: ./Rocky8_Rpi4_mkimage.sh /path/to/outputfolder/
|
|
|
|
#
|
|
|
|
# Needs to be run in the same directory as the rocky rpi kickstart, as it relies on it!
|
|
|
|
#
|
|
|
|
# Exit with error if we don't have an output directory:
|
2022-06-29 01:57:57 +00:00
|
|
|
|
2021-06-26 14:31:50 +00:00
|
|
|
OUTDIR=$1
|
2022-06-29 01:57:57 +00:00
|
|
|
LOGDIR="logs"
|
|
|
|
LOGFILE="/create_image`date +"%y%m%d"`.log"
|
|
|
|
LOGFILE2="create_image`date +"%y%m%d"`.log.2"
|
2021-06-26 13:04:06 +00:00
|
|
|
|
2022-06-29 01:57:57 +00:00
|
|
|
if [[ -z "${OUTDIR}" ]]; then
|
2021-06-26 20:46:22 +00:00
|
|
|
echo "Need to run this script with a path to output directory. Like: ${0} /path/to/output/"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-06-29 01:57:57 +00:00
|
|
|
if [[ -d ${LOGDIR} ]]; then
|
|
|
|
echo "$LOGDIR exists..."
|
|
|
|
else
|
|
|
|
mkdir -p "${LOGDIR}"
|
|
|
|
touch $LOGDIR/$LOGFILE
|
|
|
|
fi
|
2021-06-26 13:04:06 +00:00
|
|
|
|
2022-06-29 01:57:57 +00:00
|
|
|
if [[ -d ${OUTDIR} ]]; then
|
|
|
|
echo "$OUTDIR exists..."
|
|
|
|
else
|
|
|
|
mkdir -p "${OUTDIR}"
|
|
|
|
fi
|
2021-06-26 13:04:06 +00:00
|
|
|
|
2021-06-26 20:46:22 +00:00
|
|
|
# Actually create the image. Our kickstart data should be in the same git repo as this script:
|
|
|
|
# (This takes a while, especially building on an rpi. Patience!)
|
2022-06-29 01:57:57 +00:00
|
|
|
appliance-creator -v -c ./Rocky8_Rpi4.ks -n RockyRpi \
|
|
|
|
--version=`date +"%Y%m%d"` --release=1 \
|
|
|
|
-d --logfile $LOGDIR/LOGFILE \
|
|
|
|
--vmem=2048 --vcpu=2 --no-compress -o "${OUTDIR}"
|
|
|
|
#chown -R $SUDO_USER. "${OUTDIR}"
|