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

Service is not starting and config file is not being found on my installation #9

Closed
ant0nioli opened this issue Jul 15, 2023 · 15 comments
Assignees
Labels
bug Something isn't working

Comments

@ant0nioli
Copy link

Hi!

I'm trying to get your application working inside a libvirt's VM, the OS I'm using is Alpine 3.18.2.

I have installed the package via apk but I can´t figure out what I'm doing wrong...

I'm getting this errors:

localhost:/# hetzner_ddns
jq: error (at <stdin>:0): Cannot iterate over null (null)
localhost:/# service hetzner enable
 * service: service `hetzner_ddns' does not exist
localhost:/etc# 
localhost:/# hetzner_ddns start
unable to read configuration file

Any clue?

Thank you very much for sharing this @filiparag !!

@filiparag filiparag self-assigned this Jul 15, 2023
@filiparag
Copy link
Owner

I have installed the package via apk but I can´t figure out what I'm doing wrong...

Have you installed only hetzner_ddns-0.2.3.apk or also hetzner_ddns-doc-0.2.3.apk and hetzner_ddns-openrc-0.2.3.apk?

Error message Cannot iterate over null (null) can also be a result of an invalid API key.

@ant0nioli
Copy link
Author

I have installed only:

hetzner_ddns-0.2.3.apk and hetzner_ddns-doc-0.2.3.apk

Should I install hetzner_ddns-openrc-0.2.3.apk too?

I checked the API key and it's the correct one I got from Hetzner yesterday.

Thanks

@filiparag
Copy link
Owner

Docs package is not required, but if you are using this as an OpenRC service, you have to install hetzner_ddns-openrc-0.2.3.apk for it to register.

And regarding the jq message, can you provide the logfile /var/log/hetzner_ddns.log? Just be sure to replace sensitive with placeholder data.

@ant0nioli
Copy link
Author

Yes, I installed the Docs afterwards, in the first time I installed only the required package and I was getting the same problem.

This is what I have inside my /var/log/hetzner_ddns.log:

[2023-07-15 04:08:09] Started Hetzner DDNS daemons.log                          
[2023-07-15 16:29:12] Started Hetzner DDNS daemon
[2023-07-15 16:34:40] Started Hetzner DDNS daemon

A new line is added when I launch: localhost:/# hetzner_ddns

I'm fairly new with this, and as I see maybe I should use open-rc with Alpine..

An other things that catches my attention is the error message in reply when I try to start the service:

localhost:/# service hetzner_ddns enable
 * service: service `hetzner_ddns' does not exist

Here the `hetzner_ddns' name is printed with two different apostrophes at the beginning and at the end of the service name: ` and '

Thanks

@ant0nioli
Copy link
Author

Installing hetzner_ddns-openrc-0.2.3.apk seems to be a step forward.

Now I can update the open-rc:

localhost:~# rc-update add hetzner_ddns
 * service hetzner_ddns added to runlevel default

But if I try to start the service I get this error:

localhost:~# service hetzner_ddns start
unable to read configuration file
 * ERROR: hetzner_ddns failed to start

the /var/log/hetzner_ddns.log is showing the same:

[2023-07-15 04:08:09] Started Hetzner DDNS daemons.log                          
[2023-07-15 16:29:12] Started Hetzner DDNS daemon
[2023-07-15 16:34:40] Started Hetzner DDNS daemon
[2023-07-15 17:03:18] Started Hetzner DDNS daemon

@filiparag
Copy link
Owner

Here the `hetzner_ddns' name is printed with two different apostrophes at the beginning and at the end of the service name: ` and '

This is an OpenRC typo, as you can see it when trying to start arbitrarily-named services:

