TXT record generation
authorChristian Weiske <cweiske@cweiske.de>
Wed, 21 Aug 2013 19:18:46 +0000 (21:18 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Wed, 21 Aug 2013 19:18:46 +0000 (21:18 +0200)
README.rst
ssh-dyndns

index 34341e62edecab14b4e30eaee598e56eaecacc62..8c84931f3efaaa38e6162c1792da7fc963d65eba 100644 (file)
@@ -10,6 +10,7 @@ SSH provides secure, password-less key-based authentication.
 
 Upon login, the remote IP is used to create/update a tinydns file with the
 DNS record for a hostname given by the SSH client.
+In addition to the IP record, a TXT record with the update time will be added.
 
 tinydns is part of the dbjdns/dbndns package.
 
@@ -116,6 +117,26 @@ compile the ``data.cdb`` file.
 tinydns will automatically pick up the change.
 
 
+Test
+====
+You can test it locally:
+
+1. Create config file::
+
+     $ cp ssh-dyndns.sh.config-dist ~/.config/ssh-dyndns.sh
+
+2. Create dummy makefile::
+
+     $ touch /tmp/Makefile
+
+3. Run it::
+
+     $ SSH_CLIENT=192.168.1.4 SSH_CONNECTION=1 ./ssh-dyndns foo home.example.org
+
+4. See generated file::
+
+     $ cat /tmp/data-dyndns-home.example.org
+
 ====
 Bugs
 ====
index 67a13d9a66235c3fdbafea0e5ffd5546af67a2c9..cbbb1cd543bd5a0fed002253f0201d230974861e 100755 (executable)
@@ -76,7 +76,7 @@ djbdnsline="=${domain}:${remoteip}:${timeout}"
 
 update=1
 if [ -f "$datafile" ]; then
-    currentdata=`cat "$datafile"`
+    currentdata=`head -n1 "$datafile"|tr -d '\n'`
     if [ "$currentdata" = "$djbdnsline" ]; then
         #no need to update
         update=0
@@ -88,6 +88,11 @@ fi
 
 echo $djbdnsline > $datafile
 
+#TXT record with last update
+date=`date --rfc-3339=seconds|tr : .|tr -d '\n'`
+djbdnsTxtLine="'${domain}:Last update ${date}.:${timeout}"
+echo $djbdnsTxtLine >> $datafile
+
 #compile dns data
 cd "$data_dir"
 sudo make