From ea08178a8514fba7a876c0cba60cc3562545c38d Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 11 Mar 2026 18:09:11 +0000 Subject: [PATCH] Add ipsender --- ipsender | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 ipsender diff --git a/ipsender b/ipsender new file mode 100644 index 0000000..ee09585 --- /dev/null +++ b/ipsender @@ -0,0 +1,25 @@ +#!/bin/bash + +#define path to private key +keypath=/path/to/jailed/key +#define where you want your publicip file to be stored on the nginx server +thetext=/home/user/publicip + +ip1=$(curl icanhazip.com 2>/dev/null) + +#backup for if curl icanhazip.com fails utilizing dig and opendns + +backupcheck() { + +local ip2=$(dig +short myip.opendns.com @resolver1.opendns.com) 2>/dev/null \ +&& echo "$ip2" > "$thetext" + +} + +#waiting 60 seconds before trying the dig fall back method +#this is in case the initial failure was due to a network blip +[ -z "$ip1" ] && sleep 60 && backupcheck || echo "$ip1" > "$thetext" + +#update scp to use the actual remote ip of your nameserver +#the -z check paired with the logical OR does nothing if both curl and dig failed to return an ip +[ -z "$(cat "$thetext")" ] || scp -i "$keypath" "$thetext" jaileduser@1.2.3.4:/nginx/homeip \ No newline at end of file