From 8e03db3bbbb420bc36be95f4551dee073b86e787 Mon Sep 17 00:00:00 2001 From: 57_Wolve <57_wolve@private.email> Date: Mon, 19 Jan 2026 17:47:55 +0000 Subject: [PATCH] Update multiplane.sh --- multiplane.sh | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/multiplane.sh b/multiplane.sh index c1e0a7e..6a6f8d2 100644 --- a/multiplane.sh +++ b/multiplane.sh @@ -2,7 +2,7 @@ set -e -CONFIG_FILE="${1:-config-test.yaml}" +CONFIG_FILE="${1:-config.yaml}" if [[ "$EUID" -ne 0 ]]; then echo -e "\e[31m[FATAL]\e[39m Currently this script requires being ran as root user - please try again as root." @@ -55,7 +55,7 @@ validate_ipv4() { get_mac_address() { local mac while true; do - mac=$(gum input --placeholder "MAC Address (e.g., BC:24:AC:76:96:DE)") + mac=$(gum input --placeholder "MAC Address (e.g., BC:24:AC:76:96:DE)") || exit 130 if validate_mac "$mac"; then echo "$mac" @@ -70,7 +70,7 @@ get_mac_address() { get_ipv4_address() { local ip while true; do - ip=$(gum input --placeholder "IPv4 Address (e.g., 10.1.0.14)") + ip=$(gum input --placeholder "IPv4 Address (e.g., 10.1.0.14)") || exit 130 if validate_ipv4 "$ip"; then echo "$ip" @@ -82,13 +82,13 @@ get_ipv4_address() { } clear; echo "Enter a cluster hostname. (e.g., cluster.local)"; -yq -i -oy ".k0s.hostname = \"$(gum input --placeholder "cluster.local" --prompt "* " --width 80 --value "$(yq '.k0s.hostname' $CONFIG_FILE)")\"" "$CONFIG_FILE" +HOSTNAME=$(gum input --placeholder "cluster.local" --prompt "* " --width 80 --value "$(yq '.k0s.hostname' $CONFIG_FILE)") && yq -i -oy ".k0s.hostname = \"$HOSTNAME\"" "$CONFIG_FILE" || exit 0 clear; echo "Enter a cluster IP subnet. (e.g., 10.1.0.0/24)"; -yq -i -oy ".k0s.private_ip_range = \"$(gum input --placeholder "10.1.0.0/24" --prompt "* " --width 80 --value "$(yq '.k0s.private_ip_range' $CONFIG_FILE)")\"" "$CONFIG_FILE" +PRIVATE_IP_RANGE=$(gum input --placeholder "10.1.0.0/24" --prompt "* " --width 80 --value "$(yq '.k0s.private_ip_range' $CONFIG_FILE)") && yq -i -oy ".k0s.private_ip_range = \"$PRIVATE_IP_RANGE\"" "$CONFIG_FILE" || exit 0 clear; echo "Enter a public IP subnet. (e.g., 192.168.0.0/24)"; -yq -i -oy ".metallb.public_ip_range = \"$(gum input --placeholder "192.168.0.0/24" --prompt "* " --width 80 --value "$(yq '.metallb.public_ip_range' $CONFIG_FILE)")\"" "$CONFIG_FILE" +PUBLIC_IP_RANGE=$(gum input --placeholder "192.168.0.0/24" --prompt "* " --width 80 --value "$(yq '.k0s.public_ip_range' $CONFIG_FILE)") && yq -i -oy ".k0s.public_ip_range = \"$PUBLIC_IP_RANGE\"" "$CONFIG_FILE" || exit 0 # Initialize array to store entries declare -a entries @@ -96,51 +96,56 @@ declare -a entries # Proxy node entry (2 nodes required) clear; gum style --border double --padding "1 2" --border-foreground 212 "Proxy Configuration (2 Required)"; sleep 3 +trap 'clear; echo -e "\nExiting..."; exit 130' INT for i in 1 2; do clear; gum style --border double --padding "1 2" --border-foreground 212 "Proxy Node $i/2" # Get MAC address - mac=$(get_mac_address) + mac=$(get_mac_address) || exit 130 # Get IPv4 address - ip=$(get_ipv4_address) + ip=$(get_ipv4_address) || exit 130 # Add entry using yq yq -i -oy ".haproxy.proxy.$i = {\"mac\": \"$mac\", \"ip\": \"$ip\"}" "$CONFIG_FILE" done +trap - INT clear; echo "HAProxy Kuberenetes VIP. (e.g., 10.1.0.10)"; -yq -i -oy ".haproxy.kube.vip = \"$(gum input --placeholder "10.1.0.10" --prompt "* " --width 80 --value "$(yq '.haproxy.kube.vip' $CONFIG_FILE)")\"" "$CONFIG_FILE" +HAPROXY_KUBE_VIP=$(gum input --placeholder "10.1.0.10" --prompt "* " --width 80 --value "$(yq '.haproxy.kube.vip' $CONFIG_FILE)") && yq -i -oy ".haproxy.kube.vip = \"$HAPROXY_KUBE_VIP\"" "$CONFIG_FILE" || exit 0 # Controller node entry (3 nodes required) clear; gum style --border double --padding "1 2" --border-foreground 212 "Controller Node Configuration (3 Required)"; sleep 3 +trap 'clear; echo -e "\nExiting..."; exit 130' INT for i in 1 2 3; do clear; gum style --border double --padding "1 2" --border-foreground 212 "Controller Node $i/3" # Get MAC address - mac=$(get_mac_address) + mac=$(get_mac_address) || exit 130 # Get IPv4 address - ip=$(get_ipv4_address) + ip=$(get_ipv4_address) || exit 130 # Add entry using yq yq -i -oy ".nodes.controller.$i = {\"mac\": \"$mac\", \"ip\": \"$ip\"}" "$CONFIG_FILE" done +trap - INT # Controller node entry (3 nodes required) gum style --border double --padding "1 2" --border-foreground 212 "Worker Node Configuration (3 Required)"; sleep 3 # Add worker node loop count=0 +trap 'clear; echo -e "\nExiting..."; exit 130' INT while [ $count -lt 250 ]; do clear; gum style --border double --padding "1 2" --border-foreground 212 "Worker Node Entry ($(($count + 1))/250)" # Get MAC address - mac=$(get_mac_address) + mac=$(get_mac_address) || exit 130 # Get IPv4 address - ip=$(get_ipv4_address) + ip=$(get_ipv4_address) || exit 130 # Add entry using yq count=$((count+1)) @@ -151,8 +156,9 @@ while [ $count -lt 250 ]; do clear; gum confirm "Add another worker node?" || break fi done +trap - INT # Display results if [ $count -gt 0 ]; then clear; gum style --border double --padding "1 2" --border-foreground 212 "✓ Configuration saved to $CONFIG_FILE" -fi +fi \ No newline at end of file