Go Back   EQEmulator Home > EQEmulator Forums > Support > Support::Linux Servers

Support::Linux Servers Support forum for Linux EQEMu users.

Reply
 
Thread Tools Display Modes
  #1  
Old 05-09-2010, 09:36 PM
orkim
Sarnak
 
Join Date: Sep 2008
Location: -
Posts: 31
Default

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:
  1. Run the script to create the symlinks and start/stop/persist_world files.
  2. Run all 4 get scripts to check out the latest code from SVN repositories.
  3. Optionally configure for bots before compile.
  4. 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)
  5. Optionally compile the EQEmuLoginServer
    (Don't forget to copy the needed encryption includes over!)
  6. Copy eqemu_config.xml.full to eqemu_config.xml in the server directory and edit appropriately.
  7. Optionally copy the login server support files to the server directory if desired.
    (These are the 'login*' files in projecteqemu\EQLoginServer\login_util\ direcotry.)
  8. Copy the 'spells_en.txt' and 'spells_us.txt' files to your server directory.
  9. Edit the 'eqemu.conf' file to start the appropriate servers.
  10. Source the database, and apply an new updates since the last PEQ database if desired.
  11. 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
Reply With Quote
  #2  
Old 05-10-2010, 01:19 AM
Kobaz
Hill Giant
 
Join Date: Nov 2008
Location: Gold Coast, Oz
Posts: 119
Default

Hi Ork!

I've had a read across your script, and it's much nicer than mine. Mine was
what works on my bastardised server, and I'll try yours once I've got my
feet under me a bit (translation: my doctor has changed my prescriptions,
and I'm so shit faced I dare not look at a shell prompt! The other day I
typed "rm a_file_I_wanted_to_delete `ls`" without the double quotes due to
these bloody pain drugs.... forgot to hit enter between the rm and the ls....
as for the backticks, I have no idea! Lucky I believe in backups).

I guess the next step is to add some sed calls to allow for bot creation, and
calls to make, along with DB tracking and server version tracking, backups
and sourcing utils/sql files. I've been meaning to do that for a while now,
between hospital visits.

I'll eventually see how this works under different distros as well - although
your script looks like it should be happy regardless.
Reply With Quote
  #3  
Old 05-10-2010, 07:20 PM
orkim
Sarnak
 
Join Date: Sep 2008
Location: -
Posts: 31
Default

Kobaz,

I think some sort of sed script or similar for setting up bots/eqemuloginserver/etc would be nice. I started to go down
that path, but then realized that some people might not have a stable internet connection. I've got a fast one and
even getting the maps/source/etc only takes me 3 or 4 minutes, but should the SVN download fail you might need to
restart that process.

The problem with the sed scripts would be that you need to have downloaded the code repos, obviously, in order to run
said (or 'sed', heh) scripts. I'm not so sure building that into the 'setup script' would be good. However, we might be
able to make these as other little 'helper scripts' in the main folder (where the get scripts are) and allow the user to
optionally run these. That would be handy for me personally. Maybe a 'enable_bots.sh', 'disable_bots.sh', and
'setup_loginserver.sh' or something to do the appropriate tasks.

Just a few thoughts I had, when I started to go down that path. I just prettied up the scripts and posted it for some
feedback though, so I haven't headed far down the path.

-ork
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 02:24 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3