Last active
March 4, 2024 22:02
-
-
Save josemarcosrf/99c06188256dde5ac0ccb525bb16acf8 to your computer and use it in GitHub Desktop.
Shell script to do the first setup install of utilities and minimum dev tools on a clean Ubuntu (Anaconda, Docker, ...)
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
#!/usr/bin/env bash | |
# set -e | |
# set -o pipefail | |
say() { | |
echo "$@" | sed \ | |
-e "s/\(\(@\(red\|magenta\|yellow\|blue\|magenta\|cyan\|white\|reset\|b\|u\)\)\+\)[[]\{2\}\(.*\)[]]\{2\}/\1\4@reset/g" \ | |
-e "s/@red/$(tput setaf 1)/g" \ | |
-e "s/@magenta/$(tput setaf 2)/g" \ | |
-e "s/@yellow/$(tput setaf 3)/g" \ | |
-e "s/@blue/$(tput setaf 4)/g" \ | |
-e "s/@magenta/$(tput setaf 5)/g" \ | |
-e "s/@cyan/$(tput setaf 6)/g" \ | |
-e "s/@white/$(tput setaf 7)/g" \ | |
-e "s/@reset/$(tput sgr0)/g" \ | |
-e "s/@b/$(tput bold)/g" \ | |
-e "s/@u/$(tput sgr 0 1)/g" | |
} | |
install_docker() { | |
say @magenta "================ Installing Docker Engine ================" | |
docker -v | |
if [ $? -ne 0 ]; then | |
# As per: https://docs.docker.com/engine/install/ubuntu/ | |
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 update | |
sudo apt install docker-ce docker-ce-cli containerd.io | |
# Post-installation | |
# As per: https://docs.docker.com/engine/install/linux-postinstall/ | |
sudo groupadd docker | |
sudo usermod -aG docker $USER | |
if [ $(getent group docker) ]; then | |
say @yello "group docker exists." | |
else | |
say @yello "gcreating group docker" | |
newgrp docker | |
fi | |
else | |
say @cyan "🥳 Docker already installed" | |
fi | |
} | |
install_docker_compose() { | |
say @magenta "================ Installing Docker Compose ================" | |
sudo curl \ | |
-L "https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-$(uname -s)-$(uname -m)" \ | |
-o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
docker-compose --version | |
} | |
install_conda() { | |
say @magenta "================ Installing Anaconda ================" | |
if [ ! -d anaconda3 ]; then | |
say @blue "> Installing Anaconda" | |
ANACONDAFILE=~/Downloads/Anaconda3-5.3.1-Linux-x86_64.sh | |
INSTALL_URL=https://repo.continuum.io/archive/Anaconda3-5.3.1-Linux-x86_64.sh | |
if [ -f "$ANACONDAFILE" ]; then | |
echo "$ANACONDAFILE exists." | |
else | |
say @blue "> Downloading Anaconda" | |
wget -O $ANACONDAFILE $INSTALL_URL | |
fi | |
bash $ANACONDAFILE # -b -p $HOME/Anaconda | |
# Mamba | |
say @blue "> Installing Mamba" | |
conda install -c conda-forge mamba | |
# install jupyterlab | |
mamba install -c conda-forge jupyterlab | |
# Activate conda | |
say @blue "> Creating Anaconda DL environment" | |
source ~/.bashrc && \ | |
conda create -y --name py36 python=3.6 && \ | |
conda activate py36 | |
else | |
say @cyan "🥳 Anaconda3 already installed!" | |
fi | |
} | |
install_oh_bash() { | |
INSTALL_URL=https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh | |
CUSTOM_THEMES=https://github.com/jmrf/oh-my-bash-custom-dir.git | |
FONTS=https://github.com/powerline/fonts.git | |
say @blue "> .oh-my-bash" | |
if [ ! -d .oh-my-bash ]; then | |
bash -c "$(curl -fsSL $INSTALL_URL)" | |
# Oh-my-bash custom themes | |
say @blue "> .oh-my-bash" | |
git clone $CUSTOM_THEMES | |
yes | cp -r oh-my-bash-custom-dir/* .oh-my-bash/custom | |
# powerline fonts | |
git clone $FONTS fonts | |
cd fonts && ./install.sh | |
else | |
say @cyan "🥳 oh-my-bash already installed" | |
fi | |
} | |
install_cdu() { | |
say @blue "> cdu" | |
if [ ! -f /usr/local/bin/cdu.pl ]; then | |
URL=http://arsunik.free.fr/prog/cdu.html | |
export CDUVER=$(curl -s $URL | grep -Po '(?<=cdu-)\d+\.\d+' | head -1) | |
curl -s http://arsunik.free.fr/pkg/cdu-$CDUVER.tar.gz | gunzip | tar x -O cdu-$CDUVER/cdu.pl >> cdu.pl | |
chmod +x cdu.pl | |
sudo mv cdu.pl /usr/local/bin/ | |
else | |
say @cyan "🥳 cdu already installed" | |
fi | |
} | |
install_duf() { | |
say @blue "> duf" | |
duf --version | |
if [ $? -ne 0 ]; then | |
wget https://github.com/muesli/duf/releases/download/v0.6.2/duf_0.6.2_linux_amd64.deb | |
sudo dpkg -i duf_0.6.2_linux_amd64.deb | |
rm duf_0.6.2_linux_amd64.deb | |
else | |
say @cyan "🥳 duf already installed" | |
fi | |
} | |
install_node() { | |
say @blue "> nvm & node" | |
export NVM_DIR="$HOME/.nvm" | |
if [ ! -d $NVM_DIR ]; then | |
# https://github.com/nvm-sh/nvm#installing-and-updating | |
INSTALL_URL=https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | |
curl -o- $INSTALL_URL | bash | |
else | |
say @cyan "🥳 nvm already installed" | |
fi | |
source ~/.bashrc | |
node --version | |
if [ $? -ne 0 ]; then | |
nvm install node | |
else | |
say @cyan "🥳 node already installed" | |
fi | |
} | |
install_subl() { | |
say @blue "> .rmate" | |
if [ ! -f /usr/local/bin/rmate ]; then | |
# https://github.com/sclukey/rmate-python | |
wget https://raw.githubusercontent.com/sclukey/rmate-python/master/bin/rmate | |
chmod +x ./rmate | |
sudo mv ./rmate /usr/local/bin/ | |
else | |
say @cyan "🥳 rmate already installed" | |
fi | |
} | |
# Update packages and install basics | |
sudo apt update | |
sudo apt -y upgrade | |
sudo apt install -qq -y \ | |
apt-transport-https \ | |
ca-certificates \ | |
cmake \ | |
curl \ | |
g++ \ | |
git-all git-core git-gui git-doc \ | |
gnupg-agent \ | |
jq \ | |
software-properties-common \ | |
tmux \ | |
unzip \ | |
ncdu \ | |
vim \ | |
xclip \ | |
gnupg2 pass #docker seems to need these to to do 'docker login' correctly | |
mkdir -p Downloads | |
# Docker & Docker-compose | |
install_docker | |
install_docker_compose | |
# Anaconda | |
install_conda | |
( | |
# Install utilities | |
say @magenta "================ Installing Utilities ================" | |
# Install cdu | |
install_cdu | |
# Install Duf | |
install_duf | |
# Install NVM & Node | |
install_node | |
# Rmate (remote sublime) | |
install_subl | |
# bPyTop | |
say @blue "> bpytop" | |
pip install bpytop --upgrade | |
say @blue "> tmux" | |
if [ ! -f .tmux.conf ]; then | |
wget https://raw.githubusercontent.com/jmrf/tmux-conf-backup/master/.tmux.conf -O .tmux.conf | |
fi | |
# Install oh-my-bash. | |
# NOTE: This must be the last step! | |
install_oh_bash | |
) || say @red "Problem installing Utilities..." | |
say @blue "> .Update SSH service to accept several key formats" | |
sudo echo "PubkeyAcceptedKeyTypes ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512" >> /etc/ssh/sshd_config | |
sudo systemctl restart ssh.service | |
# TODO: install rclone | |
# TODO: install Tensorflow / Pytorch? |
Author
josemarcosrf
commented
Jan 19, 2021
NOTE: To make
conda
usemamba
as dependency solver (See a-faster-conda):
conda install -n base conda-libmamba-solver
conda config --set solver libmamba
Useful docker
configurations:
- Enable experimental features
- Enable
nvidia
runtime
- Open
/etc/docker/daemon.json
and paste:
{
"experimental": true,
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
-
Restart the docker deamon:
sudo systemctl restart docker
-
docker version
should show experimental features enabled
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment