Last active
November 4, 2019 10:54
-
-
Save rigwild/5ec6325f57dc5d64077267b60b4050b1 to your computer and use it in GitHub Desktop.
Configure a linux machine with a http proxy and nodejs
This file contains 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 | |
## Linux configuration script | |
## Create the `proxy_http` file containing your http proxy: | |
# https://username:[email protected]:8080 | |
## Can be automatically started in `.bashrc` | |
## with `source autoconfig.sh &> /dev/null` | |
export proxy_http=$(cat ./proxy_http) | |
export proxy_https=$proxy_http | |
export PROXY_HTTP=$proxy_http | |
export PROXY_HTTPS=$proxy_http | |
export http_proxy=$proxy_http | |
export https_proxy=$proxy_http | |
export HTTP_PROXY=$proxy_http | |
export HTTPS_PROXY=$proxy_http | |
echo "Configuring the system with the following proxy:" | |
echo "" | |
echo "PROXY_HTTP=$PROXY_HTTP" | |
echo "PROXY_HTTPS=$PROXY_HTTPS" | |
echo "" | |
# Configure http proxy | |
npm config set proxy $PROXY_HTTP | |
npm config set https-proxy $PROXY_HTTPS | |
yarn config set proxy $PROXY_HTTP | |
yarn config set https-proxy $PROXY_HTTPS | |
git config --global http.proxy $PROXY_HTTP | |
git config --global https.proxy $PROXY_HTTPS | |
# Add yarn and npm user's globally installed packages to path | |
PATH="$HOME/.npm/bin:$PATH" | |
PATH="$HOME/.yarn/bin:$PATH" | |
# Configure npm and yarn to install global packages in user's home directory | |
npm config set prefix $HOME/.npm | |
yarn config set prefix $HOME/.yarn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment