- add periodic daily script to force update

- connect to license framework
 - add special patch from glarkin to ensure daemon detach from tty,
   change some printf to use the warning function instead.

PR:		148586
Submitted by:	Chris Howey <howeyc _at_ gmail.com>
Approved by:	maintainer, glarkin (mentor)
This commit is contained in:
Olli Hauer 2010-08-17 19:22:56 +00:00
parent cc632e1482
commit e3bea4f57f
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=259442
5 changed files with 109 additions and 2 deletions

View file

@ -7,6 +7,7 @@
PORTNAME= ddclient PORTNAME= ddclient
PORTVERSION= 3.8.0 PORTVERSION= 3.8.0
PORTREVISION= 1
CATEGORIES= dns CATEGORIES= dns
MASTER_SITES= SF/${PORTNAME}/${PORTNAME}/${PORTNAME}-${PORTVERSION} MASTER_SITES= SF/${PORTNAME}/${PORTNAME}/${PORTNAME}-${PORTVERSION}
@ -17,14 +18,15 @@ COMMENT= Update dynamic DNS entries
RUN_DEPENDS= ${SITE_PERL}/IO/Socket/SSL.pm:${PORTSDIR}/security/p5-IO-Socket-SSL RUN_DEPENDS= ${SITE_PERL}/IO/Socket/SSL.pm:${PORTSDIR}/security/p5-IO-Socket-SSL
.endif .endif
LICENSE= GPLv2
USE_BZIP2= yes USE_BZIP2= yes
USE_PERL5_RUN= yes USE_PERL5_RUN= yes
NO_BUILD= yes NO_BUILD= yes
USE_RC_SUBR= ${PORTNAME} USE_RC_SUBR= ${PORTNAME}
SUB_FILES= pkg-message SUB_FILES= pkg-message ddclient_force
PKGMESSAGE= ${WRKDIR}/pkg-message PKGMESSAGE= ${WRKDIR}/pkg-message
PLIST_FILES= etc/ddclient.conf.sample sbin/ddclient
PORTDOCS= COPYING COPYRIGHT Changelog README README.cisco README.ssl \ PORTDOCS= COPYING COPYRIGHT Changelog README README.cisco README.ssl \
sample-etc_cron.d_ddclient sample-etc_dhclient-exit-hooks \ sample-etc_cron.d_ddclient sample-etc_dhclient-exit-hooks \
@ -46,6 +48,10 @@ do-install:
@${INSTALL} -d ${DOCSDIR} @${INSTALL} -d ${DOCSDIR}
@${INSTALL_DATA} ${PORTDOCS:S,^,${WRKSRC}/,} ${DOCSDIR}/ @${INSTALL_DATA} ${PORTDOCS:S,^,${WRKSRC}/,} ${DOCSDIR}/
.endif .endif
post-install:
${MKDIR} ${PREFIX}/etc/periodic/daily
${INSTALL_SCRIPT} ${WRKDIR}/ddclient_force ${PREFIX}/etc/periodic/daily/ddclient_force
@${CAT} ${PKGMESSAGE} @${CAT} ${PKGMESSAGE}
.include <bsd.port.mk> .include <bsd.port.mk>

View file

@ -0,0 +1,28 @@
#!/bin/sh
#
# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
. /etc/defaults/periodic.conf
source_periodic_confs
fi
case "$daily_ddclient_force_enable" in
[Yy][Ee][Ss])
echo
echo 'Forcing ddclient update:'
out=`%%PREFIX%%/sbin/ddclient -force`
echo "$out"
rc=0
;;
*)
rc=0
;;
esac
exit $rc

View file

@ -0,0 +1,61 @@
--- ./ddclient.orig 2009-01-27 20:14:02.000000000 +0100
+++ ./ddclient 2010-08-17 20:13:00.000000000 +0200
@@ -1,4 +1,3 @@
-#!/usr/bin/perl -w
#!/usr/local/bin/perl -w
######################################################################
# $Id: ddclient 106 2008-12-04 18:05:23Z wimpunk $
@@ -19,6 +18,7 @@
use Getopt::Long;
use Sys::Hostname;
use IO::Socket;
+use POSIX 'setsid';
my $version = "3.8.0";
my $programd = $0;
@@ -625,6 +625,9 @@
$SIG{'KILL'} = sub { $caught_kill = 1; };
if (opt('daemon') && !opt('force')) {
$SIG{'CHLD'} = 'IGNORE';
+ chdir '/';
+ open(STDIN, "</dev/null");
+ open(STDOUT, ">/dev/null");
my $pid = fork;
if ($pid < 0) {
print STDERR "${program}: can not fork ($!)\n";
@@ -632,11 +635,10 @@
} elsif ($pid) {
exit 0;
}
+ setsid;
$SIG{'CHLD'} = 'DEFAULT';
$opt{'syslog'} = 1;
- open(STDOUT, ">/dev/null");
- open(STDERR, ">/dev/null");
- open(STDIN, "</dev/null");
+ open(STDERR, "&STDOUT");
write_pid();
}
@@ -1404,17 +1406,17 @@
## execute the command.
local *FD;
if (! open(FD, $cmd)) {
- printf STDERR "$program: cannot execute command %s.\n", $cmd;
+ warning("$program: cannot execute command %s.\n", $cmd);
} elsif ($stdin && (! print FD "$stdin\n")) {
- printf STDERR "$program: failed writting to %s.\n", $cmd;
+ warning("$program: failed writing to %s.\n", $cmd);
close(FD);
} elsif (! close(FD)) {
- printf STDERR "$program: failed closing %s.($@)\n", $cmd;
+ warning("$program: failed closing %s.($@)\n", $cmd);
} elsif (opt('exec') && $?) {
- printf STDERR "$program: failed %s. ($@)\n", $cmd;
+ warning("$program: failed %s. ($@)\n", $cmd);
} else {
$ok = 1;

View file

@ -12,4 +12,10 @@ following line to /etc/rc.conf
ddclient_enable="YES" ddclient_enable="YES"
If you would like to force ddclient to update your account
daily regardless of IP changes add the following line to
your /etc/periodic.conf
daily_ddclient_force_enable="YES"
*********************************************************** ***********************************************************

6
dns/ddclient/pkg-plist Normal file
View file

@ -0,0 +1,6 @@
@comment $FreeBSD$
etc/ddclient.conf.sample
etc/periodic/daily/ddclient_force
sbin/ddclient
@dirrmtry etc/periodic/daily
@dirrmtry etc/periodic