#!/usr/bin/env bash ################################################################ # # # Privex's Insight for Litecoin Auto-deployer # # # # Deploy's Privex/ltcinsight-docker fully # # automatically (no user interaction) # # # # (C) 2021 Privex Inc. # # https://www.privex.io # # # # Official repo: https://github.com/Privex/ltcinsight-docker # # # ################################################################ # # Usage: # # curl -fsS https://cdn.privex.io/github/ltcinsight-docker/deploy.sh | bash # # ################################################################ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:${PATH}" export PATH="${HOME}/.local/bin:/snap/bin:${PATH}" : ${INS_REPO="https://github.com/Privex/ltcinsight-docker.git"} : ${INS_DIR="${HOME}/ltcinsight-docker"} : ${INS_VER="master"} : ${WAITFOR="10"} em() { >&2 echo -e "$@"; } hascmd() { command -v "$@" &> /dev/null; } has_cmd() { hascmd "$@"; } autosudo() { all_args=("$@") first_el="${all_args[0]}" last_els=("${all_args[@]:1:${#all_args[@]}}") last_els_str="$(printf "%q " "${last_els[@]}")" if (( EUID != 0 )); then if hascmd sudo; then sudo -- "$@" _ret=$? elif hascmd su; then su -c "$first_el ${last_els_str}" _ret=$? else em " [!!!] You're not root, and neither 'sudo' nor 'su' are available." em " [!!!] Cannot run command: $first_el $last_els_str " return 2 fi else env -- "$@" _ret=$? fi return $_ret } DST_TYPE="" PKG_MGR="" PKG_MGR_INS="" PKG_MGR_UP="" hascmd apt-get && DST_TYPE="deb" PKG_MGR="apt-get" [[ -z "$PKG_MGR" ]] && hascmd apt && DST_TYPE="deb" PKG_MGR="apt" [[ -z "$PKG_MGR" ]] && hascmd dnf && DST_TYPE="rhel" PKG_MGR="dnf" [[ -z "$PKG_MGR" ]] && hascmd yum && DST_TYPE="rhel" PKG_MGR="yum" [[ -z "$PKG_MGR" ]] && hascmd pacman && DST_TYPE="arch" PKG_MGR="pacman" [[ -z "$PKG_MGR" ]] && hascmd apk && DST_TYPE="alp" PKG_MGR="apk" [[ -z "$PKG_MGR" ]] && hascmd brew && DST_TYPE="osx" PKG_MGR="brew" if [[ -n "$PKG_MGR" ]]; then if [[ "$DST_TYPE" == "deb" ]]; then PKG_MGR_INS="${PKG_MGR} install -qy" PKG_MGR_UP="${PKG_MGR} update -qy" elif [[ "$DST_TYPE" == "rhel" ]]; then PKG_MGR_INS="${PKG_MGR} install -y" PKG_MGR_UP="${PKG_MGR} makecache -y" elif [[ "$DST_TYPE" == "alp" ]]; then PKG_MGR_INS="${PKG_MGR} add" PKG_MGR_UP="${PKG_MGR} update" elif [[ "$DST_TYPE" == "arch" ]]; then PKG_MGR_INS="${PKG_MGR} -S --noconfirm" PKG_MGR_UP="${PKG_MGR} -Sy --noconfirm" elif [[ "$DST_TYPE" == "osx" ]]; then PKG_MGR_INS="${PKG_MGR} install" PKG_MGR_UP="${PKG_MGR} update" else PKG_MGR="" fi fi PM_UPDATED=0 autoinst() { if hascmd "$1"; then return 0 fi em " [...] Program '$1' not found. Installing package(s):" "${@:2}" if [[ -n "$PKG_MGR_UP" ]] && (( PM_UPDATED == 0 )); then autosudo $PKG_MGR_UP _ret=$? if (( _ret )); then em " [!!!] Non-zero return code from '$PKG_MGR_UP' - code: $_ret" return $_ret fi em " +++ Successfully updated package manager '${PKG_MGR}'" PM_UPDATED=1 fi autosudo $PKG_MGR_INS "${@:2}" _ret=$? if (( _ret )); then em " [!!!] Non-zero return code from '$PKG_MGR_INS' - code: $_ret" return $_ret fi em " +++ Successfully installed packages:" "${@:2}" return 0 } em em "################################################################" em "# #" em "# Privex's Insight for Litecoin Auto-deployer #" em "# #" em "# Deploy's Privex/ltcinsight-docker fully #" em "# automatically (no user interaction) #" em "# #" em "# (C) 2021 Privex Inc. #" em "# https://www.privex.io #" em "# #" em "# Official repo: https://github.com/Privex/ltcinsight-docker #" em "# #" em "################################################################" em em sleep 1 em " !!!!! WARNING !!!!!" sleep 1 em " >> In $WAITFOR seconds, this script will install Privex's ltcinsight-docker (Litecoin Insight Explorer within Docker)" em " >> onto your system, which will automatically install various packages as-needed, such as Docker, and Docker Compose." em " >>" em " >> !!! PRESS CTRL-C TO CANCEL IF YOU DO NOT WISH TO CONTINUE !!!" sleep 1 em em " >> Cloning repo from: $INS_REPO" em " >> Storing repo at: $INS_DIR" sleep 1 em em " !!!!! WARNING !!!!!" em em " ... Waiting $WAITFOR seconds before proceeding ..." i=$WAITFOR while (( i > 0 )); do if (( i % 3 == 0 )); then em " [!!!] $i seconds remaining." fi sleep 1 i=$(( i - 1 )) done em " [...] Ensuring 'git', 'curl', and 'wget' are installed before we try to clone ltcinsight-docker..." autoinst git git autoinst curl curl autoinst wget wget em " >>> Cloning ltcinsight-docker ( $INS_REPO ) into directory: $INS_DIR" git clone -b "$INS_VER" "$INS_REPO" "$INS_DIR" em " > Entering folder $INS_DIR" cd "$INS_DIR" em " > Handing off to repository auto-installer script: ${INS_DIR}/init.sh \n" em em " > Thanks for using our project :)" em " > Consider purchasing a virtual and/or dedicated server from https://www.privex.io" em " > We offer privacy friendly servers for as little as US\$0.99/mo - and we accept crypto! (inc. LTC)" sleep 2 exec "${INS_DIR}/init.sh"