Refactor dnsmasq setup logic in installation scripts
This commit is contained in:
@@ -10,13 +10,40 @@ WILDCLOUD_ROOT=$(wild-config wildcloud.root) || exit 1
|
|||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
# Create setup bundle.
|
SOURCE_DIR="${WILDCLOUD_ROOT}/setup/dnsmasq"
|
||||||
|
DNSMASQ_SETUP_DIR="${WC_HOME}/setup/dnsmasq"
|
||||||
DNSMASQ_SETUP_DIR="${WC_ROOT}/setup/dnsmasq"
|
|
||||||
BUNDLE_DIR="${DNSMASQ_SETUP_DIR}/setup-bundle"
|
BUNDLE_DIR="${DNSMASQ_SETUP_DIR}/setup-bundle"
|
||||||
mkdir -p "${BUNDLE_DIR}"
|
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.
|
# Copy iPXE bootloader to ipxe-web.
|
||||||
echo "Copying Talos kernel and initramfs for PXE boot..."
|
echo "Copying Talos kernel and initramfs for PXE boot..."
|
||||||
PXE_WEB_ROOT="${BUNDLE_DIR}/ipxe-web"
|
PXE_WEB_ROOT="${BUNDLE_DIR}/ipxe-web"
|
||||||
|
@@ -10,38 +10,6 @@ fi
|
|||||||
|
|
||||||
WILDCLOUD_ROOT=$(wild-config wildcloud.root) || exit 1
|
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
|
# Cluster-nodes
|
||||||
|
|
||||||
if [ -d "${DEST_DIR}/cluster-nodes" ]; then
|
if [ -d "${DEST_DIR}/cluster-nodes" ]; then
|
||||||
|
Reference in New Issue
Block a user