diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/publish-ip.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/publish-ip.sh b/src/publish-ip.sh new file mode 100644 index 0000000..7da41b9 --- /dev/null +++ b/src/publish-ip.sh | |||
@@ -0,0 +1,38 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | determine_lan_ip() | ||
4 | { | ||
5 | ip -4 -oneline addr show | | ||
6 | while read n dev _ ip rest; do | ||
7 | case "$rest" in | ||
8 | *'scope global'*) ;; | ||
9 | *) continue ;; | ||
10 | esac | ||
11 | case "$ip" in | ||
12 | 192.168.10.1/24) continue ;; | ||
13 | esac | ||
14 | echo ${ip%/*} | ||
15 | break | ||
16 | done | ||
17 | } | ||
18 | |||
19 | ssh_cryptonomic_net__known_hosts() | ||
20 | { | ||
21 | cat <<'END' | ||
22 | |1|ORqVRkqd0LO25vHCB0LezHAgwRE=|ih7EYLpvg9jpU86/0Od0N8Ur36c= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHkIETz7wmKd7TZgb3NPeUElZDjZqw2VPd8yDOBTj5UzUBmcgCyE1oCS3Oe1iO9zJWpPtG0QyYa29lKi+vN6pN4= | ||
23 | END | ||
24 | } | ||
25 | |||
26 | tmpfile=$(mktemp) || exit 1 | ||
27 | trap 'rm -f "$tmpfile"' EXIT | ||
28 | ssh_cryptonomic_net__known_hosts > "$tmpfile" | ||
29 | |||
30 | lan_ip=$(determine_lan_ip) | ||
31 | |||
32 | if [ "$lan_ip" ]; then | ||
33 | set -- lan "$lan_ip" | ||
34 | else | ||
35 | set -- | ||
36 | fi | ||
37 | |||
38 | ssh -o GlobalKnownHostsFile="$tmpfile" -i /var/cache/kiki/config/ssh_host_rsa_key dyndns@ssh.cryptonomic.net "$@" | ||