diff --git a/ChangeLog.md b/ChangeLog.md index b4ca1072..3e88b8f9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,12 +7,13 @@ repository history](https://github.com/ddclient/ddclient/commits/master). ### Breaking changes + * ddclient no longer runs as a daemon. Running via cron is recommended. * ddclient now requires curl. * ddclient no longer has built-in support for IP detection via routers and firewalls. * ddclient no longer ships any example files for init systems that use `/etc/init.d`. This was done because those files where effectively unmaintained, untested by the developers and only updated by downstream distros. - If you where relying on those files, please copy them into your packaging. + If you were relying on those files, please copy them into your packaging. * The defunct `dnsexit` protocol is removed (replaced by `dnsexit2`). ### New features diff --git a/README.md b/README.md index 04dc29b5..1e8f692c 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ start the first time by hand ## TROUBLESHOOTING - 1. enable debugging and verbose messages: ``$ ddclient -daemon=0 -debug -verbose -noquiet`` + 1. enable debugging and verbose messages: ``$ ddclient -debug -verbose -noquiet`` 2. Do you need to specify a proxy? If so, just add a ``proxy=your.isp.proxy`` to the ddclient.conf file. @@ -139,14 +139,10 @@ entry with each connection, with: ## configure pppd to update DynDNS with each connection cp sample-etc_ppp_ip-up.local /etc/ppp/ip-up.local -Alternatively, you may just configure ddclient to operate as a daemon -and monitor your ppp interface. - ## USING DDCLIENT WITH `cron` -If you have not configured ddclient to use daemon-mode, you'll need to -configure cron to force an update once a month so that the dns entry will -not become stale. +You'll need to configure cron to force an update every so often so that the +dns entry will not become stale. ## configure cron to force an update twice a month cp sample-etc_cron.d_ddclient /etc/cron.d/ddclient @@ -174,9 +170,6 @@ exit 0 Other DHCP clients may have another method of calling out to programs for updating DNS entries. -Alternatively, you may just configure ddclient to operate as a daemon -and monitor your ethernet interface. - ## USING DDCLIENT WITH `dhclient` If you are using the ISC DHCP client (dhclient), you can update @@ -187,6 +180,3 @@ ie.: ``cp sample-etc_dhclient-exit-hooks /etc/dhclient-exit-hooks`` Edit ``/etc/dhclient-exit-hooks`` to change any options required. - -Alternatively, you may just configure ddclient to operate as a daemon -and monitor your ethernet interface. diff --git a/ddclient.in b/ddclient.in index 3826ab9e..6800ce7f 100755 --- a/ddclient.in +++ b/ddclient.in @@ -51,10 +51,6 @@ if ($program =~ /test/i) { my $msgs = ''; my $last_msgs = ''; -## If run as *d (e.g., ddclientd) then daemonize by default (but allow -## flags and options to override). -my $daemon_default = ($programd =~ /d$/) ? interval('5m') : 0; - use vars qw($file $lineno); local $file = ''; local $lineno = ''; @@ -65,7 +61,6 @@ our %globals; my ($result, %config, %cache); my $saved_cache; my %saved_opt; -my $daemon; # Control how many times warning message logged for invalid IP addresses my (%warned_ip, %warned_ipv4, %warned_ipv6); my $inv_ip_warn_count = opt('max-warn') // 1; @@ -163,8 +158,6 @@ sub setv { } my %variables = ( 'global-defaults' => { - 'daemon' => setv(T_DELAY, 0, 0, $daemon_default, interval('60s')), - 'foreground' => setv(T_BOOL, 0, 0, 0, undef), 'file' => setv(T_FILE, 0, 0, "$etc/$program.conf", undef), 'cache' => setv(T_FILE, 0, 0, "$cachedir/$program.cache", undef), 'pid' => setv(T_FILE, 0, 0, "", undef), @@ -737,15 +730,12 @@ $opt{'list-web-services'} = sub { my @opt = ( "usage: ${program} [options]", "options are:", - ["daemon", "=s", "-daemon : run as a daemon, specify as an interval"], - ["foreground", "!", "-foreground : do not fork"], ["proxy", "=s", "-proxy : use as the HTTP proxy"], ["server", "=s", "-server : update DNS information on "], ["protocol", "=s", "-protocol : update protocol used"], ["list-protocols", "", "-list-protocols : print a machine-readable list of supported update protocols and exit. Format: one per line"], ["file", "=s", "-file : load configuration information from "], ["cache", "=s", "-cache : record address used in "], - ["pid", "=s", "-pid : record process id in if daemonized"], "", ["use", "=s", "-use : deprecated, see 'usev4' and 'usev6'"], &ip_strategies_usage(), @@ -829,7 +819,6 @@ sub main { exit 0; } - ## read config file because 'daemon' mode may be defined there. read_config($opt{'file'} // default('file'), \%config, \%globals); init_config(); test_possible_ip() if opt('query'); @@ -840,80 +829,37 @@ sub main { $SIG{'HUP'} = sub { $caught_hup = 1; }; $SIG{'TERM'} = sub { $caught_term = 1; }; $SIG{'INT'} = sub { $caught_int = 1; }; - # don't fork() if foreground - if (opt('foreground')) { - ; - } elsif (opt('daemon')) { - $SIG{'CHLD'} = 'IGNORE'; - my $pid = fork; - if ($pid < 0) { - print STDERR "${program}: can not fork ($!)\n"; - exit -1; - } elsif ($pid) { - exit 0; - } - $SIG{'CHLD'} = 'DEFAULT'; - open(STDOUT, ">/dev/null"); - open(STDERR, ">/dev/null"); - open(STDIN, " 0) && !$caught_hup && !$caught_term && !$caught_int) { - my $delay = $left > 10 ? 10 : $left; + read_config($opt{'file'} // default('file'), \%config, \%globals); + init_config(); + read_cache(opt('cache'), \%cache); + print_info() if opt('debug') && opt('verbose'); - $0 = sprintf("%s - sleeping for %s seconds", $program, $left); - $left -= sleep $delay; - # preventing deep sleep - see [bugs:#46] - if ($left > $daemon) { - $left = $daemon; - } - } - $caught_hup = 0; - $result = 0; + fatal("invalid argument '-use %s'; possible values are:\n%s", $opt{'use'}, join("\n", ip_strategies_usage())) + unless exists $ip_strategies{lc opt('use')}; + if (defined($opt{'usev6'})) { + usage("invalid argument '-usev6 %s'; possible values are:\n%s", $opt{'usev6'}, join("\n",ipv6_strategies_usage())) + unless exists $ipv6_strategies{lc opt('usev6')}; + } - } elsif (!scalar(%config)) { - warning("no hosts to update.") unless !opt('quiet') || opt('verbose') || !$daemon; - $result = 1; + update_nics(); - } else { - $result = $result eq 'OK' ? 0 : 1; - } - } while ($daemon && !$result && !$caught_term && !$caught_int); + if (!scalar(%config)) { + $result = 1; + } else { + $result = $result eq 'OK' ? 0 : 1; + } warning("caught SIGINT; exiting") if $caught_int; - unlink_pid(); sendmail(); exit($result); @@ -987,8 +933,7 @@ sub update_nics { # And if it is valid, remember it... $iplist{$use}{$arg_ip}{$arg_if}{$arg_web}{$arg_cmd} = $ip; } else { - warning("%s: unable to determine IP address with strategy use=%s", $h, $use) - if !$daemon || opt('verbose'); + warning("%s: unable to determine IP address with strategy use=%s", $h, $use); } } # And remember it as the IP address we want to send to the DNS service. @@ -1006,8 +951,7 @@ sub update_nics { # And if it is valid, remember it... $ipv4list{$usev4}{$arg_ipv4}{$arg_ifv4}{$arg_webv4}{$arg_cmdv4} = $ipv4; } else { - warning("%s: unable to determine IPv4 address with strategy usev4=%s", $h, $usev4) - if !$daemon || opt('verbose'); + warning("%s: unable to determine IPv4 address with strategy usev4=%s", $h, $usev4); } } # And remember it as the IPv4 address we want to send to the DNS service. @@ -1025,8 +969,7 @@ sub update_nics { # And if it is valid, remember it... $ipv6list{$usev6}{$arg_ipv6}{$arg_ifv6}{$arg_webv6}{$arg_cmdv6} = $ipv6; } else { - warning("%s: unable to determine IPv6 address with strategy usev6=%s", $h, $usev6) - if !$daemon || opt('verbose'); + warning("%s: unable to determine IPv6 address with strategy usev6=%s", $h, $usev6); } } # And remember it as the IP address we want to send to the DNS service. @@ -1060,33 +1003,6 @@ sub update_nics { write_cache(opt('cache')); } -###################################################################### -## unlink_pid() -###################################################################### -sub unlink_pid { - if (opt('pid') && opt('daemon')) { - unlink opt('pid'); - } -} - -###################################################################### -## write_pid() -###################################################################### -sub write_pid { - my $file = opt('pid'); - - if ($file && opt('daemon')) { - local *FD; - if (!open(FD, "> $file")) { - warning("Cannot create file '%s'. (%s)", $file, $!); - - } else { - printf FD "%s\n", $$; - close(FD); - } - } -} - ###################################################################### ## write_cache($file) ###################################################################### @@ -1440,11 +1356,6 @@ sub init_config { $opt{'timeout'} = 0 if opt('timeout') < 0; - ## parse an interval expression (such as '5m') into number of seconds - $opt{'daemon'} = interval(opt('daemon')) if defined($opt{'daemon'}); - ## make sure the interval isn't too short - $opt{'daemon'} = minimum('daemon') if opt('daemon') > 0 && opt('daemon') < minimum('daemon'); - ## define or modify host options specified on the command-line if (exists $opt{'options'} && defined $opt{'options'}) { ## collect cmdline configuration options. @@ -2959,15 +2870,12 @@ Global definitions look like: name=value [,name=value]* For example: - daemon=5m use=if, if=eth0 proxy=proxy.myisp.com protocol=dyndns2 -specifies that ${program} should operate as a daemon, checking the -eth0 interface for an IP address change every 5 minutes and use the -'dyndns2' protocol by default. The daemon interval can be specified -as seconds (600s), minutes (5m), hours (1h) or days (1d). +specifies that ${program} should use the 'dyndns2' protocol by +default. Host definitions look like: [name=value [,name=value]*]* a.host.domain [,b.host.domain] [login] [password] @@ -4937,7 +4845,7 @@ sub nic_freedns_update { $config{$h}{'mtime'} = $now; $config{$h}{"status-ipv$ipv"} = 'good'; success("updating %s: update not necessary, '$type' record already set to %s", $h, $ip) - if (!$daemon || opt('verbose')); + if (opt('verbose')); } else { my $url = $rec->[2] . "&address=" . $ip; ($url_tmpl = $url) =~ s/\?.*\&/?&/; # redact unique update token diff --git a/sample-ddclient-wrapper.sh b/sample-ddclient-wrapper.sh index cf9e1384..0ce6f8ef 100755 --- a/sample-ddclient-wrapper.sh +++ b/sample-ddclient-wrapper.sh @@ -12,4 +12,4 @@ # ddclient adds the new IP as argument IP=$1 -ddclient -ip ${IP} -file ${SECONDCONFIG} -daemon 0 +ddclient -ip ${IP} -file ${SECONDCONFIG} diff --git a/sample-etc_cron.d_ddclient b/sample-etc_cron.d_ddclient index b0818323..0291da3b 100644 --- a/sample-etc_cron.d_ddclient +++ b/sample-etc_cron.d_ddclient @@ -1,5 +1,5 @@ ###################################################################### -## ddclient is an IP address updater for www.dyndns.org +## ddclient is a dynamic DNS IP address updater ###################################################################### ## minute 0-59 ## hour 0-23 @@ -7,10 +7,10 @@ ## month 1-12 (or names, see below) ## day of week 0-7 (0 or 7 is Sun, or use names) ###################################################################### -## force an update twice a month (only if you are not using daemon-mode) +## force an update twice a month ## -## 30 23 1,15 * * root /usr/bin/ddclient -daemon=0 -syslog -quiet -force +## 30 23 1,15 * * root /usr/bin/ddclient -syslog -quiet -force ###################################################################### -## retry failed updates every hour (only if you are not using daemon-mode) +## retry failed updates every hour ## -## 0 * * * * root /usr/bin/ddclient -daemon=0 -syslog -quiet retry +## 0 * * * * root /usr/bin/ddclient -syslog -quiet retry diff --git a/sample-etc_dhclient-exit-hooks b/sample-etc_dhclient-exit-hooks index 49787a44..3e27f2d5 100644 --- a/sample-etc_dhclient-exit-hooks +++ b/sample-etc_dhclient-exit-hooks @@ -10,6 +10,6 @@ case "$new_ip_address" in 192.168.*) ;; *) logger -t dhclient IP address changed to $new_ip_address - ddclient -daemon=0 -syslog -use=ip -ip=$new_ip_address >/dev/null 2>&1 + ddclient -syslog -use=ip -ip=$new_ip_address >/dev/null 2>&1 ;; esac diff --git a/sample-etc_dhcpc_dhcpcd-eth0.exe b/sample-etc_dhcpc_dhcpcd-eth0.exe index 13c5d35d..edb131e5 100644 --- a/sample-etc_dhcpc_dhcpcd-eth0.exe +++ b/sample-etc_dhcpc_dhcpcd-eth0.exe @@ -13,6 +13,6 @@ case "$1" in 192.168.*) ;; *) logger -t dhcpcd IP address changed to $1 - ddclient -daemon=0 -syslog -use=ip -ip=$1 >/dev/null 2>&1 + ddclient -syslog -use=ip -ip=$1 >/dev/null 2>&1 ;; esac diff --git a/sample-etc_ppp_ip-up.local b/sample-etc_ppp_ip-up.local index 49404ad1..9be498dd 100644 --- a/sample-etc_ppp_ip-up.local +++ b/sample-etc_ppp_ip-up.local @@ -36,7 +36,7 @@ case "$IP" in ;; *) ( sleep 5 - ddclient -daemon=0 -syslog -use=if -if=$IFACE >/dev/null 2>&1 + ddclient -syslog -use=if -if=$IFACE >/dev/null 2>&1 ) & ;; esac diff --git a/sample-etc_systemd.service b/sample-etc_systemd.service deleted file mode 100644 index cd707121..00000000 --- a/sample-etc_systemd.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Dynamic DNS Update Client -Wants=network-online.target -After=network-online.target nss-lookup.target - -[Service] -Type=forking -PIDFile=/run/ddclient.pid -ExecStart=/usr/bin/ddclient - -[Install] -WantedBy=multi-user.target