Created
July 26, 2020 21:32
-
-
Save fabian-mv/dd5b52743209745714c5ee185d51da40 to your computer and use it in GitHub Desktop.
script that checks if TOR service is running and working properly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
until $(systemctl is-active --quiet tor.service) | |
do | |
printf "Tor is \u001b[31mINACTIVE\u001b[0m, activating...\n" | |
sudo systemctl start tor.service | |
done | |
printf "Tor is \u001b[32mACTIVE\u001b[0m, checking IP address...\n" | |
TOR=$(curl --silent -x socks5h://127.0.0.1:9050 'http://httpbin.org/ip' | tac | tac | grep -Eo "([0-9]{1,3}[\.]){3}[0-9]{1,3}") | |
NONTOR=$(curl --silent 'http://httpbin.org/ip' | tac | tac | grep -Eo "([0-9]{1,3}[\.]){3}[0-9]{1,3}") | |
CODE=0 | |
if [[ "$TOR" != "$NONTOR" ]] | |
then | |
printf "Your IP address is \u001b[32mHIDDEN\u001b[0m.\n" | |
else | |
printf "Error: Your IP address is \u001b[31mNOT HIDDEN.\u001b[0m\n" | |
CODE=1 | |
fi | |
printf "Real IP address: \u001b[34m%s\u001b[0m\n" "$NONTOR" | |
printf "Routed IP address: \u001b[34m%s\u001b[0m\n" "$TOR" | |
echo | |
exit $CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment