Last active
December 5, 2018 17:06
-
-
Save ttowncompiled/ddc42068d22c0748d41dbb5e697c362e to your computer and use it in GitHub Desktop.
A small script to setup a Raspberry Pi in a Pi cluster.
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 | |
ENDC='\033[0m' | |
CYAN='\033[0;36m' | |
GREEN='\033[0;32m' | |
RED='\033[0;31m' | |
YELLOW='\033[0;33m' | |
# update repositories, upgrade current packages, and remove deprecated packages | |
echo -e "${CYAN}>>> Updating, Upgrading, and Autoremoving...${ENDC}" | |
sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get autoremove -y | |
# perform dist-upgrade | |
echo -e "${CYAN}>>> Performing dist upgrade...${ENDC}" | |
sudo apt-get dist-upgrade -y | |
# install tools | |
echo -e "${CYAN}>>> Installing tools...${ENDC}" | |
sudo apt-get install -y curl wget apt-transport-https make cmake software-properties-common build-essential gnupg zip unzip git vim libxss1 libappindicator1 libindicator7 pssh | |
# install Vim plug | |
if ! [ -f "$HOME/.vim/autoload/plug.vim" ] ; then | |
echo -e "${CYAN}>>> Installing Vim plug...${ENDC}" | |
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
else | |
echo -e "${YELLOW}>>> Vim plug already installed!${ENDC}" | |
fi | |
# download .vimrc | |
if ! [ -f "$HOME/.vimrc" ] ; then | |
echo -e "${CYAN}>>> Downloading vimrc from gist...${ENDC}" | |
curl https://gist.githubusercontent.com/ttowncompiled/b9083bf4ea1df769048c586c7e86f381/raw/vimrc-pi >> ~/.vimrc | |
else | |
echo -e "${YELLOW}>>> vimrc already exists!${ENDC}" | |
echo -e "${RED}>>> Overwriting vimrc...${ENDC}" | |
rm ~/.vimrc | |
echo -e "${CYAN}>>> Downloading vimrc from gist...${ENDC}" | |
curl https://gist.githubusercontent.com/ttowncompiled/b9083bf4ea1df769048c586c7e86f381/raw/vimrc-pi >> ~/.vimrc | |
fi | |
# install c/c++ | |
if ! [ -x "$(command -v gcc)" ] ; then | |
echo -e "${CYAN}>>> Installing C...${ENDC}" | |
sudo apt-get install -y gcc | |
else | |
echo -e "${YELLOW}>>> C is already installed!${ENDC}" | |
fi | |
if ! [ -x "$(command -v g++)" ] ; then | |
echo -e "${CYAN}>>> Installing C++...${ENDC}" | |
sudo apt-get install -y g++ | |
else | |
echo -e "${YELLOW}>>> C++ is already installed!${ENDC}" | |
fi | |
# install open MPI --- must be installed after gcc/g++ | |
if ! [ -x "$(command -v mpicc)" ] ; then | |
echo -e "${CYAN}>>> Installing OpenMPI...${ENDC}" | |
sudo apt-get install -y mpich openmpi-bin openmpi-common openmpi-doc openssh-server openssh-client libopenmpi-dev libopenmpi2 | |
else | |
echo -e "${YELLOW}>>> OpenMPI and MPICH are already installed!${ENDC}" | |
fi | |
# install python 3 and python deps | |
if [ "$1" == "--python" ] ; then | |
echo -e "${CYAN}>>> Installing Python3-dev, pip3, and mypy...${ENDC}" | |
sudo apt-get install -y python3-dev python3-pip mypy | |
sudo python3 -m pip install --upgrade pip setuptools wheel virtualenv ipython numpy scipy pandas requests typing flake8 flake8-mypy | |
fi | |
# install python 2 and python deps | |
if [ "$1" == "--python" ] ; then | |
echo -e "${CYAN}>>> Installing Python-dev and pip...${ENDC}" | |
sudo apt-get install -y python-dev python-pip | |
sudo python -m pip install --upgrade pip setuptools wheel virtualenv ipython numpy scipy pandas requests flake8 | |
fi | |
# install mpi4py | |
if [ "$1" == "--python" ] ; then | |
echo -e "${CYAN}>>> Installing mpi4py...${ENDC}" | |
cd ~ | |
echo -e "${CYAN}>>> Downloading mpi4py...${ENDC}" | |
wget https://bitbucket.org/mpi4py/mpi4py/downloads/mpi4py-3.0.0.tar.gz | |
sudo apt-get update --fix-missing | |
tar -zxf mpi4py-3.0.0.tar.gz | |
rm mpi4py-3.0.0.tar.gz | |
cd mpi4py-3.0.0 | |
echo -e "${CYAN}>>> Installing for Python3...${ENDC}" | |
sudo python3 setup.py build --mpicc=/usr/bin/mpicc | |
sudo python3 setup.py install | |
echo -e "${CYAN}>>> Installing for Python2...${ENDC}" | |
sudo python setup.py build --mpicc=/usr/bin/mpicc | |
sudo python setup.py install | |
cd ~ | |
fi | |
echo -e "${GREEN}>>> Done.${ENDC}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment