Last active
May 24, 2020 15:52
-
-
Save lcbm/ee64772bac37eefbfc6bf2f8bfd5bf82 to your computer and use it in GitHub Desktop.
My Old Bash Scripts
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 | |
#### HEADER #### | |
# Description : KNoT bash script for installing 'knot-cloud-source'. | |
# Install order: Mongo DB, NodeJS, KNoT Cloud, Update Configuration, | |
# Run Mongo Service, Run KNoT Cloud. | |
# Written by : KNoT Scientific Initiation Team 2018.2. | |
# Last updated : 2019 February 4th. | |
#### GLOBAL VARIABLES #### | |
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |
LOG_FILE="knot-cloud-install-log.txt" | |
# KNoT Cloud Variables | |
# Source: github.com/CESARBR/knot-cloud-source/releases | |
KNOT_RELEASE="01.04-rc01" | |
KNOT_CLOUD_DIR="${HOME}/knot/src/knot-cloud-source" | |
KNOT_CLOUD_URL="https://github.com/CESARBR/knot-cloud-source/archive/KNOT-v${KNOT_RELEASE}.tar.gz" | |
# NVM Variables | |
# Source: github.com/creationix/nvm | |
NVM_VERSION="0.34.0" | |
NVM_URL="https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh" | |
# MongoDB Variables | |
# Source: docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#install-mongodb-community-edition-using-deb-packages | |
MONGODB_VERSION="4.0" | |
MONGODB_KEYSERVER="hkp://keyserver.ubuntu.com:80" | |
MONGODB_KEY="9DA31620334BD75D9DCB49F368818C72E52529D4" | |
#### INSTALL FUNCTIONS #### | |
# Install MongoDB's latest version: | |
install_mongo() { | |
local XENIAL=",arm64 " | |
local DISTRIBUTION=$(lsb_release -c -s) | |
local MONGODB_LIST_FILE="deb [ arch=amd64${XENIAL}] https://repo.mongodb.org/apt/ubuntu ${DISTRIBUTION}/mongodb-org/4.0 multiverse" | |
if [ ! "$DISTRIBUTION" = "xenial" ]; then | |
unset XENIAL | |
fi | |
sudo apt-key adv --keyserver ${MONGODB_KEYSERVER} --recv ${MONGODB_KEY} && | |
echo ${MONGODB_LIST_FILE} | sudo tee /etc/apt/sources.list.d/mongodb-org-${MONGODB_VERSION}.list && | |
sudo apt update && | |
sudo apt install -y mongodb-org | |
} | |
# Install NodeJS via NVM (Node Version Manager): github.com/creationix/nvm | |
install_node() { | |
# completely remove current node & npm before installing via nvm | |
sudo apt-get purge --auto-remove nodejs npm && | |
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*} | |
sudo rm -r /etc/apt/sources.list.d/nodesource.list | |
wget -qO- ${NVM_URL} | bash && # nvm install script | |
source ~/.nvm/nvm.sh # source nvm install path | |
nvm install --lts && # install 'lts' version of 'NodeJs' | |
nvm use --lts # tell 'nvm' to use 'lts' version of 'NodeJs' | |
} | |
# Install knot-clouds dependencies and itself | |
install_cloud() { | |
echo -e "\n#### install_cloud: cloud installation in progress... ####\n" | |
if ! [ -d ${KNOT_CLOUD_DIR} ]; then # start: if-else block | |
mkdir ${KNOT_CLOUD_DIR} && # create directory for library installation | |
# unpack folder contents (no parent folder) from URL into new directory ($LIB_PATH)... | |
wget -O- ${KNOT_CLOUD_URL} | tar xz -C ${KNOT_CLOUD_DIR} --strip-components=1 | |
fi # end: if-else block | |
cd ${KNOT_CLOUD_DIR} && # enter knot-cloud directory | |
# replace "process.env.MONGODB_URI" by "mongodb://localhost:27017/knot_cloud" .. | |
# '/' is a special character; therefore, must use '\' to escape special characters | |
sed -i 's/process.env.MONGODB_URI/"mongodb:\/\/localhost:27017\/knot_cloud"/g' config.js && | |
npm install bcrypt@latest --save && # install and update bcrypt at package.json | |
npm install --production # install production dependencies | |
} | |
# Deploy knot-cloud | |
deploy_cloud() { | |
echo -e "\n#### deploy_cloud: cloud is being deployed... ####\n" | |
sudo service mongod stop && # make sure only one service is up | |
sudo service mongod start && # start a mongodb service | |
cd ${KNOT_CLOUD_DIR} && # enter cloud directory | |
node server.js --http # deploy cloud | |
} | |
# MENU WITH INSTALL OPTIONS | |
main_menu() { | |
local CHECKLIST_MENU=(dialog --separate-output --checklist "KNOT RELEASE: v${KNOT_RELEASE} | |
Press SPACE to select what you wish to install: " | |
22 76 16) | |
local OPTIONS=(1 "All: MongoDB, NodeJs, KNoT Cloud" off | |
2 "Mongo DB v${MONGODB_VERSION}" off | |
3 "NodeJs LTS Version (via NVM v${NVM_VERSION})" off | |
4 "KNoT Cloud (requires knot-protocol & knot-hal)" off) | |
local CHOICES=$("${CHECKLIST_MENU[@]}" "${OPTIONS[@]}" 2>&1 >/dev/tty) | |
for CHOICE in $CHOICES; do | |
case $CHOICE in | |
1) | |
install_mongo && | |
install_node && | |
install_cloud | |
;; | |
2) | |
install_mongo | |
;; | |
3) | |
install_node | |
;; | |
4) | |
install_cloud | |
;; | |
esac | |
done | |
} | |
# MAIN FUNCTION | |
main() { | |
if main_menu; then | |
echo -e "\nDONE :D knot-cloud-source will deploy in couple seconds... \n" | |
else | |
echo -e "\nERROR: log file generated: ${LOG_FILE}\n" 1>&2 | |
exit 1 | |
fi | |
} | |
main 2>&1 | tee ${LOG_FILE} && # generate log file | |
sleep 5s && # wait five seconds | |
deploy_cloud # deploy cloud |
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 | |
#### HEADER #### | |
# Description : KNoT bash script to setup developer's basic needs. | |
# Setup order : Git, Mongo DB, NodeJS, KNoT Repositories, Arduino IDE | |
# Written by : KNoT Scientific Initiation Team 2018.2. | |
# Last updated: 2019 February 4th. | |
#### GLOBAL VARIABLES #### | |
SCRIPT_DEPENDENCIES="dialog" | |
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |
LOG_FILE="knot-dev-setup.txt" | |
# KNoT Cloud Variables | |
# Source: github.com/CESARBR/knot-cloud-source/releases | |
KNOT_RELEASE="01.04-rc01" | |
KNOT_REPOSITORIES="knot-cloud-source knot-thing-source knot-samples knot-hal-source knot-protocol-source knot-service-source knot-gateway-buildroot" | |
# Arduino Variables | |
# Source: arduino.cc/en/Main/Software | |
ARDUINO_VERSION="1.8.8" | |
ARDUINO_FOLDER="arduino-${ARDUINO_VERSION}-linux64.tar.xz" | |
ARDUINO_URL="https://downloads.arduino.cc/${ARDUINO_FOLDER}" | |
# NVM Variables | |
# Source: github.com/creationix/nvm | |
NVM_VERSION="0.34.0" | |
NVM_URL="https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh" | |
# MongoDB Variables | |
# Source: docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#install-mongodb-community-edition-using-deb-packages | |
MONGODB_VERSION="4.0" | |
MONGODB_KEYSERVER="hkp://keyserver.ubuntu.com:80" | |
MONGODB_KEY="9DA31620334BD75D9DCB49F368818C72E52529D4" | |
#### INSTALL FUNCTIONS #### | |
# INSTALL GIT THROUGH PACKAGE MANAGER | |
install_git() { | |
sudo add-apt-repository -y ppa:git-core/ppa && | |
sudo apt update && | |
sudo apt install -y git | |
} | |
# INSTALL MONGO DB THROUGH PACKAGE MANAGER | |
install_mongo() { | |
local DISTRIBUTION=$(lsb_release -c -s) # user's distribution codename | |
local XENIAL=",arm64 " # ubuntu 16.04 'list file' prefix | |
local MONGODB_LIST_FILE="deb [ arch=amd64${XENIAL}] https://repo.mongodb.org/apt/ubuntu ${DISTRIBUTION}/mongodb-org/${MONGODB_VERSION} multiverse" | |
if [ ! "$DISTRIBUTION" = "xenial" ]; then | |
unset XENIAL | |
fi | |
sudo apt-key adv --keyserver ${MONGODB_KEYSERVER} --recv ${MONGODB_KEY} && | |
echo "$MONGODB_LIST_FILE" | sudo tee /etc/apt/sources.list.d/mongodb-org-${MONGODB_VERSION}.list && | |
sudo apt update && | |
sudo apt install -y mongodb-org | |
} | |
# INSTALL NVM THROUGH INSTALL SCRIPT, THEN INSTALL NODEJS VIA NVM | |
install_node() { | |
echo -e "\n#### install_node: completely removing old NodeJs... ####\n" | |
sudo apt-get purge --auto-remove nodejs npm && | |
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*} | |
sudo rm -r /etc/apt/sources.list.d/node* | |
echo -e "\n#### install_node: installing NodeJs LTS via NVM (NVM v${NVM_VERSION})... ####\n" | |
wget -qO- ${NVM_URL} | bash && # nvm install script | |
source ~/.nvm/nvm.sh && # source 'nvm' command from file ~/.nvm/nvm.sh. | |
nvm install --lts && # install 'lts' version of 'nodejs' | |
nvm use --lts # tell 'nvm' to use 'lts' version of 'NodeJs' | |
} | |
# DOWNLOAD AND INSTALL ARDUINO | |
install_arduino() { | |
echo -e "\n#### install_arduino: installing Arduino v${ARDUINO_VERSION}... ####\n" | |
cd ${HOME} && | |
wget ${ARDUINO_URL} && # download 'arduino' files into 'home' directory | |
tar xvf ${ARDUINO_FOLDER} # unzip files | |
sudo rm ${ARDUINO_FOLDER} # remove zipped 'arduino' file | |
cd arduino-${ARDUINO_VERSION} && # enter arduino directory | |
sudo ./install.sh && # run installation script w/ sudo permission | |
sudo usermod -a -G dialout $USER # set serial port permission | |
} | |
# CLONE MAIN REPOSITORIES | |
clone_repositories() { | |
echo -e "\n#### clone_repositories: cloning knot repositores... ####\n" | |
# create directories for KNoT's project | |
mkdir -p ~/knot/src/knot-install-scripts ~/knot/releases ~/knot/tmp ~/knot/test-env | |
for REPOSITORY in ${KNOT_REPOSITORIES}; do | |
git -C ~/knot/src clone "https://github.com/CESARBR/${REPOSITORY}.git" | |
done | |
} | |
# MENU WITH INSTALL OPTIONS | |
main_menu() { | |
local CHECKLIST_MENU=(dialog --separate-output --checklist "KNOT RELEASE: v${KNOT_RELEASE} | |
Press SPACE to select what you wish to install: " | |
22 76 16) | |
local OPTIONS=(1 "All: Git, MongoDB, NodeJs, Arduino, KNoT Repositories" off | |
2 "Git at Latest Stable Upstream" off | |
3 "Mongo DB v${MONGODB_VERSION}" off | |
4 "NodeJs LTS Version (via NVM v${NVM_VERSION})" off | |
5 "Arduino v${ARDUINO_VERSION}" off | |
6 "Clone KNoT Repositories" off) | |
local CHOICES=$("${CHECKLIST_MENU[@]}" "${OPTIONS[@]}" 2>&1 >/dev/tty) | |
for CHOICE in $CHOICES; do | |
case $CHOICE in | |
1) | |
install_git && | |
install_mongo && | |
install_node && | |
install_arduino && | |
clone_repositories | |
;; | |
2) | |
install_git | |
;; | |
3) | |
install_mongo | |
;; | |
4) | |
install_node | |
;; | |
5) | |
install_arduino | |
;; | |
6) | |
clone_repositories | |
;; | |
esac | |
done | |
} | |
# MAIN FUNCTION | |
main() { | |
sudo apt install -y ${SCRIPT_DEPENDENCIES} && | |
if main_menu; then | |
echo -e "\nDONE installing basic developer tools :D" | |
echo -e "\nInstallation Scripts and Logs were moved to '~/knot/src/knot-install-scripts'" | |
echo -e "\nPlease reboot for all changed to take effect! \n" | |
else | |
echo -e "\nERROR: log file generated: ${LOG_FILE}\n" | |
exit 1 | |
fi | |
} | |
main 2>&1 | tee ${LOG_FILE} && # generate log file | |
mv *.sh *txt ~/knot/src/knot-install-scripts # move scripts and logs to 'knot' folder |
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 | |
#### HEADER #### | |
# Description : KNoT bash script for installing 'knot-service-source'. | |
# Build order : common dependencies, protocol, hal, service. | |
# Written by : KNoT Scientific Initiation Team 2018.2. | |
# Last updated: 2019 February 26th. | |
#### TO-DO #### | |
# installation_menu: fix KNOT_OPTIONS menu to switch menus and only | |
# install after user chose all tools and dependencies | |
# he/she wishes to install. | |
# configure_install: remove 'knot-service-source' fix from 'configure_install' | |
#### GLOBALS #### | |
# Description: list of variables that hold fixed values. | |
LOG_FILE_NAME="knot-service-install-log.txt" | |
BASH_ROOT_DIR=$( dirname "$(readlink -f "$0")") | |
USER_HOME_DIR=$( getent passwd ${USER} | cut -d: -f6 ) | |
KNOT_SRC_DIR="${USER_HOME_DIR}/knot-tools-source" | |
KNOT_SCRIPTS_DIR="${KNOT_SRC_DIR}/knot-scripts-source" | |
KNOT_TMP_DIR="${KNOT_SRC_DIR}/tmp" | |
#### REQUIREMENTS #### | |
# Description: list of required tools and their respective dependencies. | |
SCRIPT_REQUIREMENTS="git dialog wget xz-utils" | |
COMMON_REQUIREMENTS="autoconf automake libtool" | |
PYTHON3_REQUIREMENTS="python3 python3-pip python3-setuptools python3-wheel ninja-build libselinux1-dev" | |
KNOT_PROTOCOL_REQUIREMENTS="${COMMON_REQUIREMENTS}" | |
KNOT_HAL_REQUIREMENTS="json-c glib" | |
KNOT_SERVICE_REQUIREMENTS="libdbus-glib-1-dev ell json-c libwebsockets" | |
#### DEPENDENCIES #### | |
# Description: list of dependencies' versions, url & subsequent dependencies. | |
KNOT_RELEASE="KNOT-v01.04-rc01" | |
KNOT_PROFILE="CESARBR" | |
CMAKE_VERSION="3.8.2" # currently using 'pip3' to install 'cmake' (latest version) | |
CMAKE_URL="https://github.com/Kitware/CMake/archive/v${CMAKE_VERSION}.tar.gz" | |
ELL_VERSION="0.11" | |
ELL_URL="https://mirrors.edge.kernel.org/pub/linux/libs/ell/ell-${ELL_VERSION}.tar.gz" | |
GLIB_VERSION="2.56.1" | |
GLIB_DEPENDENCIES="zlib1g-dev libffi-dev libmount-dev libpcre3-dev" | |
GLIB_URL="https://github.com/GNOME/glib/archive/${GLIB_VERSION}.tar.gz" | |
JSONC_VERSION="0.13.1-20180305" | |
JSONC_URL="https://github.com/json-c/json-c/archive/json-c-${JSONC_VERSION}.tar.gz" | |
LIBWEBSOCKETS_VERSION="2.4.2" | |
LIBWEBSOCKETS_DEPENDENCIES="libssl-dev" # cmake | |
LIBWEBSOCKETS_URL="https://github.com/warmcat/libwebsockets/archive/v${LIBWEBSOCKETS_VERSION}.tar.gz" | |
#### SETUP #### | |
# Description: installs minimum requirements to enable script execution. | |
setup() { | |
local BUILD_DIRS="${KNOT_SRC_DIR} ${KNOT_TMP_DIR} ${KNOT_SCRIPTS_DIR}" | |
echo -e "\n -> setup: RUNNING INITIAL SETUP \n " | |
# updating system | |
sudo apt-get update && | |
sudo apt-get upgrade -y && | |
# install script related requirements | |
sudo apt-get install -y ${SCRIPT_REQUIREMENTS} && | |
sudo apt-get install -y ${COMMON_REQUIREMENTS} && | |
# install python3 related requirements | |
sudo apt-get install -y ${PYTHON3_REQUIREMENTS} && | |
pip3 install --user --upgrade pip && | |
# creating temporary directories; if non existent | |
for DIR in ${BUILD_DIRS}; do | |
if ! [ -d ${DIR} ]; then | |
mkdir -p ${DIR} | |
fi | |
done | |
return 0 | |
} | |
#### INSTALLATION FUNCTIONS #### | |
# Function : meson_install | |
# Description: uses meson and ninja to build and install library | |
meson_install() { | |
# build installation files with 'meson' | |
meson builddir && | |
cd builddir && | |
# install library using 'ninja' | |
ninja && | |
sudo ninja install && | |
return 0 | |
} | |
# Function : cmake_install | |
# Description: installs dependencies with cmake. | |
cmake_install() { | |
# remove old 'cmake' installation | |
sudo rm -rf build && | |
# build installation files with 'cmake' | |
mkdir build && | |
cd build && | |
cmake .. && | |
# install library with 'make' | |
make && | |
sudo make install && | |
return 0 | |
} | |
# Function : configure_install | |
# Description: installs dependencies w/ 'bootstrap' and 'configure' scripts | |
configure_install() { | |
local CURRENT_DIR=$"(${PWD##*/})" | |
local BOOTSTRAP_FILES="./bootstrap-configure ./bootstrap ./autogen.sh ./configure" | |
echo -e "\n -> configure_install: CONFIGURING ${LIB_NAME} \n" | |
# searching for bootstrap files to execute | |
for FILE in ${BOOTSTRAP_FILES}; do | |
if [ -f ${FILE} ]; then | |
${FILE} | |
fi | |
done | |
# if lib name matches 'knot-service-source', correct makefile | |
if [ "${CURRENT_DIR}" = "knot-service-source" ]; then | |
sed -i 's/-Werror //g' Makefile && | |
echo -e "\n -> configure_install: REMOVED '-Werror' FLAG FROM ${LIB_NAME} MAKEFILE \n" | |
fi | |
# install library with 'make' | |
make && | |
sudo make install && | |
return 0 | |
} | |
# Function : fetch_source_files | |
# Description: exctracts, or clones, source files from source and installs library. | |
fetch_source_files() { | |
local LIB_NAME=$1 # LIB_NAME takes first argument | |
local VERSION=$2 # VERSION takes second argument | |
local SOURCE=$3 # SOURCE takes third argument | |
echo -e "\n -> fetch_source_files: FETCHING FILES FOR ${LIB_NAME} \n" | |
# checking if LIB_NAME contains 'knot'; since only 'knot' tools are repos | |
if [[ $LIB_NAME == *"knot"* ]]; then | |
local LIB_PATH="${KNOT_SRC_DIR}/${LIB_NAME}" | |
local GIT_URL="https://github.com/${SOURCE}/${LIB_NAME}.git" | |
# clonning repository into path (-C) and checking out on version/tag (--branch=...) | |
if ! [ -d "$LIB_PATH" ]; then | |
git -C ${KNOT_SRC_DIR} clone ${GIT_URL} | |
fi | |
cd ${LIB_PATH} && | |
git checkout tags/${VERSION} # checkout on specific tag | |
return 0 | |
# if SOURCE is not a repository, use 'wget instead' of 'git' | |
else | |
local LIB_PATH="${KNOT_TMP_DIR}/${LIB_NAME}" | |
# unpacking source content (--strip-components=1) into $LIB_PATH (-C <DIR>) | |
mkdir -p "${KNOT_TMP_DIR}/${LIB_NAME}" ; | |
wget -O- ${SOURCE} | tar xz -C ${LIB_PATH} --strip-components=1 && | |
return 0 | |
fi | |
return 1 | |
} | |
# Function : install_lib | |
# Description: installs library using appropriate tools. | |
install_lib() { | |
local LIB_NAME=$1 # LIB_NAME takes first argument | |
local VERSION=$2 # VERSION takes second argument | |
local SOURCE=$3 # SOURCE takes third argument | |
echo -e "\n -> install_lib: INSTALLING ${LIB_NAME} \n" | |
# get library source files | |
fetch_source_files "$@" && | |
# enter correct lib path | |
if [ -d "${KNOT_TMP_DIR}/${LIB_NAME}" ]; then | |
cd "${KNOT_TMP_DIR}/${LIB_NAME}" | |
else | |
cd "${KNOT_SRC_DIR}/${LIB_NAME}" | |
fi | |
# checking if library can be used | |
if [ -f "meson_options.txt" ]; then | |
meson_install && | |
return 0 | |
elif [ -f "./CMakeLists.txt" ]; then | |
cmake_install && | |
return 0 | |
else | |
configure_install && | |
return 0 | |
fi | |
return 1 | |
} | |
#### INSTALLATION MENU #### | |
# Description: the menu allows the user pick and choose which tools, | |
# requirements, and/or dependencies to install. | |
installation_menu() { | |
# creating a checklist type menu using 'dialog' | |
local CHECKLIST_MENU=(dialog --checklist | |
"[KNOT-SERVICE-SOURCE INSTALLATION MENU] | |
RELEASE: ${KNOT_RELEASE} | |
Press 'SPACE' to select which knot-tools and dependencies you wish to install:" | |
25 100 15) | |
# list of knot tools | |
local KNOT_OPTIONS=( | |
ALL "Install ALL of the tools below" off | |
KNOT-PROTOCOL "knot-protocol-source" off | |
KNOT-HAL "knot-hal-source" off | |
KNOT-SERVICE "knot-service-source (requires KNOT-PROTOCOL and KNOT-HAL)" off) | |
# list of knot-protocol-source requirements and dependencies to chose from | |
local PROTOCOL_OPTIONS=( | |
1 "knot-service-source (no requirements)" off) | |
# list of knot-hal-source requirements and dependencies to chose from | |
local HAL_OPTIONS=( | |
4 "json-c v${JSONC_VERSION}" off | |
5 "glib v${GLIB_VERSION} (requires ${GLIB_DEPENDENCIES}" off | |
2 "knot-hal-source (requires libraries above)" off) | |
# list of knot-service-source requirements and dependencies to chose from | |
local SERVICE_OPTIONS=( | |
4 "json-c v${JSONC_VERSION}" off | |
6 "CMake v${CMAKE_VERSION} (required by 'libwebsockets')" off | |
7 "libwebsockets v${LIBWEBSOCKETS_VERSION}" off | |
8 "ell v${ELL_VERSION}" off | |
3 "knot-service-source (requires libraries above)" off) | |
# render 'CHECKLIST_MENU' with options from 'KNOT_OPTIONS' and store user choices | |
local CHOICES=$("${CHECKLIST_MENU[@]}" "${KNOT_OPTIONS[@]}" 2>&1 >/dev/tty) | |
# break loop if CHOICES is empty, after removing blanks (using parameter expansion) | |
while ! [ -z "$( echo ${CHOICES//[[:blank:]]/})" ]; do | |
for CHOICE in $CHOICES; do | |
case $CHOICE in | |
ALL) | |
CHOICES="1 4 5 2 6 7 8 3" | |
;; | |
KNOT-PROTOCOL) | |
CHOICES+=" $("${CHECKLIST_MENU[@]}" "${PROTOCOL_OPTIONS[@]}" 2>&1 >/dev/tty)" | |
CHOICES=${CHOICES//"KNOT-PROTOCOL"/} | |
;; | |
KNOT-HAL) | |
CHOICES+=" $("${CHECKLIST_MENU[@]}" "${HAL_OPTIONS[@]}" 2>&1 >/dev/tty)" | |
CHOICES=${CHOICES//"KNOT-HAL"/} | |
;; | |
KNOT-SERVICE) | |
CHOICES+=" $("${CHECKLIST_MENU[@]}" "${SERVICE_OPTIONS[@]}" 2>&1 >/dev/tty)" | |
CHOICES=${CHOICES//"KNOT-SERVICE"/} | |
;; | |
1) | |
sudo apt-get install -y ${KNOT_PROTOCOL_REQUIREMENTS} && | |
install_lib "knot-protocol-source" ${KNOT_RELEASE} ${KNOT_PROFILE} && | |
CHOICES=${CHOICES//"1"/} | |
;; | |
2) | |
install_lib "knot-hal-source" ${KNOT_RELEASE} ${KNOT_PROFILE} && | |
CHOICES=${CHOICES//"2"/} | |
;; | |
3) | |
install_lib "knot-service-source" ${KNOT_RELEASE} ${KNOT_PROFILE} && | |
CHOICES=${CHOICES//"3"/} | |
;; | |
4) | |
install_lib "json-c" ${JSONC_VERSION} ${JSONC_URL} && | |
CHOICES=${CHOICES//"4"/} | |
;; | |
5) | |
sudo apt-get install -y ${GLIB_DEPENDENCIES} && | |
install_lib "glib" ${GLIB_VERSION} ${GLIB_URL} && | |
CHOICES=${CHOICES//"5"/} | |
;; | |
6) | |
echo -e "\n -> python3: INSTALLING CMake \n " | |
pip3 install --user "cmake" && | |
CHOICES=${CHOICES//"6"/} | |
;; | |
7) | |
sudo apt-get install -y ${LIBWEBSOCKETS_DEPENDENCIES} && | |
install_lib "libwebsockets" ${LIBWEBSOCKETS_VERSION} ${LIBWEBSOCKETS_URL} && | |
CHOICES=${CHOICES//"7"/} | |
;; | |
8) | |
install_lib "ell" ${ELL_VERSION} ${ELL_URL} && | |
CHOICES=${CHOICES//"8"/} | |
;; | |
esac | |
done | |
done | |
return 0 | |
} | |
#### MAIN FUNCTION #### | |
main() { | |
# run setup function to install minimum requirements | |
setup && | |
# if no errors are encountered durint tool, remove and move folders | |
if installation_menu; then | |
sudo rm -rf ${KNOT_TMP_DIR} && | |
mv -v "${BASH_ROOT_DIR}/${BASH_SOURCE[0]}" ${KNOT_SCRIPTS_DIR} && | |
mv -v "${BASH_ROOT_DIR}/${LOG_FILE_NAME}" ${KNOT_SCRIPTS_DIR} && | |
echo -e "\n SUCCESS: ALL TOOLS INSTALLED \n" | |
else | |
echo -e "\n ERROR: ENCOUTERED AN ERROR DURING INSTALLATION \n" | |
fi | |
echo -e "\n LOG FILE PATH: '${KNOT_SCRIPTS_DIR}/${LOG_FILE_NAME}' \n" | |
echo -e "\n TEMPORARY FILES: DELETED UNECESSARY FILES FROM '${KNOT_TMP_DIR}' \n" | |
echo -e "\n PERMANENT FILES: MOVED TO '${KNOT_SRC_DIR}' \n" | |
exit 0 | |
} | |
# RUN SCRIPT TO INSTALL KNOT-SERVICE-SOURCE | |
main 2>&1 | tee ${LOG_FILE_NAME} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment