Skip to content

Instantly share code, notes, and snippets.

@zxjinn
Last active December 14, 2015 06:39
Show Gist options
  • Save zxjinn/5044260 to your computer and use it in GitHub Desktop.
Save zxjinn/5044260 to your computer and use it in GitHub Desktop.
# ubuntu 12.04, assuming fresh install, still a work in progress
24 Feb 2013
###### as root user
# install pre-reqs
apt-get update
apt-get -y upgrade
apt-get -y dist-upgrade
apt-get -y install gcc g++ make cmake unzip subversion git-core gzip
apt-get -y install libio-stringy-perl libperl-dev libdbi-perl
apt-get -y install mysql-server libmysqlclient-dev #type and remember mysql root password
# create user
useradd -m -s /bin/bash eqemu
# change user to eqemu
sudo su - eqemu
###### as eqemu user
mkdir -p ~/server/shared
mkdir ~/pids
git clone git://github.com/EQEmu/Server.git ~/source
cd ~/source
# if bots are desired, run this sed command. Otherwise, skip it
sed -i CMakeLists.txt -e 's|"Enable Bots" OFF|"Enable Bots" ON|g'
cmake .
make -j$(grep -c processor /proc/cpuinfo)
# copy compiled bins and patches to server folder
cd ~/server
cp -rv ~/source/utils/defaults/* ./
cp -rv ~/source/Bin/* ./
cp -rv ~/source/utils/patches/* ./
# get quests and maps, Maps will take a while
svn co http://projecteqquests.googlecode.com/svn/trunk/quests quests
svn co http://eqemu-maps.googlecode.com/svn/trunk/ Maps
# copy quest plugins
cp -rv ./quests/plugins/ ./plugins
# get and set up peq db
cd ~
svn co http://projecteqdb.googlecode.com/svn/trunk/peqdatabase
cd peqdatabase
gunzip peqdb_rev*.sql.gz
SVNP="~/source/utils/sql/svn"
GITRP="~/source/utils/sql/git/required"
GITOP="~/source/utils/sql/git/optional"
CURV=$(ls -1 peqdb_rev*sql | awk '{ print $NF }' | sed -e 's|rev|.|' | awk -F'.' '{ print $(NF-1) }')
eval SVNP=$SVNP
eval GITRP=$GITRP
eval GITOP=$GITOP
echo "create database if not exists peq;" > mysqlcommands
echo "use peq;" >> mysqlcommands
echo "source $(ls -1 peqdb_rev*sql | awk '{ print $NF }')" >> mysqlcommands
echo "source load_player.sql" >> mysqlcommands
echo "source load_bots.sql" >> mysqlcommands
#echo "source $SVNP/bots.sql" >> mysqlcommands # not sure if this is needed, awaiting feedback from git issue #15
#echo "source $SVNP/mercs.sql" >> mysqlcommands # ditto
# patch/update peq db
ls -1 ${SVNP}/[0-9]* | uniq | xargs -n1 basename | sort -n | awk -v c=$CURV -F'_' '$1 >= c' | sed "s|^|source $SVNP/|g" >> mysqlcommands
ls -1 ${GITRP}/ | uniq | xargs -n1 basename | sort -n | sed "s|^|source $GITRP/|g" >> mysqlcommands
#ls -1 ${GITOP}/ | uniq | xargs -n1 basename | sort -n | sed "s|^|source $GITOP/|g" >> mysqlcommands # you can skip this step if you want
# execute mysql updates
mysql -u root -p < mysqlcommands
# edit config files
cd ~/server
rm eqemu_config.xml
cp eqemu_config.xml.full eqemu_config.xml
vim eqemu_config.xml
#### back as root
cp /home/eqemu/server/libEMuShareMem.so /usr/lib/libEMuShareMem.so
#!/bin/bash
ARG1=$1
EQUSER="eqemu"
EQROOT="/home/$EQUSER"
if [ "$ARG1" == "" ]; then
echo "No args. $0 [start|stop]"
exit 2
fi
if [ $UID -ne 0 ]; then
echo "You are not root, go away."
exit 3
fi
binarray=( shared_memory world queryserv ucs eqlaunch )
case $ARG1 in
start)
for i in ${binarray[@]}
do
echo "Starting $i"
if [ "$i" == "eqlaunch" ]; then EQPARAM="zone"; fi
start-stop-daemon --make-pidfile --pidfile $EQROOT/pids/$i.pid --quiet --chuid $EQUSER --start --chdir $EQROOT/server --background --exec $EQROOT/server/$i --startas $EQROOT/server/$i -- $EQPARAM
if [ "$i" == "world" ]; then echo "Sleeping 10" ; sleep 10; fi
done
;;
stop)
# Stops in reverse order
for ((i=${#binarray[@]}-1; i>=0; i--))
do
echo "Stopping ${binarray[$i]}"
start-stop-daemon --stop --quiet --oknodo --pidfile $EQROOT/pids/${binarray[$i]}.pid --exec $EQROOT/server/${binarray[$i]}
done
;;
status)
for i in ${binarray[@]}
do
ps aux | grep -v grep |grep $i
done
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment