diff options
Diffstat (limited to 'bin/cryptonomic-dyndns-command')
-rwxr-xr-x | bin/cryptonomic-dyndns-command | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/bin/cryptonomic-dyndns-command b/bin/cryptonomic-dyndns-command index dc420d7..8e1cbce 100755 --- a/bin/cryptonomic-dyndns-command +++ b/bin/cryptonomic-dyndns-command | |||
@@ -9,7 +9,9 @@ sql_string() | |||
9 | 9 | ||
10 | powerdns_sqlite_add_replace_record() | 10 | powerdns_sqlite_add_replace_record() |
11 | { | 11 | { |
12 | local sql_new_domain="$(sql_string "$1.$3")" | 12 | local fqdn="$1.$3" |
13 | fqdn=${fqdn: -64 : 64} | ||
14 | local sql_new_domain="$(sql_string "$fqdn")" | ||
13 | local sql_ip_address="$(sql_string "$2")" | 15 | local sql_ip_address="$(sql_string "$2")" |
14 | local sql_domain="$(sql_string "$3")" | 16 | local sql_domain="$(sql_string "$3")" |
15 | local record_type="$(sql_string "$4")" | 17 | local record_type="$(sql_string "$4")" |
@@ -46,6 +48,10 @@ BEGIN; | |||
46 | WHERE name=$sql_domain; | 48 | WHERE name=$sql_domain; |
47 | COMMIT; | 49 | COMMIT; |
48 | END | 50 | END |
51 | r=$? | ||
52 | [ $r = 0 ] || return $r | ||
53 | |||
54 | printf '%s %s\n' "$fqdn" "$2" | ||
49 | } | 55 | } |
50 | 56 | ||
51 | add() | 57 | add() |
@@ -57,8 +63,7 @@ add() | |||
57 | *) exit 1 ;; | 63 | *) exit 1 ;; |
58 | esac | 64 | esac |
59 | 65 | ||
60 | powerdns_sqlite_add_replace_record "$1" "$2" "$domain" "$record_type" \ | 66 | powerdns_sqlite_add_replace_record "$1" "$2" "$domain" "$record_type" |
61 | && printf '%s %s\n' "$1.$domain $2" | ||
62 | } | 67 | } |
63 | 68 | ||
64 | main() | 69 | main() |
@@ -66,16 +71,15 @@ main() | |||
66 | add "$subdomain" "$ip_address" | 71 | add "$subdomain" "$ip_address" |
67 | 72 | ||
68 | set -- $SSH_ORIGINAL_COMMAND | 73 | set -- $SSH_ORIGINAL_COMMAND |
69 | while [ $# -ge 2 ]; do | 74 | while [ $# -ge 1 ]; do |
70 | d=$1 | 75 | d=$1 |
71 | ip=$2 | 76 | shift |
72 | shift 2 | ||
73 | 77 | ||
74 | case "$d" in | 78 | case "$d" in |
75 | *.*) continue;; | 79 | *.*) continue;; |
76 | esac | 80 | esac |
77 | 81 | ||
78 | add "$d.$subdomain" "$ip" | 82 | add "$d.$subdomain" "$ip_address" |
79 | done | 83 | done |
80 | } | 84 | } |
81 | 85 | ||