Skip to content

Instantly share code, notes, and snippets.

@MacsInSpace
Forked from abn/install-homebrew-osx.sh
Created October 22, 2021 00:52
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 MacsInSpace/434fb3c225d39c31c67dc4d0179e5bf4 to your computer and use it in GitHub Desktop.
Save MacsInSpace/434fb3c225d39c31c67dc4d0179e5bf4 to your computer and use it in GitHub Desktop.
Install homebrew from behind a proxy on Mac OS X.
#!/usr/bin/env bash
# Based on: http://godlessheathenmemoirs.blogspot.com.au/2015/03/homebrew-aka-brew-on-mac-os-x-behind.html
function usage() {
echo 2>&1 ""
echo 2>&1 "usage: $(basename $0) PROXY_HOST PROXY_PORT"
exit 1
}
PROXY_HOST=${PROXY_HOST:-$1}
PROXY_PORT=${PROXY_PORT:-$2}
[ -z "${PROXY_HOST}" ] && { echo 1>&2 "PROXY_HOST not defined"; usage; }
[ -z "${PROXY_PORT}" ] && { echo 1>&2 "PROXY_PORT not defined"; usage; }
PROXY_URI=${PROXY_HOST}:${PROXY_PORT}
# export proxy environment configurations
declare -x HTTPS_PROXY="http://${PROXY_URI}"
declare -x HTTP_PROXY="http://${PROXY_URI}"
declare -x http_proxy="http://${PROXY_URI}"
declare -x https_proxy="http://${PROXY_URI}"
# ignore TLS issues when cloning from git (homebrew)
declare -x GIT_SSL_NO_VERIFY="1"
# there really should be a better way; sigh
# source: https://brew.sh/
ruby -e "$(curl -x http://${PROXY_URI} -fsSL -k https://raw.githubusercontent.com/Homebrew/install/master/install)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment