Refactor dnsmasq setup logic in installation scripts

This commit is contained in:
2025-06-26 16:32:10 -07:00
parent 81a74e1d0d
commit 8848f5682a
2 changed files with 30 additions and 35 deletions

View File

@@ -10,13 +10,40 @@ WILDCLOUD_ROOT=$(wild-config wildcloud.root) || exit 1
# ---
# Create setup bundle.
DNSMASQ_SETUP_DIR="${WC_ROOT}/setup/dnsmasq"
SOURCE_DIR="${WILDCLOUD_ROOT}/setup/dnsmasq"
DNSMASQ_SETUP_DIR="${WC_HOME}/setup/dnsmasq"
BUNDLE_DIR="${DNSMASQ_SETUP_DIR}/setup-bundle"
mkdir -p "${BUNDLE_DIR}"
# Create local templates.
if [ -d "${DNSMASQ_SETUP_DIR}" ]; then
echo "Warning: ${DNSMASQ_SETUP_DIR}/dnsmasq already exists"
read -p "Overwrite? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Skipping dnsmasq setup"
else
rm -rf "${DNSMASQ_SETUP_DIR}"
cp -r "${SOURCE_DIR}" "${DNSMASQ_SETUP_DIR}"
find "${DNSMASQ_SETUP_DIR}" -type f \( -name "*.yaml" -o -name "*.ipxe" -o -name "*.conf" \) | while read -r file; do
echo "Processing: ${file}"
wild-compile-template < "${file}" > "${file}.tmp" && mv "${file}.tmp" "${file}"
done
echo "Successfully created dnsmasq setup files from templates."
fi
else
cp -r "${SOURCE_DIR}" "${DNSMASQ_SETUP_DIR}"
find "${DNSMASQ_SETUP_DIR}" -type f \( -name "*.yaml" -o -name "*.ipxe" -o -name "*.conf" \) | while read -r file; do
echo "Processing: ${file}"
wild-compile-template < "${file}" > "${file}.tmp" && mv "${file}.tmp" "${file}"
done
echo "Successfully created dnsmasq setup files from templates."
fi
# Create setup bundle.
# Copy iPXE bootloader to ipxe-web.
echo "Copying Talos kernel and initramfs for PXE boot..."
PXE_WEB_ROOT="${BUNDLE_DIR}/ipxe-web"

View File

@@ -10,38 +10,6 @@ fi
WILDCLOUD_ROOT=$(wild-config wildcloud.root) || exit 1
# Dnsmasq
SOURCE_DIR="${WILDCLOUD_ROOT}/setup"
DEST_DIR="setup"
mkdir -p "${DEST_DIR}"
if [ -d "${DEST_DIR}/dnsmasq" ]; then
echo "Warning: ${DEST_DIR}/dnsmasq already exists"
read -p "Overwrite? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Skipping dnsmasq setup"
else
rm -rf "${DEST_DIR}/dnsmasq"
cp -r "${SOURCE_DIR}/dnsmasq" "${DEST_DIR}/dnsmasq"
find "${DEST_DIR}/dnsmasq" -type f \( -name "*.yaml" -o -name "*.ipxe" -o -name "*.conf" \) | while read -r file; do
echo "Processing: ${file}"
wild-compile-template < "${file}" > "${file}.tmp" && mv "${file}.tmp" "${file}"
done
echo "Successfully created dnsmasq setup files from templates."
fi
else
cp -r "${SOURCE_DIR}/dnsmasq" "${DEST_DIR}/dnsmasq"
find "${DEST_DIR}/dnsmasq" -type f \( -name "*.yaml" -o -name "*.ipxe" -o -name "*.conf" \) | while read -r file; do
echo "Processing: ${file}"
wild-compile-template < "${file}" > "${file}.tmp" && mv "${file}.tmp" "${file}"
done
echo "Successfully created dnsmasq setup files from templates."
fi
# Cluster-nodes
if [ -d "${DEST_DIR}/cluster-nodes" ]; then