minor fixes

This commit is contained in:
Dominik Moritz Roth 2025-08-17 23:28:13 +02:00
parent aa9ba7ce23
commit 9456753877

View File

@ -99,15 +99,32 @@ sed -i "s/^HOSTNAME .*/HOSTNAME $HOSTNAME/" install.conf
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
# 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
if ! sed -i "s/^ALMA_USER=.*/ALMA_USER=\"$USERNAME\"/" post-install.sh; then
echo "ERROR: Failed to update ALMA_USER in post-install.sh"
exit 1
fi
# Use awk to replace SSH_KEY line to avoid sed issues with special characters
if ! awk -v key="$SSH_KEY" '
/^SSH_KEY=/ { print "SSH_KEY=\"" key "\""; next }
{ print }
' post-install.sh > post-install.sh.tmp; then
echo "ERROR: Failed to update SSH_KEY in post-install.sh"
exit 1
fi
mv post-install.sh.tmp post-install.sh
# Copy to root directory where installimage expects them
cp install.conf /root/
cp post-install.sh /root/
if ! cp install.conf /root/; then
echo "ERROR: Failed to copy install.conf to /root/"
exit 1
fi
if ! cp post-install.sh /root/; then
echo "ERROR: Failed to copy post-install.sh to /root/"
exit 1
fi
chmod +x /root/post-install.sh
# Ask for optional features
@ -170,11 +187,29 @@ if [[ "$CONFIRM" =~ ^[Nn]$ ]]; then
exit 1
fi
# Check if installimage exists
if ! command -v installimage &> /dev/null; then
echo "ERROR: installimage command not found!"
echo "This might not be a Hetzner rescue system, or installimage is not in PATH."
echo "On Hetzner rescue, installimage is usually at /root/.oldroot/nfs/install/installimage"
# Try common locations
if [ -x "/root/.oldroot/nfs/install/installimage" ]; then
echo "Found installimage at /root/.oldroot/nfs/install/installimage"
INSTALLIMAGE_CMD="/root/.oldroot/nfs/install/installimage"
else
echo "Could not find installimage. Please check your Hetzner rescue environment."
exit 1
fi
else
INSTALLIMAGE_CMD="installimage"
fi
# Run the installer
echo -e "\n[+] Starting Hetzner installimage..."
echo "The installer will now run. Follow any prompts if needed."
echo ""
installimage -a -c /root/install.conf -s /root/post-install.sh
$INSTALLIMAGE_CMD -a -c /root/install.conf -s /root/post-install.sh
echo -e "\n[+] Installation complete!"
echo ""