From 865b5e0ea0d802298db54aa23ac1aa931feafc50 Mon Sep 17 00:00:00 2001 From: Nelis Volschenk Date: Mon, 4 May 2026 13:11:46 +0000 Subject: [PATCH] Make packer build script interactive Prompts for config values on first run, saves to server.pkrvars.hcl. On subsequent runs, shows existing config and asks whether to reuse or enter new values. Secret keys are hidden when displaying existing config. Co-Authored-By: Claude Opus 4.6 --- packer/build.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/packer/build.sh b/packer/build.sh index 6652080..7a9689a 100755 --- a/packer/build.sh +++ b/packer/build.sh @@ -4,12 +4,62 @@ set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" -if [ ! -f server.pkrvars.hcl ]; then - echo "Error: server.pkrvars.hcl not found." - echo "Copy server.pkrvars.hcl.example to server.pkrvars.hcl and fill in your values." - exit 1 +VARS_FILE="server.pkrvars.hcl" + +collect_values() { + echo "=== Server Configuration ===" + echo "" + + read -p "Base domain: " BASE_DOMAIN + + read -p "SSH public key path [~/.ssh/id_ed25519.pub]: " PUBKEY_PATH + PUBKEY_PATH="${PUBKEY_PATH:-$HOME/.ssh/id_ed25519.pub}" + if [ ! -f "$PUBKEY_PATH" ]; then + echo "Warning: $PUBKEY_PATH not found, leaving SSH key empty" + SSH_PUBKEY="" + else + SSH_PUBKEY=$(cat "$PUBKEY_PATH") + fi + + echo "" + echo "--- JuiceFS / Nextcloud Storage ---" + read -p "S3 endpoint (e.g. https://s3.amazonaws.com): " JUICEFS_S3_ENDPOINT + read -p "S3 bucket name: " JUICEFS_S3_BUCKET + read -p "S3 access key: " JUICEFS_S3_ACCESS_KEY + read -s -p "S3 secret key: " JUICEFS_S3_SECRET_KEY + echo + read -p "JuiceFS local cache size [50G]: " JUICEFS_CACHE_SIZE + JUICEFS_CACHE_SIZE="${JUICEFS_CACHE_SIZE:-50G}" + + cat > "$VARS_FILE" <