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"
21 echo Missing argument: domain name
27 if [ -f ~/.config/ssh-dyndns.sh ]; then
28 . ~/.config/ssh-dyndns.sh
30 if [ -f /etc/ssh-dyndns.sh ]; then
34 if [ -z "$data_dir" ]; then
35 echo '$data_dir not set'
38 if [ ! -d "$data_dir" ]; then
39 echo "$data_dir does not exist"
42 if [ ! -f "$data_dir/Makefile" ]; then
43 echo "$data_dir misses Makefile"
47 if [ ! -z "$domain_patterns" ]; then
49 for single_dp in $domain_patterns; do
54 if [ $ok -ne 1 ]; then
55 echo "Domain \"$domain\" does not match \$domain_pattern"
61 file_pattern="${file_pattern:-data-dyndns-%DOMAIN%}"
62 timeout=${timeout:-300}
64 datafile=${data_dir}`echo $file_pattern | sed "s/%DOMAIN%/$domain/"`
66 if [ `echo "$remoteip"| sed "s/://"` != "$remoteip" ]; then
67 echo "IPv6 not supported yet"
68 # we need ipv6 address expansion
72 #=cweiske.de:5.35.241.22
73 djbdnsline="=${domain}:${remoteip}:${timeout}"
74 #FIXME: do not update if nothing changed
75 echo $djbdnsline > $datafile