
Estou usando ddclient/DDNS no Ubuntu 16.04 LTS para atualizar os IPs para os quais dois domínios que possuo (do NameCheap) possuem um registro DNS (isso está funcionando).
No entanto, o problema é que, tendo dois domínios, preciso de duas instâncias separadas do ddclient em execução. Comecei a escrever dois .service
arquivos para fazer isso:
/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
Com as configurações especificadas nos comandos ExecStart, conforme especificado abaixo:
/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
E usando systemctl enable ddclient_website1.service
(o mesmo para website2) produz:
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
não produz saída.
ps -ef | grep ddclient
lista apenas o grep que acabou de ser executado e systemctl status ddclient_website1.service
produz:
● 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.
Uma reinicialização não causa alterações positivas.
Editar:
Após a modificação dos .service
arquivos para o arquivo padrão .service
criado durante a instalação do ddclient, agora possocomeçaros serviços (eles estão listados em 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
No entanto, após a execução por 40 a 50 segundos, eles atingem o tempo limite, informando que os arquivos PID que eles precisam acessar não existem (mesmo problema para ambos os serviços):
● 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'.
Eu touch
editei ddclient_website1.pid
(também para o website2) /var/run
e obtive o mesmo resultado.
Responder1
[Serviço] ExecStart=/usr/sbin/ddclient -file /etc/ddclient_website1.conf
Usar as configurações PIDFile
e Type=forking
no arquivo INI está errado, assim como a -pid
opção do programa. Este programa (como tantos outros) na verdade não implementa o protocolo de prontidão relevante.
A forma correta de proceder, assim como tantos outros softwares, é utilizar a -foreground
opção do programa, que possui desde a revisão 113 conforme seu documento.
Leitura adicional
Responder2
Isto pode estar relacionado, tente alterar a [Install]
seção para
[Install]
WantedBy=default.target
Responder3
O problema é que eu não havia especificado onde o cache e o arquivo PID estariam localizados no ddclient.
Conforme a --help
página:
-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'.
Meu ExecStart
comando especificou apenas -file
, enquanto eu precisava especificar também -cache
e -pid
.
Aqui está meu ddclient_website1.service funcional:
[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
Você também pode especificar esses caminhos em seu arquivo de configuração para ddclient, em /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
@
Agora você deve conseguir executar systemctl enable ddclient_website1.service
e systemctl start ddclient_website1.service
fazer com que o ddclient comece a funcionar.