# service foobar start
 * service: service `foobar' does not exist

Your log file should look something like this:

[2023-07-15 17:00:00] Started Hetzner DDNS daemon
[2023-07-15 17:00:03] Zone for example.com: <zone id goes here>
[2023-07-15 17:00:46] IPv4 record for test.example.com: <record id goes here>
[2023-07-15 17:00:46] IPv6 record for test.example.com: (missing)
[2023-07-13 17:01:00] Update IPv4 for test.example.com: 1.2.3.4 => 5.6.7.8

Did you add your domain and records to Hetzner DNS console?

@ant0nioli
Copy link
Author

Did you add your domain and records to Hetzner DNS console?

I have only this info in my Hetzner DNS console.

(The domain is pointing to the Hetzner Name Servers.)

$ORIGIN mydomain.tld.
$TTL 86400
; SOA Records
@		IN	SOA	hydrogen.ns.hetzner.com. dns.hetzner.com. 2023071400 86400 10800 3600000 3600
; NS Records
@		IN	NS	helium.ns.hetzner.de.
@		IN	NS	hydrogen.ns.hetzner.com.
@		IN	NS	oxygen.ns.hetzner.com.

Should I manually add some other record for my mydomain.tld domain?

@filiparag
Copy link
Owner

Should I manually add some other record for my mydomain.tld domain?

Yes, you should add A/AAAA entries for every record you plan for hetzner_ddns to modify.

If reading config file still doesn't work, it might be a permissions issue, so replace these lines of /usr/bin/hetzner_ddns and see if it works:

#!/bin/sh

self='hetzner_ddns'

- if ! [ -z "$1" ]; then
-     self="${self}.$1"
- fi

# Read variabels from configuration file
- if test -G "/etc/$self.conf"; then
+ if test -f "/etc/$self.conf"; then
    . "/etc/$self.conf"

@ant0nioli
Copy link
Author

With the /usr/bin/hetzner_ddns change the service is starting!

But the log looks the same.

In Hetzner DNS I have added only an A record with the subdomain sub.mydomain.tld I want to use, and the public IP I'm having at the moment assigned.

Maybe something more is needed?

Thank you again for your help.

@filiparag
Copy link
Owner

Maybe something more is needed?

If you properly set the configuration file and did all the things you said, I am not sure why it is still not working. I tried replicating your problem on AlpineLinux 3.18 but to no avail - it works as intended.

What I may suggest is for you to manually try running curl commands [1] and [2] to see if the API is properly accessible from your machine.

@ant0nioli
Copy link
Author

If you properly set the configuration file and did all the things you said, I am not sure why it is still not working. I tried replicating your problem on AlpineLinux 3.18 but to no avail - it works as intended.

Thank you for trying to replicate it. I'm using AlpineLinux 3.17 now, but the problem I get is the same I was getting with 3.18.

What I may suggest is for you to manually try running curl commands [1] and [2] to see if the API is properly accessible from your machine.

I tried to run the two curl commands from the VM and I correctly got the records result from Heitzner.

Maybe the is something I'm missing about the whole picture...

@ant0nioli
Copy link
Author

ant0nioli commented Jul 16, 2023

Something that might help.

(sensitive data has been replaced with dummy data)

When I launch this code:

curl "https://dns.hetzner.com/api/v1/records?zone_id=YTUJ78564cx345gd7UUUUT" -H "Auth-API-Token: UIROSJHYUHYUI4hduand988" 2>/dev/null | jq -r '.records[] | .name + " " + .type + " " + .id'

I get:

@ NS 11a4bcccca56t337fc972f249852083e
@ NS 61deb815148epod67854rc531d1128e7
@ NS 742a5fdser567a5d7dce2e51decb12cb
@ SOA dd16b99787878a42e2ce15eb58bd15f4
sub A c1884fh7h89765fu65e47819f22f8499

But when I launch the same command including the last awk command | awk "\$1==\"$1\" && \$2==\"A\" {print \$3}":

curl "https://dns.hetzner.com/api/v1/records?zone_id=YTUJ78564cx345gd7UUUUT" -H "Auth-API-Token: UIROSJHYUHYUI4hduand988" 2>/dev/null | jq -r '.records[] | .name + " " + .type + " " + .id' | awk "\$1==\"$1\" && \$2==\"A\" {print \$3}"

I get nothing.

@filiparag filiparag added the bug Something isn't working label Jul 17, 2023
@filiparag
Copy link
Owner

I am still unable to reproduce your issue, but it might be a bug so I labeled it as such.

But when I launch the same command including the last awk command | awk "$1=="$1" && $2=="A" {print $3}":

When you are running this awk command, you have to substitute $1 with your SUBDOMAIN subdomain:

curl "https://dns.hetzner.com/api/v1/records?zone_id=$zone" \
                -H "Auth-API-Token: $key" 2>/dev/null | \
            jq -r '.records[] | .name + " " + .type + " " + .id' | \
            awk "\$1==\"SUBDOMAIN\" && \$2==\"A\" {print \$3}"

I ran this command with BusyBox 1.35.0 on AlpineLinux.

@ant0nioli
Copy link
Author

You are totally right @filiparag 😅

I substituted the $1 with the actual subdomain and I'm correctly getting the id as result.

I'm running this as root, I don´t know if this could be a problem.

Thank you for your help, if I have any positive update I will post them here.

@filiparag
Copy link
Owner

I will close the issue for now. If you have any updates, please post them here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants