Skip to content

Instantly share code, notes, and snippets.

@egandro
Last active December 17, 2025 10:03
Show Gist options
  • Select an option

  • Save egandro/f2dab8a559a665fc3c21c176c98dfc29 to your computer and use it in GitHub Desktop.

Select an option

Save egandro/f2dab8a559a665fc3c21c176c98dfc29 to your computer and use it in GitHub Desktop.
#!/bin/bash
PLUGIN_FILE="/usr/share/proxmox-acme/dnsapi/dns_hetznercloud.sh"
SCHEMA_FILE="/usr/share/proxmox-acme/dns-challenge-schema.json"
DOWNLOAD_URL="https://raw.githubusercontent.com/acmesh-official/acme.sh/refs/tags/3.1.2/dnsapi/dns_hetznercloud.sh"
if [ -f "$PLUGIN_FILE" ]; then
echo "File '$PLUGIN_FILE' already exists. Stopping."
exit 0
fi
if ! dpkg-query -W -f='${Status}' libproxmox-acme-plugins 2>/dev/null | grep -q "install ok installed"; then
echo "Error: libproxmox-acme-plugins is not installed. This only works on a Proxmox system." >&2
exit 1
fi
if ! command -v jq &> /dev/null; then
echo "Error: 'jq' is not installed. Please install it (apt install jq)." >&2
exit 1
fi
if ! command -v curl &> /dev/null; then
echo "Error: 'curl' is not installed." >&2
exit 1
fi
if [ ! -f "$SCHEMA_FILE" ]; then
echo "Error: Schema file '$SCHEMA_FILE' not found. Cannot proceed." >&2
exit 1
fi
if [ "$(id -u)" -ne 0 ]; then
echo "Error: You must be root to run this script." >&2
exit 1
fi
echo "Downloading dns_hetznercloud.sh..."
mkdir -p "$(dirname "$PLUGIN_FILE")"
if curl -sS -o "$PLUGIN_FILE" "$DOWNLOAD_URL"; then
echo "Download complete."
chmod +x "$PLUGIN_FILE"
else
echo "Error: Failed to download file." >&2
exit 1
fi
if jq -e 'has("hetznercloud")' "$SCHEMA_FILE" > /dev/null 2>&1; then
echo "Entry 'hetznercloud' already exists in schema. No changes made."
echo "Exiting script."
exit 0
fi
echo "Patching '$SCHEMA_FILE'..."
TMP_JSON=$(mktemp)
jq '. + {"hetznercloud": {}}' "$SCHEMA_FILE" > "$TMP_JSON"
if [ $? -eq 0 ]; then
mv "$TMP_JSON" "$SCHEMA_FILE"
chmod 644 "$SCHEMA_FILE"
echo "Schema file patched successfully."
else
echo "Error: Failed to patch JSON file." >&2
rm -f "$TMP_JSON"
exit 1
fi
if systemctl list-unit-files "pveproxy.service" > /dev/null 2>&1; then
echo "Restarting pveproxy..."
systemctl restart pveproxy
fi
if systemctl list-unit-files "proxmox-backup-proxy.service" > /dev/null 2>&1; then
echo "Restarting proxmox-backup-proxy..."
systemctl restart proxmox-backup-proxy
fi
echo "XXX: You still have to reboot the server..."
echo "-----------------------------------------------------------------------"
echo "Use the new acme plugin 'hetznercloud' with HETZNER_TOKEN=XXX"
echo "(Create a token via the Hetzner console)."
echo ""
echo "Please refresh your browser window."
echo "-----------------------------------------------------------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment