From aa9ba7ce231e56e29bf5e03422c577f008cd610c Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 17 Aug 2025 23:23:34 +0200 Subject: [PATCH] save, then run, dont execuet while piping --- install.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 70076fb..c382c17 100644 --- a/install.sh +++ b/install.sh @@ -4,6 +4,14 @@ set -euo pipefail +# If we're being piped, save to a temp file and re-execute +if [ ! -t 0 ]; then + TEMP_SCRIPT=$(mktemp) + cat > "$TEMP_SCRIPT" + chmod +x "$TEMP_SCRIPT" + exec bash "$TEMP_SCRIPT" +fi + BANNER=$(cat << "EOF" :^7J5GB##&&##GPY?~: ^75B&@@@@@@&&&@@@@@@@#GJ~: @@ -93,8 +101,9 @@ sed -i "s/^CRYPTPASSWORD .*/CRYPTPASSWORD $LUKS_PASS/" install.conf # Update post-install.sh sed -i "s/^ALMA_USER=.*/ALMA_USER=\"$USERNAME\"/" post-install.sh # Use a different approach for SSH_KEY to handle special characters -escaped_key=$(printf '%s\n' "$SSH_KEY" | sed 's/[[\.*^$()+?{|]/\\&/g') -sed -i "s|^SSH_KEY=.*|SSH_KEY=\"$escaped_key\"|" post-install.sh +# Escape the SSH key for use in sed by replacing special characters +escaped_key=$(printf '%s' "$SSH_KEY" | sed 's/[[\.*^$()+?{|]/\\&/g; s/]/\\&/g') +sed -i "s|^SSH_KEY=.*|SSH_KEY=\"${escaped_key}\"|" post-install.sh # Copy to root directory where installimage expects them cp install.conf /root/