Created
October 24, 2024 09:38
-
-
Save stephenturner/2b8b0814d915c8348cfa75928fbfef5a to your computer and use it in GitHub Desktop.
New VM setup script for Ubuntu 22.04
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
################################################################################ | |
# GCP/AWS setup script for general bioinformatics | |
# Base image: Ubuntu 22.04 LTS x86/64 | |
################################################################################ | |
# Make a directory in which to build stuff | |
sudo mkdir -p ${HOME}/build && sudo chmod 777 ${HOME}/build && cd ${HOME}/build | |
# Install system libs | |
sudo apt-get update | |
sudo apt-get install -y \ | |
apt-transport-https \ | |
build-essential \ | |
ca-certificates \ | |
cloud-guest-utils \ | |
curl \ | |
default-jre \ | |
f2c \ | |
gdebi-core \ | |
gnupg \ | |
libbz2-dev \ | |
libcurl4-openssl-dev \ | |
libffi-dev \ | |
libfontconfig1-dev \ | |
libfribidi-dev \ | |
libgsl0-dev \ | |
libgtextutils-dev \ | |
libharfbuzz-dev \ | |
libicu-dev \ | |
liblzma-dev \ | |
libncurses5-dev \ | |
libncursesw5-dev \ | |
libpcre3 \ | |
libpcre3-dev \ | |
libperl-dev \ | |
libreadline-dev \ | |
libssl-dev \ | |
libtiff-dev \ | |
libxml2-dev \ | |
locales \ | |
ncftp \ | |
pandoc \ | |
parallel \ | |
pkg-config \ | |
readline-doc \ | |
sudo \ | |
tcl \ | |
tk \ | |
tk-dev \ | |
tk-table \ | |
tmux \ | |
tzdata \ | |
unzip \ | |
vim \ | |
&& sleep 1 | |
# Optionally set the time zone (to the best time zone -- use Etc/UTC if you're not sure) | |
sudo timedatectl set-timezone America/New_York | |
# Set locale | |
sudo locale-gen en_US.UTF-8 | |
# Install latest version of R | |
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo gpg --dearmor -o /usr/share/keyrings/r-project.gpg | |
echo "deb [signed-by=/usr/share/keyrings/r-project.gpg] https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/" | sudo tee -a /etc/apt/sources.list.d/r-project.list | |
sudo apt update | |
sudo apt install -y r-base | |
echo 'options(repos = c(CRAN = "https://packagemanager.posit.co/cran/__linux__/jammy/latest"))' | sudo tee -a /usr/lib/R/etc/Rprofile.site | |
# # Install a specific version of R | |
# export R_VERSION="4.2.3" | |
# sudo curl -O https://cdn.rstudio.com/r/ubuntu-2204/pkgs/r-${R_VERSION}_1_amd64.deb | |
# sudo gdebi -n r-${R_VERSION}_1_amd64.deb | |
# sudo ln -s /opt/R/${R_VERSION}/bin/R /usr/local/bin/R | |
# sudo ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/local/bin/Rscript | |
# echo 'options(repos = c(CRAN = "https://packagemanager.posit.co/cran/__linux__/jammy/latest"))' | sudo tee -a /opt/R/4.2.3/lib/R/etc/Rprofile.site | |
# Install RStudio server | |
cd ${HOME}/build | |
wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2024.04.1-748-amd64.deb | |
sudo gdebi --non-interactive rstudio-server-2024.04.1-748-amd64.deb | |
# Install gcloud and gsutils | |
# https://cloud.google.com/sdk/docs/install#deb | |
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg | |
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list | |
sudo apt-get update && sudo apt-get install google-cloud-cli | |
# gcloud auth login | |
# GCSfuse | |
export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s` | |
echo "deb [signed-by=/usr/share/keyrings/cloud.google.asc] https://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list | |
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo tee /usr/share/keyrings/cloud.google.asc | |
sudo apt-get update | |
sudo apt-get install gcsfuse | |
# Nextflow | |
cd ${HOME}/build | |
# Get the latest build | |
wget -qO- https://get.nextflow.io | bash | |
sudo mv nextflow /usr/local/bin | |
sudo chmod 755 /usr/local/bin/nextflow | |
# Docker | |
sudo install -m 0755 -d /etc/apt/keyrings | |
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | |
sudo chmod a+r /etc/apt/keyrings/docker.asc | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ | |
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ | |
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
sudo apt-get update | |
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | |
sudo groupadd docker | |
sudo usermod -aG docker $USER | |
################################################################################ | |
# Domain specific tools | |
################################################################################ | |
# Seqkit | |
# https://github.com/shenwei356/seqkit/ | |
cd ${HOME}/build | |
VERSION_SEQKIT="2.8.1" | |
wget https://github.com/shenwei356/seqkit/releases/download/v${VERSION_SEQKIT}/seqkit_linux_amd64.tar.gz | |
tar xzf seqkit_linux_amd64.tar.gz | |
sudo mv seqkit /usr/local/bin | |
# fastp | |
# https://github.com/OpenGene/fastp | |
cd ${HOME}/build | |
wget http://opengene.org/fastp/fastp | |
chmod a+x ./fastp | |
sudo mv fastp /usr/local/bin | |
# Seqtk | |
# https://github.com/lh3/seqtk | |
cd ${HOME}/build | |
VERSION_SEQTK="1.4" | |
wget -q https://github.com/lh3/seqtk/archive/refs/tags/v${VERSION_SEQTK}.tar.gz | |
tar xzf v${VERSION_SEQTK}.tar.gz | |
cd seqtk-${VERSION_SEQTK} | |
make && sudo make install | |
# htslib, samtools, bcftools | |
VERSION_SAMTOOLS="1.20" | |
## htslib | |
cd ${HOME}/build | |
wget -q https://github.com/samtools/htslib/releases/download/${VERSION_SAMTOOLS}/htslib-${VERSION_SAMTOOLS}.tar.bz2 | |
tar xjf htslib-${VERSION_SAMTOOLS}.tar.bz2 | |
cd htslib-${VERSION_SAMTOOLS} | |
./configure && make -j4 && sudo make install | |
## bcftools | |
cd ${HOME}/build | |
wget -q https://github.com/samtools/bcftools/releases/download/${VERSION_SAMTOOLS}/bcftools-${VERSION_SAMTOOLS}.tar.bz2 | |
tar xjf bcftools-${VERSION_SAMTOOLS}.tar.bz2 | |
cd bcftools-${VERSION_SAMTOOLS} | |
./configure && make -j4 && sudo make install | |
# samtools | |
cd ${HOME}/build | |
wget -q https://github.com/samtools/samtools/releases/download/${VERSION_SAMTOOLS}/samtools-${VERSION_SAMTOOLS}.tar.bz2 | |
tar xjf samtools-${VERSION_SAMTOOLS}.tar.bz2 | |
cd samtools-${VERSION_SAMTOOLS} | |
./configure && make -j4 && sudo make install | |
# bedtools | |
# https://github.com/arq5x/bedtools2 | |
cd ${HOME}/build | |
VERSION_BEDTOOLS="2.31.1" | |
wget https://github.com/arq5x/bedtools2/releases/download/v${VERSION_BEDTOOLS}/bedtools-${VERSION_BEDTOOLS}.tar.gz | |
tar xzf bedtools-${VERSION_BEDTOOLS}.tar.gz | |
cd bedtools2 | |
make -j4 && sudo make install | |
# bwa | |
# https://github.com/lh3/bwa/ | |
VERSION_BWA="0.7.18" | |
cd ${HOME}/build | |
wget -q https://github.com/lh3/bwa/archive/refs/tags/v${VERSION_BWA}.tar.gz | |
tar xzf v${VERSION_BWA}.tar.gz | |
cd ${HOME}/build/bwa-${VERSION_BWA} | |
# make CC='gcc -fcommon' | |
make | |
sudo mv bwa /usr/local/bin/ | |
sudo mv bwa.1 /usr/local/share/man/man1 | |
# minimap2 | |
# https://github.com/lh3/minimap2/ | |
cd ${HOME}/build | |
VERSION_MINIMAP2="2.28" | |
wget -q https://github.com/lh3/minimap2/releases/download/v${VERSION_MINIMAP2}/minimap2-${VERSION_MINIMAP2}.tar.bz2 | |
tar xjf minimap2-${VERSION_MINIMAP2}.tar.bz2 | |
cd minimap2-${VERSION_MINIMAP2} | |
make | |
sudo mv minimap2 /usr/local/bin/ | |
sudo mv minimap2.1 /usr/local/share/man/man1 | |
# bowtie2 | |
# https://github.com/BenLangmead/bowtie2 | |
cd ${HOME}/build | |
VERSION_BOWTIE2="2.5.3" | |
wget https://github.com/BenLangmead/bowtie2/releases/download/v${VERSION_BOWTIE2}/bowtie2-${VERSION_BOWTIE2}-linux-x86_64.zip | |
unzip bowtie2-${VERSION_BOWTIE2}-linux-x86_64.zip | |
sudo mv bowtie2-${VERSION_BOWTIE2}-linux-x86_64/bowtie2* /usr/local/bin | |
# Clean up the build dir | |
cd && sudo rm -rf ${HOME}/build | |
################################################################################ | |
# Interactive installs and setup | |
################################################################################ | |
# Mamba | |
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh | |
bash Miniforge3-Linux-x86_64.sh | |
# Authorize gcloud | |
gcloud auth login | |
gcloud config set compute/region us-central1 | |
gcloud config set project your-project-id | |
# After adding an ssh key: Get dotfiles, and replace the Rprofile repos | |
cd ${HOME} | |
git clone [email protected]:stephenturner/dotfiles.git | |
cd dotfiles | |
./install.sh | |
# Optionally relocate docker data-root to a different disk | |
# Assumes new disk is mounted at /data | |
NEWDOCKERDIR=/data/docker | |
sudo systemctl stop docker | |
sudo systemctl stop docker.socket | |
sudo systemctl stop containerd | |
sudo mkdir -p $NEWDOCKERDIR | |
sudo mv /var/lib/docker $NEWDOCKERDIR | |
sudo vim /etc/docker/daemon.json | |
## Add the following (replace the directory with the correct path): | |
# { | |
# "data-root": "/data/docker" | |
# } | |
sudo systemctl start docker | |
docker info -f '{{ .DockerRootDir}}' | |
# Set up R profile to use RSPM | |
echo 'options(repos = c(CRAN = "https://packagemanager.posit.co/cran/__linux__/jammy/latest"))' >> ~/.Rprofile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment