From 601cb5987fe81d489ba4c1bafd96be123f3e7053 Mon Sep 17 00:00:00 2001
From: Greg Frost <gregfrost1@bigpond.com>
Date: Mon, 19 Oct 2009 23:11:34 +1030
Subject: ddclient LinHES-config runit-scripts: add dyndns support

---
 abs/core-testing/LinHES-config/PKGBUILD            |   3 +-
 abs/core-testing/LinHES-config/mv_ddns.py          |  25 ++++
 abs/core-testing/LinHES-config/systemconfig.py     |   3 +-
 abs/core-testing/runit-scripts/PKGBUILD            |   2 +-
 .../runitscripts/services/ddclient/run             |   8 +
 abs/extra-testing/ddclient/ChangeLog               |  22 ---
 abs/extra-testing/ddclient/PKGBUILD                |  30 ++--
 .../ddclient/ddclient-foreground.patch             |  47 ++++++
 abs/extra-testing/ddclient/ddclient.conf.d         |   2 -
 .../ddclient/ddclient.conf.dynamic.dyndns.sample   | 162 +++++++++++++++++++++
 abs/extra-testing/ddclient/ddclient.install        |  41 ------
 abs/extra-testing/ddclient/ddclient.rc             |  37 -----
 12 files changed, 261 insertions(+), 121 deletions(-)
 create mode 100755 abs/core-testing/LinHES-config/mv_ddns.py
 create mode 100755 abs/core-testing/runit-scripts/runitscripts/services/ddclient/run
 delete mode 100644 abs/extra-testing/ddclient/ChangeLog
 create mode 100644 abs/extra-testing/ddclient/ddclient-foreground.patch
 delete mode 100644 abs/extra-testing/ddclient/ddclient.conf.d
 create mode 100644 abs/extra-testing/ddclient/ddclient.conf.dynamic.dyndns.sample
 delete mode 100644 abs/extra-testing/ddclient/ddclient.install
 delete mode 100644 abs/extra-testing/ddclient/ddclient.rc

diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD
index 1e61fdf..cb8f8f3 100644
--- a/abs/core-testing/LinHES-config/PKGBUILD
+++ b/abs/core-testing/LinHES-config/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=LinHES-config
 pkgver=2.1
