Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch issue 21 (Issues on OpenWRT 22.03.4) #22

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion hetzner_ddns.openwrt.rc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@
START=99
USE_PROCD=1

_LOG_FILE=/var/log/hetzner_ddns.log
_PID_FILE=/var/run/hetzner_ddns.pid

fix_permissions() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also set the owner of the config file to nobody:nogroup?

I did encounter issues when leaving it to root:root.
What I did:

  • changed the config file contents in order to match my zone on hetzner
  • restarted the service with service hetzner_ddns restart
  • had a look in my log file which showed me the following:
[2024-12-27 19:52:00] Started Hetzner DDNS daemon
[2024-12-27 19:52:00] Error: unable to read configuration file /etc/config/hetzner_ddns.conf
  • after changing the owner of hetzner_ddns.conf to nobody:nogroup I could process the config file, because the log showed me this:
[2024-12-27 20:26:07] Started Hetzner DDNS daemon
[2024-12-27 20:26:07] Reading configuration from /etc/config/hetzner_ddns.conf
[2024-12-27 20:26:07] Info: update of A records not set, enabling by default
[2024-12-27 20:26:07] Info: update of AAAA records not set, enabling by default
[2024-12-27 20:26:09] Zone for refractedlight.eu: <redacted>
[2024-12-27 20:26:09] IPv4 record for cloud.refractedlight.eu: <redacted>
[2024-12-27 20:26:09] IPv6 record for cloud.refractedlight.eu: (missing)
[2024-12-27 20:26:09] Configuration successful
[2024-12-27 20:26:09] Watching for IP address and record changes
  • then I also could confirm that the process is running:
 # ps | grep hetzner
17873 nobody    1564 S    {hetzner_ddns} /bin/sh /usr/bin/hetzner_ddns -d

But maybe this was just something strange on my installation... I am not that sure.
Did test that with
hetzner-ddns_0.2.7-1_all.ipk.txt
(.txt suffix only because of GitHub rejecting pure .ipk)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange. I will give it some further investigations in the course of the weekend, but what permissions did your config file have after installation/editing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the fuss, seems that I did something wrong previously or had some older configuration files.

Installation history root@danielcpe ~ # opkg install hetzner-ddns_0.2.7-1_all.ipk Installing hetzner-ddns (0.2.7-1) to root... Configuring hetzner-ddns. root@danielcpe /etc/config # ll hetzner_ddns.conf -rw-r--r-- 1 root root 453 Dec 27 14:34 hetzner_ddns.conf root@danielcpe /etc/config # cat hetzner_ddns.conf interval=60 # Seconds between updates / TTL value key='********************************' # Hetzner DNS API key domain='example.com' # Top level domain name records='homelab media vpn' # Space separated host subdomains (@ for domain itself) ipv4=true # Enable updating A records (IPv4) ipv6=true # Enable updating AAAA records (IPv6) root@danielcpe /etc/config # cat /var/log/hetzner_ddns.log [2024-12-29 17:14:55] Started Hetzner DDNS daemon [2024-12-29 17:14:55] Reading configuration from /etc/config/hetzner_ddns.conf [2024-12-29 17:14:56] Error: Invalid API key

Now the configuration file is owned by root, but the daemon process is running and owned by nobody and the update works:

16841 nobody    1564 S    {hetzner_ddns} /bin/sh /usr/bin/hetzner_ddns -d
[2024-12-29 17:32:34] Watching for IP address and record changes
[2024-12-29 17:36:14] Update IPv4 for cloud.refractedlight.eu: 127.0.0.1 => 84.135.98.106

TL;DR Seems fine now ✔️

touch "${_LOG_FILE}"
touch "${_PID_FILE}"

chown nobody:nogroup "${_LOG_FILE}"
chown nobody:nogroup "${_PID_FILE}"

chmod u+w "${_LOG_FILE}"
chmod u+w "${_PID_FILE}"
}

start_service() {
fix_permissions
procd_open_instance [hetzner_ddns]
procd_set_param command /usr/bin/hetzner_ddns -d /etc/config/hetzner_ddns.conf
procd_set_param command /usr/bin/hetzner_ddns -d

# respawn automatically if something died, be careful if you have an alternative process supervisor
# if process exits sooner than respawn_threshold, it is considered crashed and after 5 retries the service is stopped
Expand Down
6 changes: 3 additions & 3 deletions release/OpenWrt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ endef
define Package/$(PKG_NAME)/install
# copy shell script, init.d file and conf as preparation
mkdir -p files
cp $(PKG_BUILD_DIR)/hetzner_ddns.sh ./files/
cp $(PKG_BUILD_DIR)/hetzner_ddns.sh ./files/hetzner_ddns
carstencodes marked this conversation as resolved.
Show resolved Hide resolved
cp $(PKG_BUILD_DIR)/hetzner_ddns.conf ./files/
cp $(PKG_BUILD_DIR)/hetzner_ddns.openwrt.rc ./files/

Expand All @@ -59,13 +59,13 @@ define Package/$(PKG_NAME)/install

# install shell script, conf and service
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) ./files/hetzner_ddns.sh $(1)/usr/bin
$(INSTALL_BIN) ./files/hetzner_ddns $(1)/usr/bin

$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/hetzner_ddns.openwrt.rc $(1)/etc/init.d/hetzner_ddns

$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/hetzner_ddns.conf $(1)/etc/config/hetzner_ddns.conf
$(INSTALL_DATA) ./files/hetzner_ddns.conf $(1)/etc/config/hetzner_ddns.conf
carstencodes marked this conversation as resolved.
Show resolved Hide resolved
endef

define Package/$(PKG_NAME)/prerm
Expand Down