manatee: Expose komga publicly via komga.ppp.pm

This commit is contained in:
Alexander Heldt
2026-03-02 21:41:41 +01:00
parent 65569f6b57
commit 4f5de3b4cc
3 changed files with 53 additions and 26 deletions

View File

@@ -160,13 +160,13 @@ in
user = {
timers = {
"update-hetzner-ha-dns" = {
"update-hetzner-dns" = {
unitConfig = {
Description = "updates Hetzner DNS for home-assistant";
Description = "updates Hetzner DNS records";
};
timerConfig = {
Unit = "update-hetzner-ha-dns.service";
Unit = "update-hetzner-dns.service";
OnCalendar = "*-*-* *:00/30:00";
Persistent = true;
};
@@ -176,9 +176,9 @@ in
};
services = {
"update-hetzner-ha-dns" = {
"update-hetzner-dns" = {
unitConfig = {
Description = "updates Hetzner DNS for home-assistant";
Description = "updates Hetzner DNS records";
};
serviceConfig = {
@@ -188,38 +188,41 @@ in
path = [
pkgs.curl
pkgs.coreutils # For `cat`
pkgs.coreutils
pkgs.jq
];
script = ''
LAST_IP_FILE="/tmp/hetzner-dns-ha-ip"
SUBDOMAINS="ha komga"
INTERFACE="enp3s0"
CURRENT_IP=$(curl -s --fail --interface "$INTERFACE" ifconfig.me)
LAST_IP=""
if [[ -f "$LAST_IP_FILE" ]]; then
LAST_IP=$(cat "$LAST_IP_FILE")
fi
for SUBDOMAIN in $SUBDOMAINS; do
LAST_IP_FILE="/tmp/hetzner-dns-''${SUBDOMAIN}-ip"
if [[ "$CURRENT_IP" == "$LAST_IP" ]]; then
echo "IP unchanged, NOOP update."
exit 0
else
echo "Updating IP"
LAST_IP=""
if [[ -f "$LAST_IP_FILE" ]]; then
LAST_IP=$(cat "$LAST_IP_FILE")
fi
JSON_BODY=$(jq -n --arg ip "$CURRENT_IP" '{records: [{value: $ip}]}')
if [[ "$CURRENT_IP" == "$LAST_IP" ]]; then
echo "$SUBDOMAIN: IP unchanged, NOOP update."
else
echo "$SUBDOMAIN: Updating IP"
curl \
--fail \
-X POST \
-H "Authorization: Bearer $HETZNER_API_TOKEN" \
-H "Content-Type: application/json" \
-d "$JSON_BODY" \
"https://api.hetzner.cloud/v1/zones/ppp.pm/rrsets/ha/A/actions/set_records" \
&& echo $CURRENT_IP > $LAST_IP_FILE
fi
JSON_BODY=$(jq -n --arg ip "$CURRENT_IP" '{records: [{value: $ip}]}')
curl \
--fail \
-X POST \
-H "Authorization: Bearer $HETZNER_API_TOKEN" \
-H "Content-Type: application/json" \
-d "$JSON_BODY" \
"https://api.hetzner.cloud/v1/zones/ppp.pm/rrsets/''${SUBDOMAIN}/A/actions/set_records" \
&& echo $CURRENT_IP > $LAST_IP_FILE
fi
done
'';
};
};