-pkgrel=1
+pkgrel=2
 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev )
 pkgdesc="Install and configure your system"
 depends=(bc libstatgrab  mysql-python expect curl dnsutils parted 
@@ -33,6 +33,7 @@ source=(mv_install.py
 	README 
 	mv_advanced.py 
 	mv_common.py 
+	mv_ddns.py 
 	mv_ir.py 
 	mv_misc.py 
 	mv_network.py 
diff --git a/abs/core-testing/LinHES-config/mv_ddns.py b/abs/core-testing/LinHES-config/mv_ddns.py
new file mode 100755
index 0000000..8c05fbe
--- /dev/null
+++ b/abs/core-testing/LinHES-config/mv_ddns.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+import logging, mv_common
+import os, re
+
+config_file = "mv_config"
+
+def setup_ddns(systemconfig):
+    logging.info("____Start of setup_ddns____")
+
+    if systemconfig["DDnsEnable"] == "1":
+        logging.debug("    Enabling DDNS")
+	mv_common.cp_and_log("/etc/ddclient/ddclient.conf.dynamic.dyndns.sample", 
+	  		     "/etc/ddclient/ddclient.conf")
+	cmd = ''' sed -i -e "s/your-dynamic-dyndns-login/%s/g" /etc/ddclient/ddclient.conf''' %(systemconfig["DDnslogin"])
+	mv_common.runcmd(cmd)
+	cmd = ''' sed -i -e "s/your-dynamic-dyndns-password/%s/g" /etc/ddclient/ddclient.conf''' %(systemconfig["DDnspassword"])
+	mv_common.runcmd(cmd)
+	cmd = ''' sed -i -e "s/your-dynamic-dyndns-host/%s/g" /etc/ddclient/ddclient.conf''' %(systemconfig["DDnshostname"])
+	mv_common.runcmd(cmd)
+	mv_common.add_service("ddclient")
+    else:
+        logging.debug("    Disabling DDNS")
+	mv_common.remove_service("ddclient")
+
+    logging.info("__End of ddns\n")
diff --git a/abs/core-testing/LinHES-config/systemconfig.py b/abs/core-testing/LinHES-config/systemconfig.py
index c559e09..28e2e7a 100755
--- a/abs/core-testing/LinHES-config/systemconfig.py
+++ b/abs/core-testing/LinHES-config/systemconfig.py
@@ -147,7 +147,8 @@ def main(argv):
         mv_webuser.setup_web_auth(systemconfig["UseMythWEB_auth"])
 
     if cmdmodule["ddns"]:
-        print " LOOK FOR DDNS"
+        import mv_ddns
+        mv_ddns.setup_ddns(systemconfig)
 
     if cmdmodule["screensaver"]:
         import mv_screensaver
diff --git a/abs/core-testing/runit-scripts/PKGBUILD b/abs/core-testing/runit-scripts/PKGBUILD
index 14297fd..3407502 100755
--- a/abs/core-testing/runit-scripts/PKGBUILD
+++ b/abs/core-testing/runit-scripts/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=runit-scripts
 pkgver=1.8.0
-pkgrel=96
+pkgrel=97
 pkgdesc="collection of startup scripts for runit"
 url="http://smarden.org/runit/"
 license="BSD"
diff --git a/abs/core-testing/runit-scripts/runitscripts/services/ddclient/run b/abs/core-testing/runit-scripts/runitscripts/services/ddclient/run
new file mode 100755
index 0000000..c5488f6
--- /dev/null
+++ b/abs/core-testing/runit-scripts/runitscripts/services/ddclient/run
@@ -0,0 +1,8 @@
+#!/bin/sh
+export TERM=linux
+. /etc/rc.conf
+. /etc/rc.d/functions
+stat_runit "Starting ddclient"
+
+
+exec /usr/sbin/ddclient -foreground &> /var/log/ddclient.log
diff --git a/abs/extra-testing/ddclient/ChangeLog b/abs/extra-testing/ddclient/ChangeLog
deleted file mode 100644
index 4520b69..0000000
--- a/abs/extra-testing/ddclient/ChangeLog
+++ /dev/null
@@ -1,22 +0,0 @@
-2008-08-07	Abhishek Dasgupta <abhidg@gmail.com>
-	
-	* ddclient 3.7.3-2
-	* added /etc/conf.d/ddclient for modifying
-	  daemon poll frequency. This overrides the
-	  setting specified in /etc/ddclient/ddclient.conf
-	  when ddclient is called as an rc script.
-
-2007-08-08  Alessio 'mOLOk' Bolognino <themolok@gmail.com>
-
-	* ddclient-3.7.3-1
-	* version bump
-	* GPL -> GPL2
-	* shortened pkgdesc
-
-2007-07-02  tardo <tardo@nagi-fanboi.net>
-
-	* Built for x86_64
-
-2007-06-29  Georg Grabler (STiAT) <ggrabler@gmail.com>
-	
-	* Version Bump to 3.7.2
diff --git a/abs/extra-testing/ddclient/PKGBUILD b/abs/extra-testing/ddclient/PKGBUILD
index 121d2c5..f283cb9 100644
--- a/abs/extra-testing/ddclient/PKGBUILD
+++ b/abs/extra-testing/ddclient/PKGBUILD
@@ -3,33 +3,31 @@
 # Contributor: David Rosenstrauch <darose@darose.net>
 
 pkgname=ddclient
-pkgver=3.7.3
-pkgrel=2
+pkgver=3.8.0
+pkgrel=1
 pkgdesc="Update dynamic DNS entries for accounts on many dynamic DNS services."
 arch=('i686' 'x86_64')
 url="http://ddclient.sourceforge.net/"
 license=('GPL2')
 depends=('perl' 'perl-io-socket-ssl')
-backup=('etc/ddclient/ddclient.conf' 'etc/conf.d/ddclient')
-install=ddclient.install
-source=(http://downloads.sourceforge.net/sourceforge/ddclient/ddclient-$pkgver.tar.bz2 ddclient.rc ddclient.conf.d)
+backup=('etc/ddclient.conf')
+source=(http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.bz2
+        ddclient.conf.dynamic.dyndns.sample
+        ddclient-foreground.patch)
 
 build() {
-  cd ${srcdir}/ddclient-${pkgver}
+  cd ${srcdir}/$pkgname-${pkgver}
+  patch < ${srcdir}/ddclient-foreground.patch
 
   # core files
   install -D -m755 ddclient ${pkgdir}/usr/sbin/ddclient
-  install -D -m755 ${srcdir}/ddclient.rc ${pkgdir}/etc/rc.d/ddclient
-  install -D -m600 sample-etc_ddclient.conf ${pkgdir}/etc/ddclient/ddclient.conf
-  install -D -m644 ${srcdir}/ddclient.conf.d ${pkgdir}/etc/conf.d/ddclient
+  install -D -m600 sample-etc_ddclient.conf ${pkgdir}/etc/ddclient/ddclient.conf.sample
+  install -D -m600 ${srcdir}/ddclient.conf.dynamic.dyndns.sample ${pkgdir}/etc/ddclient/
   install -d ${pkgdir}/var/cache/ddclient
 
   # additional instructions, sample configs
-  install -D -m644 README ${pkgdir}/etc/ddclient/samples/README
-  install -D -m644 sample-etc_cron.d_ddclient ${pkgdir}/etc/ddclient/samples/sample-etc_cron.d_ddclient
-  install -D -m644 sample-etc_dhcpc_dhcpcd-eth0.exe ${pkgdir}/etc/ddclient/samples/sample-etc_dhcpc_dhcpcd-eth0.exe
-  install -D -m644 sample-etc_ppp_ip-up.local ${pkgdir}/etc/ddclient/samples/sample-etc_ppp_ip-up.local
+  install -D -m644 README ${pkgdir}/etc/ddclient/README
 }
-md5sums=('f6a55bc68cf73ffe7e80d2fa5cd44f85'
-         '7035bf8132f3517a59167f61ee5e8b90'
-         'b8f39c82827776da948b76ef83544d33')
+md5sums=('6cac7a5eb1da781bfd4d98cef0b21f8e'
+         '4194825b9b4a7fcc1c57c2f5a4f6162b'
+         'd8ffc95f98f9afcb4a06a1e192220e35')
diff --git a/abs/extra-testing/ddclient/ddclient-foreground.patch b/abs/extra-testing/ddclient/ddclient-foreground.patch
new file mode 100644
index 0000000..a814ede
--- /dev/null
+++ b/abs/extra-testing/ddclient/ddclient-foreground.patch
@@ -0,0 +1,47 @@
+--- ../ddclient-orig/ddclient	2009-10-19 22:45:15.000000000 +1030
++++ ddclient	2009-10-19 22:50:11.000000000 +1030
+@@ -307,6 +307,7 @@
+ my %variables = (
+     'global-defaults'    => {
+ 	'daemon'              => setv(T_DELAY, 0, 0, 1, 0,                    interval('60s')),
++	'foreground'          => setv(T_BOOL,  0, 0, 1, 0,                    undef),
+ 	'file'                => setv(T_FILE,  0, 0, 1, "$etc$program.conf",  undef),
+ 	'cache'               => setv(T_FILE,  0, 0, 1, "$cachedir$program.cache", undef),
+ 	'pid'                 => setv(T_FILE,  0, 0, 1, "",                   undef),
+@@ -535,6 +536,7 @@
+     "usage: ${program} [options]",
+     "options are:",
+     [ "daemon",      "=s", "-daemon delay         : run as a daemon, specify delay as an interval." ],
++    [ "foreground",  "!",  "-foreground           : do not fork" ],
+     [ "proxy",       "=s", "-proxy host           : use 'host' as the HTTP proxy" ],
+     [ "server",      "=s", "-server host          : update DNS information on 'host'" ],
+     [ "protocol",    "=s", "-protocol type        : update protocol used" ],
+@@ -623,7 +625,10 @@
+ $SIG{'HUP'}    = sub { $caught_hup  = 1; };
+ $SIG{'TERM'}   = sub { $caught_term = 1; };
+ $SIG{'KILL'}   = sub { $caught_kill = 1; };
+-if (opt('daemon') && !opt('force')) {
++# don't fork() if foreground or force is on
++if (opt('foreground') || opt('force')) {
++    ;
++} elsif (opt('daemon')) {
+     $SIG{'CHLD'}   = 'IGNORE';
+     my $pid = fork;
+     if ($pid < 0) {
+@@ -633,12 +638,15 @@
+ 	exit 0;
+     }
+     $SIG{'CHLD'}   = 'DEFAULT';
+-    $opt{'syslog'} = 1;
+     open(STDOUT, ">/dev/null");
+     open(STDERR, ">/dev/null");
+     open(STDIN,  "</dev/null");
++}
+ 
++# write out the pid file if we're daemon'ized
++if(opt('daemon')) {
+     write_pid();
++    $opt{'syslog'} = 1;
+ }
+ 
+ umask 077;
diff --git a/abs/extra-testing/ddclient/ddclient.conf.d b/abs/extra-testing/ddclient/ddclient.conf.d
deleted file mode 100644
index 8b754a3..0000000
--- a/abs/extra-testing/ddclient/ddclient.conf.d
+++ /dev/null
@@ -1,2 +0,0 @@
-# Parameters passed to ddclient
-EXTRA_ARGS="-daemon 300"
diff --git a/abs/extra-testing/ddclient/ddclient.conf.dynamic.dyndns.sample b/abs/extra-testing/ddclient/ddclient.conf.dynamic.dyndns.sample
new file mode 100644
index 0000000..a492c8b
--- /dev/null
+++ b/abs/extra-testing/ddclient/ddclient.conf.dynamic.dyndns.sample
@@ -0,0 +1,162 @@
+######################################################################
+## 
+## $Id: sample-etc_ddclient.conf 102 2008-11-01 11:23:03Z wimpunk $
+##
+## Define default global variables with lines like:
+## 	var=value [, var=value]*
+## These values will be used for each following host unless overridden
+## with a local variable definition.
+##
+## Define local variables for one or more hosts with:
+## 	var=value [, var=value]* host.and.domain[,host2.and.domain...]
+##
+## Lines can be continued on the following line by ending the line
+## with a \
+##
+##
+## Warning: not all supported routers or dynamic DNS services 
+##          are mentioned here.
+##
+######################################################################
+daemon=300				# check every 300 seconds
+syslog=yes				# log update msgs to syslog
+mail=root				# mail all msgs to root
+mail-failure=root			# mail failed update msgs to root
+pid=/var/run/ddclient.pid		# record PID in file.
+ssl=yes					# use ssl-support.  Works with
+					# ssl-library
+# postscript=script			# run script after updating.  The
+					# new IP is added as argument.
+#
+#use=watchguard-soho,        fw=192.168.111.1:80	# via Watchguard's SOHO FW
+#use=netopia-r910,           fw=192.168.111.1:80	# via Netopia R910 FW
+#use=smc-barricade,          fw=192.168.123.254:80	# via SMC's Barricade FW
+#use=netgear-rt3xx,          fw=192.168.0.1:80		# via Netgear's internet FW
+#use=linksys,                fw=192.168.1.1:80		# via Linksys's internet FW
+#use=maxgate-ugate3x00,      fw=192.168.0.1:80		# via MaxGate's UGATE-3x00  FW
+#use=elsa-lancom-dsl10,      fw=10.0.0.254:80		# via ELSA LanCom DSL/10 DSL Router
+#use=elsa-lancom-dsl10-ch01, fw=10.0.0.254:80		# via ELSA LanCom DSL/10 DSL Router
+#use=elsa-lancom-dsl10-ch02, fw=10.0.0.254:80		# via ELSA LanCom DSL/10 DSL Router
+#use=alcatel-stp,            fw=10.0.0.138:80           # via Alcatel Speed Touch Pro
+#use=xsense-aero,            fw=192.168.1.1:80          # via Xsense Aero Router
+#use=allnet-1298,            fw=192.168.1.1:80          # via AllNet 1298 DSL Router
+#use=3com-oc-remote812,	     fw=192.168.0.254:80	# via 3com OfficeConnect Remote 812
+#use=e-tech,                 fw=192.168.1.1:80          # via E-tech Router
+#use=cayman-3220h,           fw=192.168.0.1:1080        # via Cayman 3220-H DSL Router
+#
+#fw-login=admin,             fw[REDACTED]		# FW login and password
+#
+## To obtain an IP address from FW status page (using fw-login, fw-password)
+#use=fw, fw=192.168.1.254/status.htm, fw-skip='IP Address' # found after IP Address
+#
+## To obtain an IP address from Web status page (using the proxy if defined)
+#use=web, web=checkip.dyndns.org/, web-skip='IP Address' # found after IP Address
+#
+#use=ip,                     ip=127.0.0.1	# via static IP's
+#use=if,                     if=eth0		# via interfaces
+use=web					# via web
+#
+#protocol=dyndns2				# default protocol
+#proxy=fasthttp.sympatico.ca:80			# default proxy
+#server=members.dyndns.org			# default server
+#server=members.dyndns.org:8245			# default server (bypassing proxies)
+
+login=your-dynamic-dyndns-login			# default login
+password=[REDACTED]		# default password
+#mx=mx.for.your.host				# default MX
+#backupmx=yes|no				# host is primary MX?
+#wildcard=yes|no				# add wildcard CNAME?
+
+##
+## dyndns.org dynamic addresses
+##
+## (supports variables: wildcard,mx,backupmx)
+##
+server=members.dyndns.org,		\
+protocol=dyndns2			\
+your-dynamic-dyndns-host
+
+##
+## dyndns.org static addresses
+##
+## (supports variables: wildcard,mx,backupmx)
+##
+# static=yes,				\
+# server=members.dyndns.org,		\
+# protocol=dyndns2			\
+# your-static-host.dyndns.org
+
+##
+##
+## dyndns.org custom addresses
+##
+## (supports variables: wildcard,mx,backupmx)
+##
+# custom=yes,				\
+# server=members.dyndns.org,		\
+# protocol=dyndns2			\
+# your-domain.top-level,your-other-domain.top-level
+
+##
+## ZoneEdit (zoneedit.com)
+##
+# server=dynamic.zoneedit.com, 		\
+# protocol=zoneedit1,			\
+# login=your-zoneedit-login,  		\
+# password=[REDACTED]	\
+# your.any.domain,your-2nd.any.dom
+
+##
+## EasyDNS (easydns.com)
+##
+# server=members.easydns.com, 		\
+# protocol=easydns,			\
+# login=your-easydns-login,  		\
+# password=[REDACTED]	\
+# your.any.domain,your-2nd.any.domain
+
+##
+## Hammernode (hn.org) dynamic addresses
+##
+# server=dup.hn.org,             	\
+# protocol=hammernode1,         	\
+# login=your-hn-login,           	\
+# password=[REDACTED]      	\
+# your-hn-host.hn.org,your-2nd-hn-host.hn.org
+
+##
+## dslreports.com dynamic-host monitoring
+##
+# server=members.dslreports.com		\
+# protocol=dslreports1,			\
+# login=dslreports-login,		\
+# password=[REDACTED]		\
+# dslreports-unique-id
+
+##
+## OrgDNS.org account-configuration
+##
+# use=web, web=members.orgdns.org/nic/ip
+# server=www.orgdns.org 		\
+# protocol=dyndns2 			\
+# login=yourLoginName 			\
+# password=[REDACTED] 		\
+# yourSubdomain.orgdns.org
+
+##
+## dnspark.com
+## (supports variables: mx, mxpri)
+##
+# use=web, web=ipdetect.dnspark.com, web-skip='Current Address:'
+# protocol=dnspark,			\
+# server=www.dnspark.com,		\
+# your-host.dnspark.com
+
+##
+## NameCheap (namecheap.com)
+##
+# protocol=namecheap,				\
+# server=dynamicdns.park-your-domain.com,	\
+# login=my-namecheap.com-login,			\
+# password=[REDACTED]		\
+# myhost.namecheap.com 
diff --git a/abs/extra-testing/ddclient/ddclient.install b/abs/extra-testing/ddclient/ddclient.install
deleted file mode 100644
index d6edc0e..0000000
--- a/abs/extra-testing/ddclient/ddclient.install
+++ /dev/null
@@ -1,41 +0,0 @@
-# arg 1:  the new package version
-post_install() {
-cat << EOM
-
-If you want to use ddclient with dhcpcd, cron or pppd,
-see /etc/ddclient/samples for further instructions.
-
-If you have ddclient in the DAEMONS array of /etc/rc.conf:
-- Change /etc/conf.d/ddclient according to your needs.
-- This setting OVERRIDES any setting in
-  /etc/ddclient/ddclient.conf
-
-EOM
-}
-
-# arg 1:  the new package version
-# arg 2:  the old package version
-post_upgrade() {
-  
-if [ -f /etc/ddclient/ddclient.cache ]; then
-	echo -n "Moving ddclient.cache from /etc/ddclient/ to /var/cache/ddclient/."
-	mv /etc/ddclient/ddclient.cache /var/cache/ddclient/
-	echo " (done)"
-fi
-
-if [ "$(vercmp $2 3.7.3-2)" -lt 0 ]; then
-cat << EOM
-
-If you have ddclient in the DAEMONS array of /etc/rc.conf:
-- Change /etc/conf.d/ddclient according to your needs.
-- This setting OVERRIDES any setting in
-  /etc/ddclient/ddclient.conf
-
-EOM
-fi
-
-}
-
-op=$1
-shift
-$op $*
diff --git a/abs/extra-testing/ddclient/ddclient.rc b/abs/extra-testing/ddclient/ddclient.rc
deleted file mode 100644
index a9093f7..0000000
--- a/abs/extra-testing/ddclient/ddclient.rc
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-
-[ -f /etc/conf.d/ddclient ] && . /etc/conf.d/ddclient
-
-. /etc/rc.conf
-. /etc/rc.d/functions
-
-PID=`pidof -o %PPID /usr/sbin/ddclient`
-case "$1" in
-  start)
-    stat_busy "Starting ddclient"
-    [ -z "$PID" ] && /usr/sbin/ddclient ${EXTRA_ARGS}
-    if [ $? -gt 0 ]; then
-      stat_fail
-    else
-      add_daemon ddclient
-      stat_done
-    fi
-    ;;
-  stop)
-    stat_busy "Stopping ddclient"
-    [ -n "$PID" ] && kill -15 $PID >/dev/null
-    if [ $? -gt 0 ]; then
-      stat_fail
-    else
-      rm_daemon ddclient
-      stat_done
-    fi
-    ;;
-  restart)
-    $0 stop
-    sleep 1
-    $0 start
-    ;;
-  *)
-    echo "usage: $0 {start|stop|restart}"  
-esac
-- 
cgit v0.12

