37 lines
972 B
Bash
Executable File
37 lines
972 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
set -o pipefail
|
|
|
|
if [ ! -d ".wildcloud" ]; then
|
|
echo "Error: You must run this script from a wild-cloud directory"
|
|
exit 1
|
|
fi
|
|
|
|
WILDCLOUD_ROOT=$(wild-config wildcloud.root) || exit 1
|
|
TEMPLATE_DIR="${WILDCLOUD_ROOT}/central-setup/dnsmasq"
|
|
SETUP_DIR="cluster/dnsmasq"
|
|
|
|
if [ ! -d "${TEMPLATE_DIR}" ]; then
|
|
echo "Error: Template directory not found at ${TEMPLATE_DIR}"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -d "${SETUP_DIR}" ]; then
|
|
echo "Warning: ${SETUP_DIR} already exists"
|
|
read -p "Overwrite? (y/N): " -n 1 -r
|
|
echo
|
|
[[ ! $REPLY =~ ^[Yy]$ ]] && exit 1
|
|
rm -rf "${SETUP_DIR}"
|
|
fi
|
|
|
|
# Copy and process templates
|
|
cp -r "${TEMPLATE_DIR}" "${SETUP_DIR}"
|
|
|
|
find "${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."
|