Update multiplane.sh

This commit is contained in:
2026-01-19 20:50:24 +00:00
parent 4bc1b9a99b
commit b961a26cdd

View File

@@ -60,12 +60,12 @@ get_mac_address() {
while true; do
if [[ -z "$io" ]]; then
mac=$(gum input --placeholder "MAC Address (e.g., BC:24:AC:76:96:DE)" $STYLE_SETTING1) || exit 130
mac=$(gum input --header "MAC Address (e.g., BC:24:AC:76:96:DE)" --placeholder "XX:XX:XX:XX:XX:XX" $STYLE_SETTING1) || exit 130
else
if [[ -z "$(yq $io $CONFIG_FILE)" ]]; then
mac=$(gum input --placeholder "MAC Address (e.g., BC:24:AC:76:96:DE)" $STYLE_SETTING1) || exit 130
mac=$(gum input --header "MAC Address (e.g., BC:24:AC:76:96:DE)" --placeholder "XX:XX:XX:XX:XX:XX" $STYLE_SETTING1) || exit 130
else
mac=$(gum input --placeholder "MAC Address (e.g., BC:24:AC:76:96:DE)" $STYLE_SETTING1 --value "$(yq $io $CONFIG_FILE)") && yq -i -oy "$io = \"$mac\"" "$CONFIG_FILE" || exit 130
mac=$(gum input --header "MAC Address (e.g., BC:24:AC:76:96:DE)" --placeholder "XX:XX:XX:XX:XX:XX" $STYLE_SETTING1 --value "$(yq $io $CONFIG_FILE)") && yq -i -oy "$io = \"$mac\"" "$CONFIG_FILE" || exit 130
fi
fi
@@ -85,12 +85,12 @@ get_ipv4_address() {
while true; do
if [[ -z "$io" ]]; then
ip=$(gum input --placeholder "IPv4 Address (e.g., 10.1.0.14)" $STYLE_SETTING1) || exit 130
ip=$(gum input --header "IPv4 Address (e.g., 10.1.0.14)" --placeholder "X.X.X.X" $STYLE_SETTING1) || exit 130
else
if [[ -z "$(yq $io $CONFIG_FILE)" ]]; then
ip=$(gum input --placeholder "IPv4 Address (e.g., 10.1.0.14)" $STYLE_SETTING1) || exit 130
ip=$(gum input --header "IPv4 Address (e.g., 10.1.0.14)" --placeholder "X.X.X.X" $STYLE_SETTING1) || exit 130
else
ip=$(gum input --placeholder "IPv4 Address (e.g., 10.1.0.14))" $STYLE_SETTING1 --value "$(yq $io $CONFIG_FILE)") && yq -i -oy "$io = \"$ip\"" "$CONFIG_FILE" || exit 130
ip=$(gum input --header "IPv4 Address (e.g., 10.1.0.14)" --placeholder "X.X.X.X" $STYLE_SETTING1 --value "$(yq $io $CONFIG_FILE)") && yq -i -oy "$io = \"$ip\"" "$CONFIG_FILE" || exit 130
fi
fi
@@ -105,20 +105,17 @@ get_ipv4_address() {
config_setup() {
clear; echo "Enter a cluster hostname. (e.g., cluster.local)";
HOSTNAME=$(gum input --placeholder "cluster.local" --prompt "* " $STYLE_SETTING1 --value "$(yq '.k0s.hostname' $CONFIG_FILE)") && yq -i -oy ".k0s.hostname = \"$HOSTNAME\"" "$CONFIG_FILE" || exit 0
clear; HOSTNAME=$(gum input --header "Enter a cluster hostname. (e.g., cluster.local)" --placeholder "cluster.local" --prompt "* " $STYLE_SETTING1 --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)";
PRIVATE_IP_RANGE=$(gum input --placeholder "10.1.0.0/24" --prompt "* " $STYLE_SETTING1 --value "$(yq '.k0s.private_ip_range' $CONFIG_FILE)") && yq -i -oy ".k0s.private_ip_range = \"$PRIVATE_IP_RANGE\"" "$CONFIG_FILE" || exit 0
clear; PRIVATE_IP_RANGE=$(gum input --header "Enter a cluster IP subnet. (e.g., 10.1.0.0/24)" --placeholder "10.1.0.0/24" --prompt "* " $STYLE_SETTING1 --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)";
PUBLIC_IP_RANGE=$(gum input --placeholder "192.168.0.0/24" --prompt "* " $STYLE_SETTING1 --value "$(yq '.k0s.public_ip_range' $CONFIG_FILE)") && yq -i -oy ".k0s.public_ip_range = \"$PUBLIC_IP_RANGE\"" "$CONFIG_FILE" || exit 0
clear; PUBLIC_IP_RANGE=$(gum input --header "Enter a public IP subnet. (e.g., 192.168.0.0/24" --placeholder "192.168.0.0/24" --prompt "* " $STYLE_SETTING1 --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
# Proxy node entry (2 nodes required)
clear; gum style --border double --padding "1 2" $STYLE_SETTING2 "Proxy Configuration (2 Required)"; gum spin --spinner dot --title "Waiting..." -- sleep 2
clear; gum style --border double --padding "1 2" $STYLE_SETTING2 "Proxy Configuration (2 Required)"; gum spin --spinner dot --spinner.foreground 220 --title "Waiting..." -- sleep 1
trap 'clear; echo -e "\nExiting..."; exit 130' INT
for i in 1 2; do
@@ -135,11 +132,10 @@ config_setup() {
done
trap - INT
clear; echo "HAProxy Kuberenetes VIP. (e.g., 10.1.0.10)";
HAPROXY_KUBE_VIP=$(gum input --placeholder "10.1.0.10" --prompt "* " $STYLE_SETTING1 --value "$(yq '.haproxy.kube.vip' $CONFIG_FILE)") && yq -i -oy ".haproxy.kube.vip = \"$HAPROXY_KUBE_VIP\"" "$CONFIG_FILE" || exit 0
clear; HAPROXY_KUBE_VIP=$(gum input --header "HAProxy Kuberenetes VIP. (e.g., 10.1.0.10)" --placeholder "10.1.0.10" --prompt "* " $STYLE_SETTING1 --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" $STYLE_SETTING2 "Controller Node Configuration (3 Required)"; gum spin --spinner dot --title "Waiting..." -- sleep 2
clear; gum style --border double --padding "1 2" $STYLE_SETTING2 "Controller Node Configuration (3 Required)"; gum spin --spinner dot --spinner.foreground 220 --title "Waiting..." -- sleep 1
trap 'clear; echo -e "\nExiting..."; exit 130' INT
for i in 1 2 3; do
@@ -157,7 +153,7 @@ config_setup() {
trap - INT
# Controller node entry (3 nodes required)
clear; gum style --border double --padding "1 2" $STYLE_SETTING2 "Worker Node Configuration (3 Required)"; gum spin --spinner dot --title "Waiting..." -- sleep 2
clear; gum style --border double --padding "1 2" $STYLE_SETTING2 "Worker Node Configuration (3 Required)"; gum spin --spinner dot --spinner.foreground 220 --title "Waiting..." -- sleep 1
# Add worker node loop
count=1
@@ -206,7 +202,7 @@ thatll_buff_right_out_captin() {
}
main() {
# Choices List
CHOICE=$(gum choose --header "Select a function to run:" --cursor "> " --height 10 --cursor.foreground 220 --header.foreground 220 "Configuration Setup" "Run Maintenance Tasks" "Run Cluster Upgrade" "Backup Cluster Configuration" "Restore Cluster Configuration" "Exit")