Last active
June 19, 2020 09:55
-
-
Save Crossedfall/b65bac23e2fff95f1a9263668cf99a0a to your computer and use it in GitHub Desktop.
Automated setup of an Ubuntu wsl instance for Redbot development
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 | |
# | |
# Usage: curl -L wsl.crossedfall.io | bash | |
# | |
### Initial setup for pyenv ### | |
if [ ! -f ~/.bash_functions ]; then | |
echo -e "export PATH=\"$HOME/.pyenv/bin:$PATH\"\neval \"\$(pyenv init -)\"\neval \"\$(pyenv virtualenv-init -)\"" >> ~/.bashrc | |
touch ~/.bash_functions | |
echo -e "export PATH=\"$HOME/.pyenv/bin:$PATH\"\neval \"\$(pyenv init -)\"\neval \"\$(pyenv virtualenv-init -)\"" >> ~/.bash_functions | |
fi | |
### Check if root ### | |
if [[ $EUID > 0 ]] | |
then echo -e "\e[41mRunning with Sudo rights\e[0m" && exec sudo -- "$0" "$@" | |
fi | |
### Update and install requirements ### | |
apt update | |
DEBIAN_FRONTEND=noninteractive apt dist-upgrade -yq | |
DEBIAN_FRONTEND=noninteractive apt autoremove -yq | |
DEBIAN_FRONTEND=noninteractive apt install -yq build-essential libssl-dev zlib1g-dev libbz2-dev \ | |
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ | |
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git | |
### Install pyenv and create a virtualenv for redbot on the local user ### | |
sudo -H -u \#1000 -s <<'EOF' | |
source ~/.bash_functions | |
curl https://pyenv.run | bash | |
pyenv install 3.8.2 | |
pyenv global 3.8.2 | |
pyenv virtualenv redbot | |
EOF | |
### Reload session and install redbot (with tests) in the virtualenv ### | |
sudo -H -u \#1000 -s <<'EOF' | |
source ~/.bash_functions | |
pyenv activate redbot | |
pip install -U pip | |
pip install -U --no-cache-dir Red-Discordbot[Test] | |
rm -f ~/.bash_functions | |
EOF | |
echo -e "\nSystem upgraded and \e[41mRedbot\e[0m installed" | |
echo -e "=====================================" | |
echo -e "\e[92mReload or restart your terminal session to complete setup. Activate the redbot environment with: \e[4mpyenv activate redbot\e[24m. Leave the environment with \e[4mpyenv deactivate\e[24m.\e[0m\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment