2 # dyndns via ssh login + tinydns (djbdns/dbndns)
5 # $ ssh dyndns@example.org home.example.org
7 # @author Christian Weiske <cweiske@cweiske.de>
9 if [ -z "$SSH_CONNECTION" ]; then
10 echo "no ssh connection"
14 remoteip=${SSH_CLIENT%% *}
15 if [ -z "$remoteip" ]; then
16 echo "ssh client IP not found"
20 #TODO: support multiple domains
22 echo Missing argument: domain name
28 if [ -f ~/.config/ssh-dyndns.sh ]; then
29 . ~/.config/ssh-dyndns.sh
31 if [ -f /etc/ssh-dyndns.sh ]; then
35 if [ -z "$data_dir" ]; then
36 echo '$data_dir not set'
39 if [ ! -d "$data_dir" ]; then
40 echo "$data_dir does not exist"
43 if [ ! -f "$data_dir/Makefile" ]; then
44 echo "$data_dir misses Makefile"
48 if [ ! -z "$domain_patterns" ]; then
50 for single_dp in $domain_patterns; do
55 if [ $ok -ne 1 ]; then
56 echo "Domain \"$domain\" does not match \$domain_pattern"
62 file_pattern="${file_pattern:-data-dyndns-%DOMAIN%}"
63 timeout=${timeout:-300}
65 datafile=${data_dir}`echo $file_pattern | sed "s/%DOMAIN%/$domain/"`
67 if [ `echo "$remoteip"| sed "s/://"` != "$remoteip" ]; then
68 echo "IPv6 not supported yet"
69 # we need ipv6 address expansion
73 #=cweiske.de:5.35.241.22
74 djbdnsline="=${domain}:${remoteip}:${timeout}"
77 if [ -f "$datafile" ]; then
78 currentdata=`cat "$datafile"`
79 if [ "$currentdata" = "$djbdnsline" ]; then
84 if [ $update -eq 0 ]; then
88 echo $djbdnsline > $datafile