From 593eb9036958df6a53a411209beabad40aa0df1e Mon Sep 17 00:00:00 2001 From: Chris Oloff Date: Fri, 20 Feb 2026 18:10:01 +0200 Subject: [PATCH] script to create K3S_YAML secrets, updated --- encode-k3s-yaml.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/encode-k3s-yaml.sh b/encode-k3s-yaml.sh index e4d0e1f..ffbcf79 100755 --- a/encode-k3s-yaml.sh +++ b/encode-k3s-yaml.sh @@ -1,9 +1,24 @@ #!/usr/bin/env bash -echo "Provide the public DNS name or IP address of the k3s server:" -read -r server_url +# Define a function to read from the terminal +read_from_terminal() { + # Check if a tty is available + if [[ -t 0 ]]; then + # Use 'read -p' if standard input is an interactive terminal + read -p "$1" user_input + else + printf "\n" > /dev/tty + # If not interactive (e.g. piped), read from /dev/tty + # The '< /dev/tty' redirects input for 'read' to the terminal device + read -p "$1" user_input < /dev/tty + fi + echo "$user_input" +} + +server_url=$(read_from_terminal "Server URL (public DNS name or IP address for the k3s server): ") + +workdir=$(mktemp -d /tmp/encode-k3s-yaml.XXXXXX) -workdir = $(mktemp -d /tmp/encode-k3s-yaml.XXXXXX) cd $workdir echo "Working directory: $workdir" pwd