Script fixes.

This commit is contained in:
2025-10-04 08:28:01 -07:00
parent 482cebc603
commit 748ae1a70b
6 changed files with 17 additions and 126 deletions

View File

@@ -62,7 +62,7 @@ prompt_if_unset_config "cluster.nodes.talos.version" "Talos version" "v1.11.0"
TALOS_VERSION=$(wild-config "cluster.nodes.talos.version")
# Talos schematic ID
prompt_if_unset_config "cluster.nodes.talos.schematicId" "Talos schematic ID" "56774e0894c8a3a3a9834a2aea65f24163cacf9506abbcbdc3ba135eaca4953f"
prompt_if_unset_config "cluster.nodes.talos.schematicId" "Talos schematic ID" "434a0300db532066f1098e05ac068159371d00f0aba0a3103a0e826e83825c82"
SCHEMATIC_ID=$(wild-config "cluster.nodes.talos.schematicId")
print_info "Creating custom Talos installer image..."

View File

@@ -32,13 +32,17 @@ else
init_wild_env
fi
# ---
# Config
prompt_if_unset_config "cloud.dns.ip" "The IP address of your wild cloud DNS server" ""
prompt_if_unset_config "cloud.dnsmasq.interface" "The network interface for your wild cloud DNS server" "eth0"
prompt_if_unset_config "cluster.loadBalancerIp" "The IP address for your cluster load balancer" ""
prompt_if_unset_config "cloud.router.ip" "The IP address for your LAN router" "192.168.8.1"
prompt_if_unset_config "cloud.dhcpRange" "The DHCP range for your wild cloud network" ""
SOURCE_DIR="${WC_ROOT}/setup/dnsmasq"
DNSMASQ_SETUP_DIR="${WC_HOME}/setup/dnsmasq"
BUNDLE_DIR="${DNSMASQ_SETUP_DIR}/setup-bundle"
mkdir -p "${BUNDLE_DIR}"
# Create local templates.
@@ -58,6 +62,7 @@ if [ -d "${DNSMASQ_SETUP_DIR}" ]; then
echo "Successfully created dnsmasq setup files from templates."
fi
else
mkdir -p "${BUNDLE_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}"
@@ -65,6 +70,7 @@ else
done
echo "Successfully created dnsmasq setup files from templates."
fi
mkdir -p "${BUNDLE_DIR}"
# Create setup bundle.

View File

@@ -102,14 +102,15 @@ prompt_if_unset_config "cloud.internalDomain" "Your internal cloud domain" "inte
prompt_if_unset_config "cloud.backup.root" "Existing path to save backups to" ""
# Derive cluster name from domain if not already set
current_cluster_name=$(wild-config "cluster.name")
if [ -z "$current_cluster_name" ] || [ "$current_cluster_name" = "null" ]; then
if wild-config "cluster.name" --check; then
echo "Cluster name: $(wild-config "cluster.name")"
else
echo "Cluster name is already set to: $(wild-config "cluster.name")"
cluster_name=$(echo "${domain}" | tr '.' '-' | tr '[:upper:]' '[:lower:]')
wild-config-set "cluster.name" "${cluster_name}"
print_info "Set cluster name to: ${cluster_name}"
fi
# =============================================================================
# COPY SCAFFOLD
# =============================================================================

View File

@@ -112,7 +112,7 @@ print_info "Cluster: $CLUSTER_NAME"
# NODE DETECTION
# =============================================================================
print_header "Node Detection: $NODE_NAME"
print_info "Detecting node: $NODE_NAME"
# Get target IP for detection
if wild-config --check "cluster.nodes.active.${NODE_NAME}.targetIp"; then

View File

