add script
This commit is contained in:
commit
4ccfee47df
22
react_to_ip_change.sh
Normal file
22
react_to_ip_change.sh
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
IP_FILE='/tmp/ipaddress'
|
||||||
|
|
||||||
|
[[ -f "${IP_FILE}" ]] && IP_OLD="$(< "${IP_FILE}" )"
|
||||||
|
|
||||||
|
IP_NEW="$(curl -s -4 http://icanhazip.com/)"
|
||||||
|
|
||||||
|
# work around to report IP to root server
|
||||||
|
ssh wiebelbach@lusiardi.de -i ~/.ssh/id_rsa_update_ip "echo $IP_NEW > IP"
|
||||||
|
|
||||||
|
if [[ "${IP_OLD}" != "${IP_NEW}" ]]; then
|
||||||
|
echo "change from ${IP_OLD} to ${IP_NEW}"
|
||||||
|
echo ${IP_NEW} > ${IP_FILE}
|
||||||
|
for SCRIPT in `ls /usr/local/etc/ipchange.d/*.sh`
|
||||||
|
do
|
||||||
|
${SCRIPT} ${IP_NEW}
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "no update required (still ${IP_OLD})"
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user