diff --git a/install.sh b/install.sh index 66aa77b..810416b 100644 --- a/install.sh +++ b/install.sh @@ -64,11 +64,11 @@ echo "Found SSH key: ${SSH_KEY:0:50}..." # Ask for hostname echo -e "\n[+] Server configuration" -read -p "Enter hostname [nullpoint]: " HOSTNAME +read -r -p "Enter hostname [nullpoint]: " HOSTNAME < /dev/tty HOSTNAME=${HOSTNAME:-nullpoint} # Ask for username -read -p "Enter username for admin account [null]: " USERNAME +read -r -p "Enter username for admin account [null]: " USERNAME < /dev/tty USERNAME=${USERNAME:-null} # Generate secure LUKS passphrase @@ -80,7 +80,7 @@ echo "LUKS PASSPHRASE (SAVE THIS!):" echo "$LUKS_PASS" echo "================================================" echo -e "\nPress Enter when you've saved the passphrase..." -read +read -r < /dev/tty # Clone or download the nullpoint repo echo "[+] Downloading nullpoint configuration..." @@ -95,8 +95,21 @@ fi # Update install.conf echo "[+] Configuring installation..." cd /tmp/nullpoint -sed -i "s/^HOSTNAME .*/HOSTNAME $HOSTNAME/" install.conf -sed -i "s/^CRYPTPASSWORD .*/CRYPTPASSWORD $LUKS_PASS/" install.conf +# Update install.conf with proper escaping +if ! sed -i "s/^HOSTNAME .*/HOSTNAME $HOSTNAME/" install.conf; then + echo "ERROR: Failed to update HOSTNAME in install.conf" + exit 1 +fi + +# Use awk for CRYPTPASSWORD to handle special characters +if ! awk -v pass="$LUKS_PASS" ' + /^CRYPTPASSWORD / { print "CRYPTPASSWORD " pass; next } + { print } +' install.conf > install.conf.tmp; then + echo "ERROR: Failed to update CRYPTPASSWORD in install.conf" + exit 1 +fi +mv install.conf.tmp install.conf # Update post-install.sh if ! sed -i "s/^ALMA_USER=.*/ALMA_USER=\"$USERNAME\"/" post-install.sh; then @@ -129,25 +142,25 @@ chmod +x /root/post-install.sh # Ask for optional features echo -e "\n[+] Optional features:" -read -p "Do you have a TPM and want to use it? [y/N]: " USE_TPM +read -r -p "Do you have a TPM and want to use it? [y/N]: " USE_TPM < /dev/tty if [[ "$USE_TPM" =~ ^[Yy]$ ]]; then echo "TPM will be configured if available." else sed -i 's/^TPM_ENABLED=.*/TPM_ENABLED=false/' /root/post-install.sh fi -read -p "Do you want to configure remote unlock Tang servers? [y/N]: " USE_TANG +read -r -p "Do you want to configure remote unlock Tang servers? [y/N]: " USE_TANG < /dev/tty if [[ "$USE_TANG" =~ ^[Yy]$ ]]; then echo "Configuring Tang servers..." TANG_CONFIG="" while true; do - read -p "Enter Tang server URL (or press Enter to finish): " TANG_URL + read -r -p "Enter Tang server URL (or press Enter to finish): " TANG_URL < /dev/tty if [ -z "$TANG_URL" ]; then break fi - read -p "Enter thumbprint for $TANG_URL: " TANG_THUMBPRINT + read -r -p "Enter thumbprint for $TANG_URL: " TANG_THUMBPRINT < /dev/tty if [ -n "$TANG_THUMBPRINT" ]; then TANG_CONFIG+=" \"$TANG_URL $TANG_THUMBPRINT\"\n" echo "Added Tang server: $TANG_URL" @@ -181,7 +194,7 @@ echo " Username: $USERNAME" echo " SSH Key: ${SSH_KEY:0:50}..." echo " LUKS Passphrase: $LUKS_PASS" echo "" -read -p "Proceed with installation? [Y/n]: " CONFIRM +read -r -p "Proceed with installation? [Y/n]: " CONFIRM < /dev/tty if [[ "$CONFIRM" =~ ^[Nn]$ ]]; then echo "Installation cancelled." exit 1 @@ -209,7 +222,11 @@ fi echo -e "\n[+] Starting Hetzner installimage..." echo "The installer will now run. Follow any prompts if needed." echo "" -$INSTALLIMAGE_CMD -a -c /root/install.conf -s /root/post-install.sh +if ! $INSTALLIMAGE_CMD -a -c /root/install.conf -s /root/post-install.sh; then + echo -e "\nERROR: Installation failed!" + echo "Please check the error messages above." + exit 1 +fi echo -e "\n[+] Installation complete!" echo ""