@@ -1,116 +0,0 @@
#!/bin/bash
# Talos schematic management script
# This script manages Talos Image Factory schematics centrally
# Usage: wild-talos-schema [--force]
set -euo pipefail
# Initialize Wild Cloud environment
if [ -z "${WC_ROOT}" ]; then
print "WC_ROOT is not set."
exit 1
else
source "${WC_ROOT}/scripts/common.sh"
init_wild_env
fi
CONFIG_FILE="${WC_HOME}/config.yaml"
FORCE_UPLOAD=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--force)
FORCE_UPLOAD=true
shift
;;
-h|--help)
echo "Usage: wild-talos-schema [--force]"
echo ""
echo "Manages Talos Image Factory schematics centrally."
echo ""
echo "Options:"
echo " --force Force re-upload even if schematicId already exists"
echo " -h, --help Show this help message"
echo ""
echo "This script:"
echo " 1. Reads schematic from config.yaml (.cluster.nodes.talos.schematic)"
echo " 2. Uploads it to Image Factory if needed"
echo " 3. Stores the schematicId in config.yaml (.cluster.nodes.talos.schematicId)"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
echo "Managing Talos schematic for wildcloud..."
# Check if schematic exists in config.yaml
if ! yq eval '.cluster.nodes.talos.schematic' "$CONFIG_FILE" | grep -v "null" >/dev/null 2>&1; then
echo "Error: No schematic found in config.yaml at .cluster.nodes.talos.schematic"
echo "Expected schematic configuration with systemExtensions"
exit 1
fi
# Check if schematicId already exists (unless force)
EXISTING_ID=$(yq eval '.cluster.nodes.talos.schematicId // ""' "$CONFIG_FILE")
if [ -n "$EXISTING_ID" ] && [ "$FORCE_UPLOAD" = false ]; then
echo "✅ Schematic ID already exists: $EXISTING_ID"
echo "Use --force to re-upload and generate a new ID"
exit 0
fi
echo "Extracting schematic from config.yaml..."
# Create temporary schematic file
TEMP_SCHEMATIC=$(mktemp)
trap "rm -f $TEMP_SCHEMATIC" EXIT
# Extract schematic from config.yaml
yq eval '.cluster.nodes.talos.schematic' "$CONFIG_FILE" > "$TEMP_SCHEMATIC"
echo "Schematic contents:"
cat "$TEMP_SCHEMATIC"
echo ""
# Upload schematic to Image Factory
echo "Uploading schematic to Talos Image Factory..."
SCHEMATIC_RESPONSE=$(curl -s -X POST --data-binary @"$TEMP_SCHEMATIC" https://factory.talos.dev/schematics)
if [ -z "$SCHEMATIC_RESPONSE" ]; then
echo "Error: Failed to upload schematic to Image Factory"
exit 1
fi
# Parse schematic ID from JSON response
SCHEMATIC_ID=$(echo "$SCHEMATIC_RESPONSE" | sed 's/.*"id":"\([^"]*\)".*/\1/')
if [ -z "$SCHEMATIC_ID" ] || [ "$SCHEMATIC_ID" = "$SCHEMATIC_RESPONSE" ]; then
echo "Error: Failed to parse schematic ID from response: $SCHEMATIC_RESPONSE"
exit 1
fi
echo "✅ Schematic uploaded successfully!"
echo "Schematic ID: $SCHEMATIC_ID"
# Update config.yaml with schematic ID
echo "Updating config.yaml with schematic ID..."
yq eval ".cluster.nodes.talos.schematicId = \"$SCHEMATIC_ID\"" -i "$CONFIG_FILE"
echo ""
echo "🎉 Schematic management complete!"
echo ""
echo "Schematic ID: $SCHEMATIC_ID"
echo "Saved to: config.yaml (.cluster.nodes.talos.schematicId)"
echo ""
echo "This schematic includes:"
yq eval '.cluster.nodes.talos.schematic.customization.systemExtensions.officialExtensions[]' "$CONFIG_FILE" | sed 's/^/ - /'
echo ""
echo "Other scripts can now use this schematicId:"
echo " - setup/dnsmasq/bin/create-setup-bundle.sh (PXE boot assets)"
echo " - setup/cluster-nodes/create-installer-image.sh (custom installer)"

View File

@@ -54,9 +54,9 @@ print_info() {
print_warning() {
if [ "$1" = "-n" ]; then
echo -ne "${YELLOW}⚠️${NC} $2"
echo -ne "${YELLOW}⚠️ ${NC} $2"
else
echo -e "${YELLOW}⚠️${NC} $1"
echo -e "${YELLOW}⚠️ ${NC} $1"
fi
}