Skip to content

Instantly share code, notes, and snippets.

@nosmall
Last active June 15, 2016 16:11
Show Gist options
  • Save nosmall/ef0f436ed52f0feb6f34414105fabeb9 to your computer and use it in GitHub Desktop.
Save nosmall/ef0f436ed52f0feb6f34414105fabeb9 to your computer and use it in GitHub Desktop.
TrinityCore Auto Compiler / Ubuntu / 6.x
#!/bin/bash
## CONF ##
ADMINEMAIL="docompile@domain.tld"
CPUJOBS=8
DIRPATH=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd -P)
##DIRPATH="/home/wow/server"
if [ "$1" = "clone" ]; then
cd $DIRPATH && rm -rf TrinityCore
echo "TrinityCore REPOSITORY is deleted"
git clone -b 6.x git://github.com/TrinityCore/TrinityCore.git
fi
if [ "$1" = "clean" ]; then
cd $DIRPATH/TrinityCore && rm -rf build
echo "Old build is deleted"
fi
if [ "$1" = "make" -o "$1" = "compile" ]; then
if [ "$2" = "debug" -o "$3" = "debug" ]; then
export CXXFLAGS="-O1 -ggdb3"
export CFLAGS="-O1 -ggdb3"
EXTOPTIONS="-DWITH_COREDEBUG=1 -DCMAKE_BUILD_TYPE=RelWithDebug"
fi
cd $DIRPATH/TrinityCore && mkdir -p build && cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=$DIRPATH -DCONF_DIR=$DIRPATH/etc -DTOOLS=1 -DWITH_WARNINGS=1 $EXTOPTIONS
if [ "$2" = "cmake" -o "$3" = "cmake" ]; then
read -n1 -r -p "Press SPACE to continue MAKE or CTRL+C to EXIT" KEY
if [ "$KEY" = '' ]; then
make -j${CPUJOBS}
fi
else
make -j${CPUJOBS}
fi
fi
if [ "$1" = "install" -o "$1" = "compile" ]; then
cd $DIRPATH/TrinityCore/build && make install
fi
if [ "$1" = "compile" ]; then
screen -S tmpCompilation_${PWD##*/} -X quit
fi
if [ "$1" = "notify" ] || [ "$2" = "notify" ] || [ "$3" = "notify" ] || [ "$4" = "notify" ]; then
touch screenlog.0
echo "$(date +"%T %d-%m-%Y") SERVER COMPILATION DONE! Full report in attachment." | mutt -a "$DIRPATH/screenlog.0" -s "$(date +"%T %d-%m-%Y") / Compilation REPORT" -- $ADMINEMAIL
fi
if [ "$1" = "help" -o "$1" = "-help" -o "$1" = "-h" -o "$1" = "" ]; then
echo ""
echo "Command: ./do clone | STEP 1 - download clear binary from TrinityCore - github"
echo "Command: ./do clean | - delete old build"
echo ""
echo "Command: ./do make | STEP 2 - make Release"
echo "Command: ./do make debug | - make RelWithDebug"
echo "Command: ./do make cmake | - make Cmake Release & wait for ENTER"
echo "Command: ./do make debug cmake | - make Cmake RelWithDebug & wait for ENTER"
echo ""
echo "Command: ./do install | STEP 3 - install compiled core"
echo ""
echo "Command: ./do compile | STEP 2,3 - make & install core"
echo "Command: ./do compile debug | - make debug & install core"
echo ""
echo "Command: ./do allCommands notify | EXTRA - notify via email about JOB is DONE"
echo ""
fi
#! /bin/bash
screen -L -A -m -d -S tmpCompilation_${PWD##*/} ./do compile debug notify
ls -l
screen -ls
echo "Screen (tmpCompilation_${PWD##*/}) will be closed automatically. (after compilation)"
echo "a) Check progress: screen -x tmpCompilation_${PWD##*/}"
echo "b) You must detach screen using Ctrl-a-d"
echo ""
sudo apt-get install screen mutt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment