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" >&2
14 remoteip=${SSH_CLIENT%% *}
15 if [ -z "$remoteip" ]; then
16 echo "ssh client IP not found" >&2
20 #TODO: allow removal of domains
21 #TODO: support multiple domains
23 echo Missing argument: domain name >&2
29 if [ -f ~/.config/ssh-dyndns.sh ]; then
30 . ~/.config/ssh-dyndns.sh
32 if [ -f /etc/ssh-dyndns.sh ]; then
36 if [ -z "$data_dir" ]; then
37 echo '$data_dir not set' >&2
40 if [ ! -d "$data_dir" ]; then
41 echo "$data_dir does not exist" >&2
44 if [ ! -f "$data_dir/Makefile" ]; then
45 echo "$data_dir misses Makefile" >&2
49 if [ ! -z "$domain_patterns" ]; then
51 for single_dp in $domain_patterns; do
56 if [ $ok -ne 1 ]; then
57 echo "Domain \"$domain\" does not match \$domain_pattern" >&2
63 file_pattern="${file_pattern:-data-dyndns-%DOMAIN%}"
64 timeout=${timeout:-300}
66 datafile=${data_dir}`echo $file_pattern | sed "s/%DOMAIN%/$domain/"`
68 if [ `echo "$remoteip"| sed "s/://"` != "$remoteip" ]; then
69 echo "IPv6 not supported yet" >&2
70 # we need ipv6 address expansion
74 #=cweiske.de:5.35.241.22
75 djbdnsline="=${domain}:${remoteip}:${timeout}"
78 if [ -f "$datafile" ]; then
79 currentdata=`cat "$datafile"`
80 if [ "$currentdata" = "$djbdnsline" ]; then
85 if [ $update -eq 0 ]; then
89 echo $djbdnsline > $datafile