Skip to content

Instantly share code, notes, and snippets.

@igilham
Created October 3, 2014 16:23
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 igilham/3cca2cd7bfaa7cd56383 to your computer and use it in GitHub Desktop.
Save igilham/3cca2cd7bfaa7cd56383 to your computer and use it in GitHub Desktop.
Enable/Disable proxy settings defined elsewhere
#!/bin/bash
# Toggle proxy settings.
# It will be necessary to reload ${HOME}/.profile after running this.
USAGE="usage: ${0} on|off|status"
if [[ "d${PROXY_FILE}d" == "dd" ]]; then
echo "PROXY_FILE undefined" >&2
exit 1
fi
if [[ $# -ne 1 ]]; then
echo ${USAGE} >&2
exit 1
elif [[ "$1" == "status" ]]; then
if [[ -f "${PROXY_FILE}" ]]; then
echo "proxy ON"
else
echo "proxy OFF"
fi
elif [[ "$1" == "on" ]]; then
touch ${PROXY_FILE}
elif [[ "$1" == "off" ]]; then
if [[ -f ${PROXY_FILE} ]]; then
rm -f ${PROXY_FILE}
fi
else
echo ${USAGE} >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment