Skip to content

Instantly share code, notes, and snippets.

@gerry
Created August 16, 2016 00:26
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 gerry/a03fcc467cf02caddd87996651c0b6b2 to your computer and use it in GitHub Desktop.
Save gerry/a03fcc467cf02caddd87996651c0b6b2 to your computer and use it in GitHub Desktop.
#!/bin/sh -e
HOSTNAME=us-california.privateinternetaccess.com
# host us-california.privateinternetaccess.com|cut -d' ' -f4|tr \\n ,
HOST_IPS=198.8.80.220,198.8.80.223,198.8.80.33,198.8.80.149,198.8.80.180,198.8.80.221,198.8.80.50,198.8.80.203,198.8.80.162,198.8.80.176,107.152.98.168,198.8.80.222,107.152.98.159
IP=$(echo $HOST_IPS | tr , \\n | shuf - | head -n 1)
if grep -q $HOSTNAME /etc/hosts; then
sed -i "s/.*$HOSTNAME/$IP $HOSTNAME/" /etc/hosts
else
echo $IP $HOSTNAME >> /etc/hosts
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment