2

I am using ddclient/DDNS under Ubuntu 16.04 LTS to update the IPs which two domains I own (from NameCheap) have a DNS record for (this is working).

However, the issue is that with having two domains, I need two separate instances of ddclient running. I've begun writing two .service files in order to do this:

/usr/lib/systemd/system/ddclient_website1.service

[Unit]
Description=DDNS client for website1.tld

[Service]
ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website1.conf

[Install]
WantedBy=multi-user.target

/usr/lib/systemd/system/ddclient_website2.service

[Unit]
Description=DDNS client for website2.tld

[Service]
ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website2.conf

[Install]
WantedBy=multi-user.target

With the configurations, specified in the ExecStart commands, as specified below:

/etc/ddclient_website1.conf

daemon=1800
use=web, web=dynamicdns.park-your-domain.com/getip
protocol=namecheap
server=dynamicdns.park-your-domain.com
login=domain_1.tld
password=first_ddns_password
server_name

/etc/ddclient_website2.conf

daemon=1800
use=web, web=dynamicdns.park-your-domain.com/getip
protocol=namecheap
server=dynamicdns.park-your-domain.com
login=domain_2.tld
password=second_ddns_password
server_name

And using systemctl enable ddclient_website1.service (same for website2) yields:

Created symlink from /etc/systemd/system/multi-user.target.wants/ddclient_website1.service to /usr/lib/systemd/system/ddclient_website1.service.

systemctl start ddclient_website1.service yields no output.

ps -ef | grep ddclient lists only the grep just ran, and systemctl status ddclient_website1.service yields:

● ddclient_website1.service - DDNS client for website1.tld
   Loaded: loaded (/usr/lib/systemd/system/ddclient_website1.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Sun 2016-12-18 15:34:23 EST; 39s ago
  Process: 2687 ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website1.conf (code=exited, status=0/SUCCESS)
 Main PID: 2687 (code=exited, status=0/SUCCESS)

Dec 18 15:34:23 server_name systemd[1]: Started DDNS client for website1.tld.

A reboot causes no positive changes.

Edit:

After modification of the .servicefiles to the default .service file created during install of ddclient, I am now able to start the services (they are listed in ps -ef | grep ddclient.

[Unit]
Description=DDNS client for website1.tld
After=network.target

[Service]
Type=forking
PIDFile=/var/run/ddclient_website1.pid
ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website1.conf

[Install]
WantedBy=default.target

However, after running for 40-50 seconds, they timeout, stating the PID files they need to access do not exist (same issue for both services):

● ddclient_website1.service - DDNS client for website1.tld
   Loaded: loaded (/usr/lib/systemd/system/ddclient_website1.service; enabled; vendor preset: enabled)
   Active: failed (Result: timeout) since Sun 2016-12-18 16:04:14 EST; 22s ago
  Process: 1347 ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website1.conf (code=exited, status=0/SUCCESS)

Dec 18 16:02:44 server_name systemd[1]: Starting DDNS client for website1.tld...
Dec 18 16:02:44 server_name systemd[1]: ddclient_website1.service: PID file /var/run/ddclient_website1.pid not readable (yet?) after start: No such file or directory
Dec 18 16:04:14 server_name systemd[1]: ddclient_website1.service: Start operation timed out. Terminating.
Dec 18 16:04:14 server_name systemd[1]: Failed to start DDNS client for website1.tld.
Dec 18 16:04:14 server_name systemd[1]: ddclient_website1.service: Unit entered failed state.
Dec 18 16:04:14 server_name systemd[1]: ddclient_website1.service: Failed with result 'timeout'.

I touched ddclient_website1.pid (also for website2) into /var/run and achieved the same result.

Sean Pianka
  • 121
  • 1
  • 6
  • I use a single instance of ddclinet to update both my domains. if you can put them both under the same username just add a second host line. – Jasen Dec 19 '16 at 02:19

3 Answers3

1
[Service]
ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website1.conf

Using the PIDFile and the Type=forking settings in the INI file is wrong, as is the -pid option to the program. This program (as with so many) does not actually implement the relevant readiness protocol.

The correct way to proceed, also as with so many other softwares, is to employ the program's -foreground option, which it has had since revision 113 according to its doco.

Further reading

JdeBP
  • 68,745
0

This may related, try changing the [Install] section to

[Install]
WantedBy=default.target
Rabin
  • 3,883
  • 1
  • 22
  • 23
  • The issue is no longer that it doesn't start (that was an issue with the type of the service not being labelled as forking), but that the service timing out due to being unable to access a PID file underneath /var/run. – Sean Pianka Dec 18 '16 at 21:11
  • when running the same command from a root terminal is the PID file created ? can you add a debug or verbose flag to the ddclient ? (ddclient -daemon=0 -noquiet -debug) – Rabin Dec 18 '16 at 21:17
0

The issue was that I hadn't specified where the cache and the PID file were going to be located to ddclient.

As per the --help page:

  -file path            : load configuration information from 'path' (default: /etc/ddclient.conf).
  -cache path           : record address used in 'path' (default: /var/cache/ddclient/ddclient.cache).
  -pid path             : record process id in 'path'.

My ExecStart command only specified -file, while I needed to also specify -cache and -pid.

Here's my working ddclient_website1.service:

[Unit]
Description=DDNS client for website1.tld
After=network.target

[Service]
Type=forking
PIDFile=/var/run/ddclient_website1.pid
ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website1.conf -pid /var/run/ddclient_website1.pid -cache /var/cache/ddclient/ddclient_website1.cache

[Install]
WantedBy=default.target

You are also able to specify these paths in your configuration file for ddclient, in /etc/ddclient_website1.conf:

daemon=1800
use=web, web=dynamicdns.park-your-domain.com/getip
protocol=namecheap
server=dynamicdns.park-your-domain.com
login=website1.tld
password=my_ddns_password
cache=/var/cache/ddclient/ddclient_website1.cache
pid=/var/run/ddclient_website1.pid
@

You should now be able to run systemctl enable ddclient_website1.service and systemctl start ddclient_website1.service and have ddclient begin working.

Sean Pianka
  • 121
  • 1
  • 6