Last active
January 16, 2020 20:06
-
-
Save NathanWorkman/ed68c5b1f29f04f58a7599b1708ba0d0 to your computer and use it in GitHub Desktop.
[WIP] Bash script to setup your WSL2 environment for development before ultimately deciding to buy a new MacBook Pro anyway. Setups up Docker, Docker Compose, Python/Pyenv, Node/nvm, GoLang, Ruby/rvm.
This file contains hidden or 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 | |
| echo "Good afternoon, gentlemen. I am a HAL 9000 computer." | |
| CURRENTDIRECTORY="$(dirname $(readlink -f "$0"))" | |
| echo "Initializing from : $CURRENTDIRECTORY" | |
| ################## | |
| # Setup | |
| ################## | |
| echo "#########################################################" | |
| echo "## Checking for latest packages ##" | |
| sudo apt-get update | |
| echo "## Checking for latest packages ##" | |
| sudo apt-get install git apt-transport-https ca-certificates curl software-properties-common build-essential gettext && \ | |
| libssl-dev libreadline-dev zlib1g-dev libgtk2.0-0 libbz2-dev libxml2-dev libdb-dev gedit && \ | |
| pcmanfm ccache libffi-dev mercurial make binutils bison gcc | |
| ################## | |
| # Docker / Compose | |
| ################## | |
| echo "#########################################################" | |
| echo "## Setting up Docker and docker-compose ##" | |
| echo "## Adding Docker app repository ##" | |
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
| sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
| sudo apt-get update | |
| echo "## Installing Docker-CE ##" | |
| sudo apt-get install docker-ce | |
| echo "## Installing docker-compose ##" | |
| sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose | |
| echo "## Adding user to docker group ##" | |
| sudo groupadd docker | |
| sudo usermod -aG docker $USER | |
| echo "## Updating docker permissions ##" | |
| sudo chmod +x /usr/local/bin/docker-compose | |
| sudo chown root:docker /var/run/docker.sock | |
| echo "## Starting docker ##" | |
| sudo systemctl enable docker | |
| ################## | |
| # Python / PyEnv | |
| ################## | |
| echo "#########################################################" | |
| echo "## Setting up Python, PyEnv, and VirtualEnv ##" | |
| curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash | |
| git clone git://github.com/yyuu/pyenv-pip-migrate.git ~/.pyenv/plugins/pyenv-pip-migrate | |
| git clone https://github.com/yyuu/pyenv-ccache.git ~/.pyenv/plugins/pyenv-ccache | |
| git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv | |
| if ! grep -qc 'pyenv init' ~/.bashrc ; then | |
| echo "## Adding pyenv to .bashrc ##" | |
| echo >> ~/.bashrc | |
| echo "## Setting up Pyenv ##" >> ~/.bashrc | |
| echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc | |
| echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc | |
| echo 'eval "$(pyenv init -)"' >> ~/.bashrc | |
| echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc | |
| fi | |
| export PYENV_ROOT="$HOME/.pyenv" | |
| export PATH="$PYENV_ROOT/bin:$PATH" | |
| eval "$(pyenv init -)" | |
| echo "## Installing common Python versions.... ##" | |
| echo "## ...Python:2.7.15 ##" | |
| pyenv install 2.7.15 | |
| echo "## ...Python:3.6.8 ##" | |
| pyenv install 3.6.8 | |
| echo "## ...Python:3.8.1 ##" | |
| pyenv install 3.8.1 | |
| echo "## Adding PyEnv Versions Global" | |
| pyenv global 2.7.15 3.6.8 3.8.1 | |
| ################## | |
| # HAL / 9000 | |
| ################## | |
| echo " " | |
| echo "I am putting myself to the fullest possible use, which is all I think that any conscious entity can ever hope to do." | |
| echo " " | |
| ################## | |
| # Node / NVM | |
| ################## | |
| echo "#########################################################" | |
| echo "## Setting up Node, NVM, and Yarn ##" | |
| echo >> ~/.bashrc | |
| echo "# Installing NVM" >> ~/.bashrc | |
| curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash | |
| export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm | |
| [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
| echo "## Installing Node:LTS ##" | |
| nvm install --lts | |
| echo "## Installing Node:Latest ##" | |
| nvm install node | |
| echo "## Defaulting to Node:LTS ##" | |
| nvm use --lts | |
| ################## | |
| # Ruby / RVM | |
| ################## | |
| echo "#########################################################" | |
| echo "## Setting up Ruby and rbenv ##" | |
| export PATH="$HOME/.rbenv/bin:$PATH" | |
| echo "## Installing rbenv ##" | |
| curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash | |
| cd ~/.rbenv && src/configure && make -C src # install dynamic bash extension | |
| if ! grep -qc 'rbenv init' ~/.bashrc ; then | |
| echo "## Adding rbenv to .bashrc ##" | |
| echo >> ~/.bashrc | |
| echo "# Set up Rbenv" >> ~/.bashrc | |
| echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc | |
| echo 'eval "$(rbenv init -)"' >> ~/.bashrc | |
| fi | |
| echo "## Initializing rbenv ##" | |
| eval "$(rbenv init -)" | |
| echo "## Installing latest Ruby version Ruby:2.7.0 ##" | |
| rbenv install 2.7.0 | |
| rbenv global 2.7.0 | |
| # skip overwrite confirmation | |
| rm ~/.rbenv/versions/2.7.0/bin/rdoc | |
| rm ~/.rbenv/versions/2.7.0/bin/ri | |
| echo "## Updating Ruby and Gems ##" | |
| gem update --system | |
| gem update | |
| ################## | |
| # Golang / GVM | |
| ################## | |
| echo "#########################################################" | |
| echo "## Setting Golang and GVM ##" | |
| echo "## Installing GVM ##" | |
| bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) | |
| echo "## Installing Go:1.4.0 for C bindings ##" | |
| gvm install go1.4 -B | |
| gvm use go1.4 | |
| echo "## Adding Go root ##" | |
| export GOROOT_BOOTSTRAP=$GOROOT | |
| echo "## Installing latest Go:1.13.5 ##" | |
| gvm install go1.13.5 | |
| echo "## Use Go:1.13.5 as default ##" | |
| gvm use go1.13.5 | |
| ########################### | |
| # Postgres / MySQL / Redis | |
| ########################### | |
| echo "#########################################################" | |
| echo "## Setting up Common DB's ##" | |
| echo "## Setting up PostgreSQL ##" | |
| echo "## Setting up MySQL ##" | |
| echo "## Setting up Redis ##" | |
| echo " " | |
| echo "Dave, this conversation can serve no purpose anymore. Goodbye." | |
| echo " " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment