#!/usr/bin/env bash YW=$(echo "\033[33m") BL=$(echo "\033[36m") RD=$(echo "\033[01;31m") BGN=$(echo "\033[4;92m") GN=$(echo "\033[1;92m") DGN=$(echo "\033[32m") CL=$(echo "\033[m") BFR="\\r\\033[K" HOLD="-" CM="${GN}✓${CL}" APP="Mystic BBS" MSDIR="/opt/mystic" MSTEMPDIR="/usr/local/src/mystic" INSTALLLOG=$MSTEMPDIR/install.log TMP_DIR=$(mktemp -d) SCRIPT_VER="v7" GROUP=$(getent group mystic) USER=$(getent shadow mystic) FAIL2BAN_GROUP=$(getent group fail2ban) IPBAN_GROUP=$(getent group ipban) hostname="$(hostname)" set -o errexit set -o errtrace set -o nounset set -o pipefail shopt -s expand_aliases alias die='EXIT=$? LINE=$LINENO error_exit' trap die ERR function error_exit() { trap - ERR local reason="Unknown failure occured." local msg="${1:-$reason}" local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE" echo -e "$flag $msg" 1>&2 exit $EXIT } function cmd_exec() { { printf "$(date '+%Y-%m-%d %H:%M:%S') %s\n" "$*" "$@" } >> $INSTALLLOG } if command -v pveversion >/dev/null 2>&1; then echo -e "⚠️ Can't Install on Proxmox "; exit; fi while true; do read -p "This will Install ${APP} on $hostname. Proceed(y/n)?" yn case $yn in [Yy]*) break ;; [Nn]*) exit ;; *) echo "Please answer yes or no." ;; esac done clear function msg_info() { local msg="$1" echo -ne " ${HOLD} ${YW}${msg}..." } function msg_ok() { local msg="$1" echo -e "${BFR} ${CM} ${GN}${msg}${CL}" } mkdir -p $MSTEMPDIR &>/dev/null msg_info "Installing needed base packages" cmd_exec apt update | tee -a $INSTALLLOG &>/dev/null cmd_exec apt install lsb-release dpkg-dev wget curl figlet lolcat unzip whiptail dialog -y | tee -a $INSTALLLOG &>/dev/null msg_ok "Installing needed base packages" function header_info { cmd_exec /usr/bin/env figlet -w 60 -c "Mystic BBS DbP Installer" | /usr/games/lolcat -f } header_info ARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH) DIST=$(lsb_release -i -s) CODENAME=$(lsb_release -c -s) LIBDIR=/usr/lib/${ARCH} if [ "${ARCH}" = "x86_64-linux-gnu" ]; then INIMOD_ARCH="amd64" MYSTIC_ARCH="l64" MYSTIC_EXT="rar" RARLAB="rar" DOSEMUVER="dosemu2" elif [ "${ARCH}" = "i386-linux-gnu" ]; then INIMOD_ARCH="amd32" MYSTIC_ARCH="l32" MYSTIC_EXT="rar" RARLAB="rar" DOSEMUVER="dosemu" elif [ "${ARCH}" = "aarch64-linux-gnu" ]; then INIMOD_ARCH="arm64" MYSTIC_ARCH="p64" MYSTIC_EXT="zip" RARLAB="" DOSEMUVER="dosemu2" elif [ "${ARCH}" = "arm-linux-gnueabihf" ]; then INIMOD_ARCH="arm32" MYSTIC_ARCH="p32" MYSTIC_EXT="zip" RARLAB="" DOSEMUVER="" else echo "Architecture not supported: ${ARCH}" exit 1 fi if [ "${CODENAME}" = "bookworm" ]; then UBUNTU="kinetic" elif [ "${CODENAME}" = "bullseye" ]; then UBUNTU="focal" elif [ "${CODENAME}" = "buster" ]; then UBUNTU="bionic" elif [ "${CODENAME}" = "stretch" ]; then UBUNTU="xenial" else UBUNTU="${CODENAME}" fi if [ "${CODENAME}" = "bookworm" ]; then msg_info "adding bullseye repository to bookworm for python2" echo "deb http://deb.debian.org/debian bullseye contrib non-free main" > /etc/apt/sources.list.d/bullseye.list echo "deb http://deb.debian.org/debian bullseye-updates contrib non-free main" >> /etc/apt/sources.list.d/bullseye.list echo "deb http://security.debian.org bullseye-security contrib non-free main" >> /etc/apt/sources.list.d/bullseye.list msg_ok "adding bullseye repository to bookworm for python2" fi msg_info "Setting up ${APP} Repository" apt install -y software-properties-common &>$INSTALLLOG if [ "${DIST}" = "Debian" ]; then cmd_exec apt-add-repository -y contrib &>$INSTALLLOG cmd_exec apt-add-repository -y non-free &>$INSTALLLOG fi if [ "${DIST}" = "Ubuntu" ]; then cmd_exec apt-add-repository -y universe &>$INSTALLLOG cmd_exec apt-add-repository -y restricted &>$INSTALLLOG cmd_exec apt-add-repository -y multiverse &>$INSTALLLOG fi cmd_exec apt update &>$INSTALLLOG cmd_exec apt install -y curl wget gnupg unzip unrar &>$INSTALLLOG cmd_exec mkdir -p $MSTEMPDIR &>$INSTALLLOG msg_ok "Setting up ${APP} Repository" #============================================================================================================== msg_info "Downloading ${APP} Mystic BBS Disconnected-by-Peer Installer Files" cmd_exec wget -N https://gitea.disconnected-by-peer.at/geos_one/mystic/archive/main.zip -O $MSTEMPDIR/dbp-main.zip &>$INSTALLLOG cmd_exec rm -rf $MSTEMPDIR/mystic &>$INSTALLLOG cmd_exec pushd $MSTEMPDIR &>$INSTALLLOG cmd_exec unzip dbp-main.zip &>$INSTALLLOG cmd_exec popd &>$INSTALLLOG msg_ok "Downloading ${APP} Mystic BBS Disconnected-by-Peer Installer Files" #============================================================================================================== # Mystic install Directory source $MSTEMPDIR/mystic/mystic/prompt-${SCRIPT_VER}.sh # Add Cryptlib support source $MSTEMPDIR/mystic/cryptlib/prompt-${SCRIPT_VER}.sh # Add Spellcheck source $MSTEMPDIR/mystic/spellcheck/prompt-${SCRIPT_VER}.sh # Add Multi Relay Chat Client source $MSTEMPDIR/mystic/mrc-client/prompt-${SCRIPT_VER}.sh # Add Multi Relay Chat Server source $MSTEMPDIR/mystic/mrc-server/prompt-${SCRIPT_VER}.sh # Add IP2Location source $MSTEMPDIR/mystic/ip2location/prompt-${SCRIPT_VER}.sh # Add DBP Scripts source $MSTEMPDIR/mystic/dbp/prompt-${SCRIPT_VER}.sh # Add Fail2ban | banip source $MSTEMPDIR/mystic/fail2ban/prompt-${SCRIPT_VER}.sh # Add Dosemu2 if [ -n "${DOSEMUVER}" ]; then source $MSTEMPDIR/mystic/dosemu2/prompt-${SCRIPT_VER}.sh fi #============================================================================================================== # Mystic install source $MSTEMPDIR/mystic/mystic/install-${SCRIPT_VER}.sh # Add Spellcheck source $MSTEMPDIR/mystic/spellcheck/install-${SCRIPT_VER}.sh # Add Multi Relay Chat Client source $MSTEMPDIR/mystic/mrc-client/install-${SCRIPT_VER}.sh # Add Multi Relay Chat Server source $MSTEMPDIR/mystic/mrc-server/install-${SCRIPT_VER}.sh # Add Cryptlib support source $MSTEMPDIR/mystic/cryptlib/install-${SCRIPT_VER}.sh # Add IP2Location source $MSTEMPDIR/mystic/ip2location/install-${SCRIPT_VER}.sh # Add DBP Scripts source $MSTEMPDIR/mystic/dbp/install-${SCRIPT_VER}.sh # Add Fail2ban | banip source $MSTEMPDIR/mystic/fail2ban/install-${SCRIPT_VER}.sh # Add Dosemu2 if [ -n "${DOSEMUVER}" ]; then source $MSTEMPDIR/mystic/dosemu2/install-${SCRIPT_VER}.sh fi #============================================================================================================== # Mystic install source $MSTEMPDIR/mystic/mystic/config-${SCRIPT_VER}.sh # Add Spellcheck source $MSTEMPDIR/mystic/spellcheck/config-${SCRIPT_VER}.sh # Add Multi Relay Chat Client source $MSTEMPDIR/mystic/mrc-client/config-${SCRIPT_VER}.sh # Add Multi Relay Chat Server source $MSTEMPDIR/mystic/mrc-server/config-${SCRIPT_VER}.sh # Add Cryptlib support source $MSTEMPDIR/mystic/cryptlib/config-${SCRIPT_VER}.sh # Add IP2Location source $MSTEMPDIR/mystic/ip2location/config-${SCRIPT_VER}.sh # Add DBP Scripts source $MSTEMPDIR/mystic/dbp/config-${SCRIPT_VER}.sh # Add Fail2ban | banip source $MSTEMPDIR/mystic/fail2ban/config-${SCRIPT_VER}.sh # Add Dosemu2 if [ -n "${DOSEMUVER}" ]; then source $MSTEMPDIR/mystic/dosemu2/config-${SCRIPT_VER}.sh fi #============================================================================================================== msg_ok "Completed Successfully!\n" #============================================================================================================== DBP_INFO=${MYSTIC_DIR}/docs/DbP-install.info echo "==============================================================================================================" > ${DBP_INFO} # Mystic install source $MSTEMPDIR/mystic/mystic/info-${SCRIPT_VER}.sh # Add Spellcheck source $MSTEMPDIR/mystic/spellcheck/info-${SCRIPT_VER}.sh # Add Multi Relay Chat Client source $MSTEMPDIR/mystic/mrc-client/info-${SCRIPT_VER}.sh # Add Multi Relay Chat Server source $MSTEMPDIR/mystic/mrc-server/info-${SCRIPT_VER}.sh # Add Cryptlib support source $MSTEMPDIR/mystic/cryptlib/info-${SCRIPT_VER}.sh # Add IP2Location source $MSTEMPDIR/mystic/ip2location/info-${SCRIPT_VER}.sh # Add DBP Scripts source $MSTEMPDIR/mystic/dbp/info-${SCRIPT_VER}.sh # Add Fail2ban | banip source $MSTEMPDIR/mystic/fail2ban/info-${SCRIPT_VER}.sh # Add Dosemu2 if [ -n "${DOSEMUVER}" ]; then source $MSTEMPDIR/mystic/dosemu2/info-${SCRIPT_VER}.sh fi #============================================================================================================== echo "if you want to start some mystic tools become the mystic user first (su - mystic) or" >> ${DBP_INFO} echo "start the command with sudo -u mystic ./mis ...." >> ${DBP_INFO} echo "when you switched to the ${MYSTIC_DIR}" >> ${DBP_INFO} echo "" >> ${DBP_INFO} echo "==============================================================================================================" >> ${DBP_INFO} cmd_exec chown mystic:mystic -R ${MYSTIC_DIR} &>$INSTALLLOG cat ${DBP_INFO} echo "These Infos are also been put into ${DBP_INFO}"