Introduce fickit-deploy image

This commit is contained in:
nemunaire 2023-07-25 06:42:42 +02:00
commit 4fb0c11736
7 changed files with 229 additions and 15 deletions

View file

@ -53,30 +53,57 @@ files:
ip link set eth0 up
udhcpc -i eth0
# /proc/cmdline parser (from Gentoo Wiki)
cmdline() {
local value
value=" $(cat /proc/cmdline) "
value="${value##* $1=}"
value="${value%% *}"
[ "$value" != "" ] && echo "$value"
}
# Retrieve metadata
wget -O /tmp/metadata.iso "$(ip r | grep default | awk '{ print $3 }')/fickit-metadata.iso"
mount /tmp/metadata.iso /mnt
/usr/bin/metadata -v file=/mnt/user-data
# Try to detect backend/frontend setup
if ip l | grep eth3 > /dev/null
AUTOPREPARE=$(cmdline fickit.autoprepare)
if [ -z "${AUTOPREPARE}" ]
then
# Try to detect backend/frontend setup
if ip l | grep -q eth3
then
DEFAULT_BOOT=1
echo -n "Detected: FRONTEND host "
else
DEFAULT_BOOT=0
echo -n "Detected: BACKEND host "
fi
[ "${RAID}" -eq 1 ] && echo "with RAID setup" || echo "without raid"
echo
read -p "Proceed? (y/N/Front/Back) " V
if [ "$V" == "F" ] || [ "$V" == "f" ]; then
DEFAULT_BOOT=1
elif [ "$V" == "B" ] || [ "$V" == "b" ]; then
DEFAULT_BOOT=0
elif [ "$V" != "y" ]; then
while true; do
/bin/ash
done
fi
elif [ "${AUTOPREPARE}" == "backend" ]
then
DEFAULT_BOOT=1
echo -n "Detected: FRONTEND host "
elif [ "${AUTOPREPARE}" == "frontend" ]
then
DEFAULT_BOOT=0
else
DEFAULT_BOOT=0
echo -n "Detected: BACKEND host "
fi
echo
echo "Invalid fickit.autoprepare value: got $AUTOPREPARE, expected frontend or backend."
echo
[ "${RAID}" -eq 1 ] && echo "with RAID setup" || echo "without raid"
echo
read -p "Proceed? (y/N/Front/Back) " V
if [ "$V" == "F" ] || [ "$V" == "f" ]; then
DEFAULT_BOOT=1
elif [ "$V" == "B" ] || [ "$V" == "b" ]; then
DEFAULT_BOOT=0
elif [ "$V" != "y" ]; then
while true; do
/bin/ash
done