Skip to content

Instantly share code, notes, and snippets.

@vchatela
Created November 24, 2020 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vchatela/77b003cff9a5c3489c6fd242e52f7bf4 to your computer and use it in GitHub Desktop.
Save vchatela/77b003cff9a5c3489c6fd242e52f7bf4 to your computer and use it in GitHub Desktop.
Script to compare NAS IP and transmission-openvpn docker IP to make sure NAS IP isn't exposed !
#$ sudo docker ps
#CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
#XXXXX haugene/transmission-openvpn:latest "dumb-init /etc/open…" 44 hours ago Up 41 hours (healthy) 0.0.0.0:8888->8888/tcp, 0.0.0.0:9091->9091/tcp haugene-transmission-openvpn1
function notify {
echo "ERROR"
exit -1
}
error=0
nas_ip=$(curl -s http://whatismyip.akamai.com/)
if [[ $nas_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "NAS_IP = $nas_ip"
# send info to jeedom
notify
else
echo "NAS_IP hasn't been validated as IP address : $nas_ip"
notify
error=1
fi
container_ip=$(docker exec haugene-transmission-openvpn1 /bin/bash -c 'curl -s http://whatismyip.akamai.com/')
if [[ $nas_ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Container_IP = $container_ip"
notify
else
echo "Container_IP hasn't been validated as IP address : $container_ip"
notify
error=1
fi
if [ "$nas_ip" = "$container_ip" ]; then
echo "ERROR : same IP for both !!"
error=1
fi
if [ $error -eq 1 ]; then
exit -2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment