Skip to content

Instantly share code, notes, and snippets.

@panbanda
Last active January 1, 2016 22:06
Show Gist options
  • Save panbanda/b53227f2cba29bed9640 to your computer and use it in GitHub Desktop.
Save panbanda/b53227f2cba29bed9640 to your computer and use it in GitHub Desktop.
Unblock us cronjob IP updater
#!/bin/sh
# Variables (user specific)
userlogin="[email protected]"
userpassword="password"
# Environment
apiurl="https://api.unblock-us.com/login?$userlogin:$userpassword"
wgetcmd=$(which wget)
# Check if username and password are set.
if [ -z $userlogin ]
then
echo "No username set."
exit 1
elif [ -z $userpassword ]
then
echo "No password set."
exit 1
else
# Call the api
response=$($wgetcmd --no-check-certificate -qO- $apiurl)
# Check response from api
if [ "$response" = "active" ]; then
echo "IP address is active. You are good to go!"
exit 0
elif [ "$response" = "bad_password" ]; then
echo "Wrong username or password."
exit 1
elif [ "$response" = "not_found" ]; then
echo "Username not found."
exit 1
else
echo "Unknown error. Check api url or documentantion."
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment