diff --git a/ngbot.sh b/ngbot.sh new file mode 100755 index 0000000..13bcce5 --- /dev/null +++ b/ngbot.sh @@ -0,0 +1,129 @@ +#!/bin/bash +# This script builds an eggdrop with getops.mod, netbots TCL and some other custom scripts +# Author: bisco @ IRCNet + +set -e + +# Variables +PREFIX="$HOME/bot" +MIRROR=https://static.younerd.org/tarballs +CODE="ngbot-0.2.tar.gz" +SCRIPTPATH=$(dirname "$(readlink -f "$0")") +CODEDIR="$SCRIPTPATH/ngbot" +EGGSOURCE="$CODEDIR/source" +ADDITIONAL="$CODEDIR/additional" + + +# Code - DO NOT EDIT BELOW + +# check_error function +# This function checks if the previous command has a non-zero exit code. + +function check_error() +{ + if [ $? -ne 0 ]; then + echo "[x] ERROR" + exit 1 + else + echo "[v] OK" + fi +} + +trap check_error EXIT + +# usage function +# Do you need an explaination? Really?! + +function usage() +{ + echo "Usage $0 [command]" + echo "" + echo "Options available:" + echo "-p|--prepare runs all the step to prepare the botpack" + echo "-b|--build builds and install the bot" + echo "-c|--clean emoves the source directory" + echo "-a|--all install and clean functions" + echo "" + echo "-h|--help shows this help and exit" + echo "" +} + +# get_source function +# This function retrieves the code from mirror + +get_source() +{ + echo "[*] Downloading source code" + cd "$HOME" + wget $MIRROR/$CODE + echo "" + echo "[*] Extracting source code" + tar xzf $CODE + cd "$CODEDIR" + tar xzf "$CODEDIR"/eggdrop-1.9.5.tar.gz + mv "$CODEDIR"/eggdrop-1.9.5 "$EGGSOURCE" + cd "$HOME" + rm -rf $CODE +} + + +# assembly_botpack function +function assembly_botpack() +{ + cp "$ADDITIONAL"/eggdrop.conf "$EGGSOURCE" + cp -r "$ADDITIONAL"/getops.mod "$EGGSOURCE"/src/mod/ + rm "$EGGSOURCE"/scripts/getops.tcl + mv "$EGGSOURCE"/src/mod/getops.mod/getops.tcl/getops-3.0d.tcl "$EGGSOURCE"/scripts/getops.tcl + rm -r "$EGGSOURCE"/src/mod/getops.mod/getops.tcl + cp "$ADDITIONAL"/motd "$EGGSOURCE"/text/ +} + + +# build_source function +# This function build the eggdrop code. + +function build_source() +{ + echo "[*] Building eggdrop code" + cd "$EGGSOURCE" + ./configure --prefix="$PREFIX" + make config + make + echo "" + echo "[*] Installing eggdrop and scripts" + make install + echo "" + cp -r "$ADDITIONAL"/scripts/b_pack "$PREFIX"/scripts/ + cp -r "$ADDITIONAL"/scripts/netbots "$PREFIX"/scripts/ + echo "[v] NGBot installed! Please edit $PREFIX/eggdrop.conf and adjust the variables to fit your needs" + echo "[!] DO NOT FORGET: adjust the nb_bots and nb_key variables into netset.tcl" + echo "" +} + + +# remove_build function +# This function remove +function remove_build() +{ + echo "[*] Removing source and build directory" + cd "$HOME" + rm -rf "$CODEDIR" +} + + +case "$1" in + -p|--prepare) + get_source; + assembly_botpack;; + -b|--build) + build_source;; + -c|--clean) + remove_build;; + -a|--all) + get_source; + assembly_botpack; + build_source; + remove_build;; + -h|--help|*) + usage;; +esac