Skip to content

Instantly share code, notes, and snippets.

@ericlancebrown
Last active November 18, 2020 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericlancebrown/f6c1d8f9e27cce0187ae8627b0f62df6 to your computer and use it in GitHub Desktop.
Save ericlancebrown/f6c1d8f9e27cce0187ae8627b0f62df6 to your computer and use it in GitHub Desktop.
Ubuntu 20.04 installation bash shell file for installing all of libsubtractive's prerequisites and dependencies as well as libsubtractive itself. You should be able to #include <libsubtractive/libsubtractive.hpp> in your c++ source files after this installation is completed.
#!/bin/bash
# Script: Libsubtractive Installation Script
# OS: Ubuntu 20.04
# Updated: 11.17.20
# Author: Eric Brown
####################################################
# Usage:
# chmod u+x ls_ubuntu-2004.sh
# ./ls_ubuntu-2004.sh
####################################################
# Setup
cd ~
echo -e '\e[1;33m> Checking if Lupin software directory exists.\e[0m'
if [ ! -d Lupin ]; then
echo -e '\e[1;33m> Creating Lupin software directory.\e[0m'
mkdir -p Lupin && cd Lupin
else
echo -e '\e[1;31m> Lupin software directory already exists.\e[0m'
echo -e '\e[1;31m> Would you like to remove and reinstall the Lupin software directory?\e[0m [y/n]'
read yn
if [[ $yn == y* ]]; then
echo -e '\e[1;33m> User selected to reinstall. Removing Lupin software directory and reinstalling.\e[0m'
sudo rm -rf Lupin
mkdir -p Lupin && cd Lupin
else
echo -e '\e[1;31m> User selected not to reinstall. Exiting.\e[0m'
exit 1
fi
fi
# Update System -- Install Prerequisites
echo -e '\e[1;33m> Updating system.\e[0m'
sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade -y
echo -e '\e[1;33m> Installing Lupin prerequisites.\e[0m'
sudo apt install -y curl unzip tar cmake gcc g++ pkg-config libudev-dev scons build-essential libssl-dev binutils-dev libiberty-dev libmariadb-dev-compat libleveldb-dev libsnappy-dev git libboost-all-dev qt5-default libqt5websockets5-dev libqt5opengl5-dev libnode-dev
pkgs='curl unzip tar cmake gcc g++ pkg-config libudev-dev scons build-essential libssl-dev binutils-dev libiberty-dev libmariadb-dev-compat libleveldb-dev libsnappy-dev git libboost-all-dev qt5-default libqt5websockets5-dev libqt5opengl5-dev libnode-dev'
if ! dpkg -s $pkgs >/dev/null 2>&1; then
echo -e '\e[1;31m> [ERROR] Installation of prerequisites failed. Exiting.\e[0m'
exit 1
else
echo -e '\e[1;32m> [SUCCESS] Installation of prerequisites successful.\e[0m'
fi
# GTest / GMock
echo -e '\e[1;33m> Installing GTest and GMock.\e[0m'
git clone https://github.com/google/googletest.git
cd googletest
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON -DBUILD_GMOCK=ON -DINSTALL_GTEST=ON ..
make
sudo make install
sudo ldconfig
cd ..
cd ..
echo -e '\e[1;33m> Checking for GTest.\e[0m'
pkgs='gtest'
if ! ldconfig -p | grep $pkgs >/dev/null 2>&1; then
echo -e '\e[1;31m> [ERROR] Installation of GTest failed. Cannot find library directory. Exiting.\e[0m'
exit 1
else
echo -e '\e[1;32m> [SUCCESS] Installation of GTest successful.\e[0m'
fi
echo -e '\e[1;33m> Checking for GMock.\e[0m'
pkgs='gmock'
if ! ldconfig -p | grep $pkgs >/dev/null 2>&1; then
echo -e '\e[1;31m> [ERROR] Installation of GMock failed. Cannot find library directory. Exiting.\e[0m'
exit 1
else
echo -e '\e[1;32m> [SUCCESS] Installation of GMock successful.\e[0m'
fi
# ZeroMQ
echo -e '\e[1;33m> Installing ZeroMQ.\e[0m'
git clone https://github.com/zeromq/libzmq.git
cd libzmq
./autogen.sh
./configure
make
sudo make install
sudo ldconfig
cd ..
echo -e '\e[1;33m> Checking for ZeroMQ.\e[0m'
pkgs='zmq'
if ! ldconfig -p | grep $pkgs >/dev/null 2>&1; then
echo -e '\e[1;31m> [ERROR] Installation of ZeroMQ failed. Cannot find library directory. Exiting.\e[0m'
exit 1
else
echo -e '\e[1;32m> [SUCCESS] Installation of ZeroMQ successful.\e[0m'
fi
# libusbp
echo -e '\e[1;33m> Installing libusbp.\e[0m'
git clone https://github.com/pololu/libusbp.git
cd libusbp
mkdir build && cd build
cmake ..
make
sudo make install
sudo ldconfig
cd ..
cd ..
echo -e '\e[1;33m> Checking for libusbp.\e[0m'
pkgs='libusbp'
if ! ldconfig -p | grep $pkgs >/dev/null 2>&1; then
echo -e '\e[1;31m> [ERROR] Installation of libusbp failed. Cannot find library directory. Exiting.\e[0m'
exit 1
else
echo -e '\e[1;32m> [SUCCESS] Installation of libusbp successful.\e[0m'
fi
# libsubtractive
echo -e '\e[1;33m> Installing libsubtractive.\e[0m'
git clone https://github.com/ericlancebrown/libsubtractive.git
cd libsubtractive
mkdir build && cd build
cmake ..
make
sudo make install
sudo ldconfig
cd ..
cd ..
echo -e '\e[1;33m> Checking for libsubtractive.\e[0m'
pkgs='libsubtractive'
if ! ldconfig -p | grep $pkgs >/dev/null 2>&1; then
echo -e '\e[1;31m> [ERROR] Installation of libsubtractive failed. Cannot find library directory. Exiting.\e[0m'
exit 1
else
echo -e '\e[1;32m> [SUCCESS] Installation of libsubtractive successful.\e[0m'
fi
echo -e '\e[1;32m> [COMPLETE] Installation of libsubtractive library and dependencies complete.\e[0m'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment