Hey Kobaz! I've thought this was a great idea, and I've expanded upon what you have originally made.
First off, let me say this was a great start. I've added a configure script that I use personally, as well as fixed some bugs that I've noticed with your script. Likewise, I've put a few of my own twists on this so that the date/time and version of the script is put into the bash files.
Here's the noteable changes:
- Commented heavily
- Added support for SOD with new symlinks
- Added symlink for EQLoginServer (minus configuration files)
- Properly escaped variables on the 'cat' out of the files so the variables are actually in the file start/stop/persist_world files
- Added (my own) custom start/stop editions which is contolable via a 'eqemu.conf' file which can start/stop the chat/mail/login server(s)
- Updated the "get scripts" names to have a more standardized naming convention
- Updated the "get scripts" to checkout from svn without extra directories (just how I do it, I think its cleaner and isn't as deep)
- Added a echo variable so the time/date and the version of the script that generated the start/stop/persist_world files (all of these are 99% taken from the linux install wiki page)
- Updated the symlinks to work with the (updated) svn checkout process
- Changed shebang lines to use /bin/bash instead of /bin/sh so the source command will work properly
I'm not sure that is a comprehensive list, but it's most of the changes I have made. This layout seems to make the updating and installation a bit simpler. I've been very happy using this and I hope the community at large can make use of it. I've included the source below. I've tested this here a few times and I'm able to get a server up and running with about 10 minutes of work (mostly involving editing configuration files).
A short list, in the proper order, to make a server is listed here:
- Run the script to create the symlinks and start/stop/persist_world files.
- Run all 4 get scripts to check out the latest code from SVN repositories.
- Optionally configure for bots before compile.
- Compile the server in projecteqemu direcotry
(You might spend some time here getting the required headers, or fixing any minor bugs that exist in SVN)
- Optionally compile the EQEmuLoginServer
(Don't forget to copy the needed encryption includes over!)
- Copy eqemu_config.xml.full to eqemu_config.xml in the server directory and edit appropriately.
- Optionally copy the login server support files to the server directory if desired.
(These are the 'login*' files in projecteqemu\EQLoginServer\login_util\ direcotry.)
- Copy the 'spells_en.txt' and 'spells_us.txt' files to your server directory.
- Edit the 'eqemu.conf' file to start the appropriate servers.
- Source the database, and apply an new updates since the last PEQ database if desired.
- Use the ./start and ./stop scripts provided in the server directory to run the server.
I think this pretty much sums up what I've got so far. Please let me know any comments. I'd really love to see this turned into a script that can simplify the server setup process. I think this is a good start.
If anyone would like to collaborate on a wiki page for this (maybe include directions on keeping an up-to-date server as well?) or something else let me know. I'm using this personally and can roll out a new server very quickly.
Here's the new eqemu.sh I've created:
Code:
#!/bin/bash
################################################################################
# Configuration Section
################################################################################
# Directory to install EQEmu into.
EMUDIR=eqemulator
################################################################################
# End Configuration Section
#
# NOTE: You probably don't need to edit below here unless you're familar with
# EQEmu and the installation process.
################################################################################
################################################################################
# Variables
################################################################################
EQEMU_INSTALLER_VER=1.0
EQEMU_INSTALL_DATE=`date`
################################################################################
# Sanity Checks
################################################################################
# Check for existing directory before we begin.
if [ -e $EMUDIR ]; then
echo
echo "Installation directory already exists - exiting to avoid potential damage."
exit
fi
# Check for running this script as root.
if [ $EUID -eq 0 ]; then
echo
echo "You are running this script as root - you really shouldn't!"
exit
fi
################################################################################
# Create EQEmu Directory
################################################################################
mkdir $EMUDIR
cd $EMUDIR
################################################################################
# Helper Script Creation
################################################################################
cat > get_eqemu << EOD1
#!/bin/bash
# Auto generated by EQEmu Installer v$EQEMU_INSTALLER_VER on $EQEMU_INSTALL_DATE
svn checkout http://projecteqemu.googlecode.com/svn/trunk/EQEmuServer/ projecteqemu
EOD1
cat > get_maps << EOD2
#!/bin/bash
# Auto generated by EQEmu Installer v$EQEMU_INSTALLER_VER on $EQEMU_INSTALL_DATE
svn checkout http://eqemumaps.googlecode.com/svn/trunk/ eqemumaps
EOD2
cat > get_db << EOD3
#!/bin/bash
# Auto generated by EQEmu Installer v$EQEMU_INSTALLER_VER on $EQEMU_INSTALL_DATE
svn checkout http://projecteqdb.googlecode.com/svn/trunk/peqdatabase/ projecteqdb
EOD3
cat > get_quests << EOD4
#!/bin/bash
# Auto generated by EQEmu Installer v$EQEMU_INSTALLER_VER on $EQEMU_INSTALL_DATE
svn checkout http://projecteqquests.googlecode.com/svn/trunk/quests/ projecteqquests
EOD4
# Make all scripts executable.
for script in get_eqemu get_maps get_db get_quests ; do chmod +x $script ; done
################################################################################
# Create Runtime Directory
################################################################################
mkdir server
################################################################################
# Set Symlinks
################################################################################
cd server
# Set our seperate project symlinks first.
ln -s ../projecteqquests .
ln -s ../eqemumaps/Maps .
ln -s ../projecteqquests/plugins .
# Set our main symlink for easy updating later.
ln -s ../projecteqemu/ source
# Populate our list of symlinks.
symtargets="source/chatserver/chatserver \
source/utils/cleanipc \
source/utils/defaults/eqemu_config.xml.full \
source/EQEmuLoginServer/EQEmuLoginServer \
source/eqlaunch/eqlaunch \
source/EMuShareMem/libEMuShareMem.so \
source/utils/defaults/log.ini \
source/EQEmuLoginServer/login_util/login_opcodes.conf \
source/EQEmuLoginServer/login_util/login_opcodes_sod.conf \
source/utils/mail_opcodes.conf \
source/mailserver/mailserver \
source/utils/defaults/mime.types \
source/utils/opcodes.conf \
source/utils/patch_6.2.conf \
source/utils/patch_Anniversary.conf \
source/utils/patch_Live.conf \
source/utils/patch_SoD.conf \
source/utils/patch_SoF.conf \
source/utils/patch_Titanium.conf \
source/utils/defaults/plugin.pl \
source/utils/defaults/templates \
source/world/world \
source/utils/defaults/worldui \
source/utils/defaults/worldui.pl \
source/zone/zone"
for tar in $symtargets ; do
ln -s $tar .
done
################################################################################
# Configure Script
################################################################################
cat > eqemu.conf << EOD5
# EQEmu Installer Configuration File
# Auto generated by EQEmu Installer v$EQEMU_INSTALLER_VER on $EQEMU_INSTALL_DATE
# Should we start/stop a login server? Comment this out if you do not want to
# run your own login server.
USE_LOGIN_SERVER=1
# Should we start/stop a chat server? Comment this out if you do not want to run
# your own chat server.
USE_CHAT_SERVER=1
# Should we start/stop a mail server? Comment this out if you do not want to run
# your own mail server.
USE_MAIL_SERVER=1
# Should we use the persist_world script? If this variable is set we will use
# the persist_world script when starting the world server. This should detect
# and restart the world server should it crash. You may uncomment this if you
# would prefer running the world server directly (with no automatic restart if a
# crash were to occur).
USE_PERSIST_WORLD=1
EOD5
################################################################################
# Start Script
################################################################################
cat > start << EOD6
#!/bin/bash
# Auto generated by EQEmu Installer v$EQEMU_INSTALLER_VER on $EQEMU_INSTALL_DATE
# Include our configuration.
source eqemu.conf
#ulimit -c 99999999
# Start the login server.
if [ \$USE_LOGIN_SERVER ]; then
./EQEmuLoginServer 2>&1 > logs/loginserver &
fi
# Remove any shutdown files.
rm -f .zone_shutdown
rm -f .world_shutdown
# Print commands and their arguments as they are executed.
set -x
# Launcher name.
LNAME="zone"
if [ "\$1" = "test" ]; then
LNAME="test"
fi
# Set our library path.
P=`pwd`
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:\$P"
# Make sure we have a place to log.
mkdir -p logs 2>&1 > /dev/null
# Clear out old logs, if both are stopped.
if [ ! -e .lock-zones -a ! -e .lock-world ] ; then
for f in logs/eqemu_*.log
do
# Keep the commands_zone log.
if [ "\$f" = "logs/eqemu_commands_zone.log" ]; then
continue;
fi
rm -f \$f
done
fi
# Boot up world.
if [ ! -e .lock-world ] ; then
# Create our lock file.
touch .lock-world
# Determine how to run the world server.
if [ \$USE_PERSIST_WORLD ]; then
./persist_world 2>&1 > logs/world &
else
./world 2>&1 > logs/world &
fi
# wait for shared memory to load
sleep 15
fi
# Start up the official launcher.
if [ ! -e .lock-launcher ]; then
# Create our lock file.
touch .lock-launcher
# Launch!
./eqlaunch \$LNAME 2>&1 > logs/launcher &
fi
# Determine if we should start the chat server.
if [ \$USE_CHAT_SERVER ]; then
./chatserver 2>&1 > logs/chatserver &
fi
# Determine if we should start the mail server.
if [ \$USE_MAIL_SERVER ]; then
./mailserver 2>&1 > logs/mailserver &
fi
EOD6
################################################################################
# Stop Script
################################################################################
cat > stop << EOD7
#!/bin/bash
# Auto generated by EQEmu Installer v$EQEMU_INSTALLER_VER on $EQEMU_INSTALL_DATE
# Include our configuration.
source eqemu.conf
# Create our shutdown files.
touch .zone_shutdown
touch .world_shutdown
targets="world eqlaunch zone"
# Login Server Check
if [ \$USE_LOGIN_SERVER ]; then
targets="\$targets EQEmuLoginServer"
fi
# Chat Server Check
if [ \$USE_CHAT_SERVER ]; then
targets="\$targets chatserver"
fi
# Mail Server Check
if [ \$USE_MAIL_SERVER ]; then
targets="\$targets mailserver"
fi
killall \$targets
# Small pause here.
sleep 3
# If world/zone/eqlaunch is stuck we'll 'kill -9' them here.
if ps ax | grep -e 'w[o]rld' -e 'z[o]ne' -e 'eq[l]aunch' > /dev/null; then
killall -9 world zone eqlaunch
sleep 2
fi
# Run our IPC cleaning.
./cleanipc
# Remove any lock files.
rm -f .lock-zones .lock-world .lock-login .lock-launcher
EOD7
################################################################################
# Persist Script
################################################################################
cat > persist_world << EOD8
#!/bin/bash
#ulimit -c 99999999
while true
do
./world "\$@"
if [ -r ".world_shutdown" ]; then
exit 0
fi
echo `date` " - World crashed." >> crashlog
sleep 2
done
EOD8
########################################
# Set our scripts executable.
########################################
for script in start stop persist_world ; do chmod +x $script ; done
################################################################################
# Final Steps
################################################################################
cat << EOD | more
Things you still have to do:
- Run the 4 "get" scripts: cd ${EMUDIR} && ./get_db && ./get_quests && ./get_maps && ./get_eqemu
- Build the server: cd projecteqemu && make
- Build the login server
- Create/Edit your eqemu_config.xml in ${EMUDIR}/server
- Create/Edit your login server configuration
- Copy your spells_en.txt and spells_us.txt to ${EMUDIR}/server
- Source the database
- Edit the ${EMUDIR}/server/eqemu.conf file to start and stop the proper servers you use
Once all thats done, change to the ${EMUDIR}/server and run
./start
to start the server and
./stop
to stop it.
Check your logfiles in ${EMUDIR}/server/logs.
EOD
-ork