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 03-09-2010, 08:35 PM
Kobaz
Hill Giant
 
Join Date: Nov 2008
Location: Gold Coast, Oz
Posts: 119
Default Script to help setup server on Linux

The following script sets up the directories for building and running your server. It also creates scripts to get files from the subversion servers.
It is based on the Debian guide in the wiki, but could be used on any system that has bash.

Hope this helps...

Code:
#!/bin/bash

#Set this variable to where you want eqemu to go
EMUDIR=eqemuserver

if [ -e $EMUDIR ]; then 
   echo
   echo $EMUDIR already exists - exiting to avoid potential confusion
   echo  you might want to edit this script and set the EMUDIR to somewhere else
   exit
fi

if [ $EUID -eq 0 ]; then
   echo
   echo  you are running this script as root, possibly via su or sudo
   echo  EqEmu does not need superuser to install or run, except possibly
   echo  when you are setting up the database
   echo 
   echo  Either install this script as yourself, or create a dedicated
   echo  account to install and run EqEmu.
   echo  #!/bin/bash

#Set this variable to where you want eqemu to go
EMUDIR=eqemuserver

if [ -e $EMUDIR ]; then 
   echo
   echo $EMUDIR already exists - exiting to avoid potential confusion
   echo  you might want to edit this script and set the EMUDIR to somewhere else
   exit
fi

if [ $EUID -eq 0 ]; then
   echo
   echo  you are running this script as root, possibly via su or sudo
   echo  EqEmu does not need superuser to install or run, except possibly
   echo  when you are setting up the database
   echo 
   echo  Either install this script as yourself, or create a dedicated
   echo  account to install and run EqEmu.
   echo  
   echo  Exiting
   exit
fi

mkdir $EMUDIR
cd $EMUDIR

cat > getEqemu << EOD1
#!/bin/bash
svn checkout  http://projecteqemu.googlecode.com/svn/trunk/ projecteqemu-read-only
EOD1

cat > getEQmaps << EOD2
#!/bin/bash
svn checkout http://eqemumaps.googlecode.com/svn/trunk/ eqemumaps-read-only
EOD2

cat > getPEQdb << EOD3
#!/bin/bash
svn checkout http://projecteqdb.googlecode.com/svn/trunk/ projecteqdb-current-only
EOD3

cat > getQuest << EOD4
#!/bin/bash
svn checkout http://projecteqquests.googlecode.com/svn/trunk/ projecteqquests-read-only
EOD4

mkdir server

for s in getEQmaps getPEQdb getQuest getEqemu ; do chmod +x $s ; done

cd server

ln -s ../projecteqemu-read-only/EQEmuServer/ source

targets="source/chatserver/chatserver source/utils/cleanipc source/utils/defaults/eqemu_config.xml.full source/eqlaunch/eqlaunch source/EMuShareMem/libEMuShareMem.so source/utils/defaults/log.ini source/utils/mail_opcodes.conf source/mailserver/mailserver ../eqemumaps-read-only/Maps 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_SoF.conf source/utils/patch_Titanium.conf source/utils/defaults/plugin.pl ../projecteqquests-read-only/quests/plugins ../projecteqquests-read-only/quests source/utils/defaults/templates source/world/world  source/utils/defaults/worldui  source/utils/defaults/worldui.pl  source/zone/zone"

for foo in $targets ; do
    ln -s $foo `basename $foo `
done

echo
echo the start and stop scripts are setup for the Privatelogin server
echo you will want to edit these scripts if you use minilogin or the official
echo login servers
echo

cat > start << EOD5
#!/bin/sh

#ulimit -c 99999999

rm -f .zone_shutdown
rm -f .world_shutdown

set -x

LNAME="zone"     #launcher name
if [ "$1" = "test" ]; then
        LNAME="test"
fi

# The following are for my setup of the PrivateLogin server
# Those who use minilogin or the new private login server will need 
# to modify this to suit -- Kobaz

#cd ../LS
#wine PrivateLogin.exe > logs/PrivateLogin.log &
#cd ../server

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
        if [ "$f" = "logs/eqemu_commands_zone.log" ]; then
                continue;
        fi

        rm -f $f
  done
fi

#boot up world
if [ ! -e .lock-world ] ; then
        touch .lock-world
#       ./world 2>&1 > logs/world &
        ./persist_world 2>&1 > logs/world &
        # wait for shared memory to load
        sleep 15
fi

#start up the official launcher
if [ ! -e .lock-launcher ]; then
        touch .lock-launcher
        ./eqlaunch $LNAME 2>&1 > logs/launcher &
fi

./mailserver &
./chatserver &

EOD5

cat > stop << EOD6
#!/bin/sh

touch .zone_shutdown
touch .world_shutdown

#Users of the official private login server or minilogin
#will need to do something different here -- Kobaz
killall wine PrivateLogin.exe world eqlaunch zone mailserver chatserver
killall -9 PrivateLogin.exe
sleep 3

if ps ax|grep -e 'w[o]rld' -e 'z[o]ne' -e 'eq[l]aunch' -e 'mails[e]rver' -e  'cha[t]server' >/dev/null; then
                killall -9 world eqlaunch zone mailserver chatserver
                sleep 2
fi

./cleanipc
rm -f .lock-zones .lock-world .lock-login .lock-launcher
EOD6

cat > persist_world << EOD7
#!/bin/sh

#ulimit -c 99999999

while true
do
        ./world "$@"
        if [ -r ".world_shutdown" ]; then
                exit 0
        fi

        echo `date` "World crashed." >>crashlog
        sleep 2
done
EOD7

for a in persist_world start stop ; do chmod +x $a ; done

mkdir logs

cat << EOD | more

  Things you still have to do:

  -  create/edit your eqemu_config.xml 

  -  copy your spells_en.txt and spells_us.txt to the server folder

  -  Run the 4 "get" scripts in the eqemu directory. 
     This can take a long time, especially the maps...

  -  Build the server

  -  Source the database

  -  edit the start and stop scripts to reflect which login server 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

   echo  Exiting
   exit
fi

mkdir $EMUDIR
cd $EMUDIR

cat > getEqemu << EOD1
#!/bin/bash
svn checkout  http://projecteqemu.googlecode.com/svn/trunk/ projecteqemu-read-only
EOD1

cat > getEQmaps << EOD2
#!/bin/bash
svn checkout http://eqemumaps.googlecode.com/svn/trunk/ eqemumaps-read-only
EOD2

cat > getPEQdb << EOD3
#!/bin/bash
svn checkout http://projecteqdb.googlecode.com/svn/trunk/ projecteqdb-current-only
EOD3

cat > getQuest << EOD4
#!/bin/bash
svn checkout http://projecteqquests.googlecode.com/svn/trunk/ projecteqquests-read-only
EOD4

mkdir server

for s in getEQmaps getPEQdb getQuest getEqemu ; do chmod +x $s ; done

cd server

ln -s ../projecteqemu-read-only/EQEmuServer/ source

targets="source/chatserver/chatserver source/utils/cleanipc source/utils/defaults/eqemu_config.xml.full source/eqlaunch/eqlaunch  \ 
source/EMuShareMem/libEMuShareMem.so source/utils/defaults/log.ini source/utils/mail_opcodes.conf source/mailserver/mailserver \ 
../eqemumaps-read-only/Maps 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_SoF.conf source/utils/patch_Titanium.conf \
source/utils/defaults/plugin.pl ../projecteqquests-read-only/quests/plugins ../projecteqquests-read-only/quests \
source/utils/defaults/templates source/world/world  source/utils/defaults/worldui  source/utils/defaults/worldui.pl  source/zone/zone"

for foo in $targets ; do
    ln -s $foo `basename $foo `
done

echo
echo the start and stop scripts are setup for the Privatelogin server
echo you will want to edit these scripts if you use minilogin or the official
echo login servers
echo

cat > start << EOD5
#!/bin/sh

#ulimit -c 99999999

rm -f .zone_shutdown
rm -f .world_shutdown

set -x

LNAME="zone"     #launcher name
if [ "$1" = "test" ]; then
        LNAME="test"
fi

# The following are for my setup of the PrivateLogin server
# Those who use minilogin or the new private login server will need 
# to modify this to suit -- Kobaz

#cd ../LS
#wine PrivateLogin.exe > logs/PrivateLogin.log &
#cd ../server

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
        if [ "$f" = "logs/eqemu_commands_zone.log" ]; then
                continue;
        fi

        rm -f $f
  done
fi

#boot up world
if [ ! -e .lock-world ] ; then
        touch .lock-world
#       ./world 2>&1 > logs/world &
        ./persist_world 2>&1 > logs/world &
        # wait for shared memory to load
        sleep 15
fi

#start up the official launcher
if [ ! -e .lock-launcher ]; then
        touch .lock-launcher
        ./eqlaunch $LNAME 2>&1 > logs/launcher &
fi

./mailserver &
./chatserver &

EOD5

cat > stop << EOD6
#!/bin/sh

touch .zone_shutdown
touch .world_shutdown

#Users of the official private login server or minilogin
#will need to do something different here -- Kobaz
killall wine PrivateLogin.exe world eqlaunch zone mailserver chatserver
killall -9 PrivateLogin.exe
sleep 3

if ps ax|grep -e 'w[o]rld' -e 'z[o]ne' -e 'eq[l]aunch' -e 'mails[e]rver' -e  'cha[t]server' >/dev/null; then
                killall -9 world eqlaunch zone mailserver chatserver
                sleep 2
fi

./cleanipc
rm -f .lock-zones .lock-world .lock-login .lock-launcher
EOD6

cat > persist_world << EOD7
#!/bin/sh

#ulimit -c 99999999

while true
do
        ./world "$@"
        if [ -r ".world_shutdown" ]; then
                exit 0
        fi

        echo `date` "World crashed." >>crashlog
        sleep 2
done
EOD7

for a in persist_world start stop ; do chmod +x $a ; done

mkdir logs

cat << EOD | more

  Things you still have to do:

  -  create/edit your eqemu_config.xml 

  -  copy your spells_en.txt and spells_us.txt to the server folder

  -  Run the 4 "get" scripts in the eqemu directory. 
     This can take a long time, especially the maps...

  -  Build the server

  -  Source the database

  -  edit the start and stop scripts to reflect which login server 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

Last edited by Kobaz; 03-09-2010 at 08:40 PM.. Reason: line too long
Reply With Quote
  #2  
Old 03-09-2010, 08:47 PM
Kobaz
Hill Giant
 
Join Date: Nov 2008
Location: Gold Coast, Oz
Posts: 119
Default

For some reason the BB software is messing up the very long line

the line should read

Code:
targets="source/chatserver/chatserver source/utils/cleanipc source/utils \
/defaults/eqemu_config.xml.full source/eqlaunch/eqlaunch \
source/EMuShareMem/libEMuShareMem.so source/utils/defaults/log.ini \
source/utils/mail_opcodes.conf source/mailserver/mailserver ../eqemumaps- \
read-only/Maps 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_SoF.conf source/utils \
/patch_Titanium.conf source/utils/defaults/plugin.pl ../projecteqquests-read-only/quests/plugins \
../projecteqquests-read-only/quests source/utils /defaults/templates \ 
source/world/world  source/utils/defaults/worldui  \
source/utils/defaults/worldui.pl  source/zone/zone"
Reply With Quote
  #3  
Old 03-16-2010, 10:06 AM
MNWatchdog
Hill Giant
 
Join Date: Feb 2006
Posts: 179
Default

This script is certainly helpful, but when you're creating the Start,Stop,Perist_world files there's a problem where anything that is a variable like $LNAME or `date` it puts their current values into the outputted file.

Needless to say, this makes them somewhat useless.

Thanks for you effort and look forward to a fix fr this if there is one.
Reply With Quote
  #4  
Old 03-16-2010, 11:32 AM
MNWatchdog
Hill Giant
 
Join Date: Feb 2006
Posts: 179
Default

I just copied the parts needed to make the Start, Stop and Persist_World script from your script manually into their appropriate files and they work fine from a already open terminal session,
but if I click on them from the file browser and tell it to Run in Terminal I get the text output, but the server doesn't come up. It doesn't seem to want to run Persist_World or EQLaunch while in this mode.

To add to the oddity, if I click on Run instead of Run in Terminal it works fine.

Any ideas?

This is the latest stable Debian that I DLed over the weekend.
Reply With Quote
  #5  
Old 03-16-2010, 03:41 PM
Kobaz
Hill Giant
 
Join Date: Nov 2008
Location: Gold Coast, Oz
Posts: 119
Default

The reason for the weirdness according to how you start it is that when you run it from a terminal you are already in your server folder, so it can find the server.

When you just run it from the "file browser" (nautilus?) you are running from your ~/.desktop, so it can't find the server or the other scripts.

On my machine, I always run them like this:

Code:
ssh paranoia xterm -e ./starteqemu
and

Code:
ssh paranoia xterm -e ./stopeqemu
where paranoia is my server, and the script starteqemu is in my home directory on paranoia and contains

Code:
#!/bin/bash
cd eqemu/server
./start
read $fish
stopeqemu is similar

The read command waits for a carriage return, so I see error messages if something goes awry during start-up.

I've never tried to run the server by clicking on things.
Reply With Quote
  #6  
Old 03-16-2010, 03:48 PM
Kobaz
Hill Giant
 
Join Date: Nov 2008
Location: Gold Coast, Oz
Posts: 119
Default

The other error you found is due to a cut-and-paste error on my part. I've inadvertently double-middle-clicked, and there are two copies of the script end-to-end.

If someone with admin privileges could remove the second copy that would be great, or even if they blow away the script I'll post a SINGLE copy of it into this thread.

This stuff-up actually shows my age, as I'm still not really comfortable with graphical user interfaces. I don't think they are any more user friendly than TOPS-20 was. At least I managed to get over teletypes and IBM card readers, so I'm not a total dinosaur.
Reply With Quote
  #7  
Old 03-19-2010, 08:45 PM
MNWatchdog
Hill Giant
 
Join Date: Feb 2006
Posts: 179
Default

I added cd /home/eqemu/eqemuserver/server to start script and it stilll isn't working.

I would expect that that would solve the issues of the batch thinking it's in different directory, but it's acting the same.

PS Clicking is the present!
Reply With Quote
  #8  
Old 03-19-2010, 11:43 PM
Kobaz
Hill Giant
 
Join Date: Nov 2008
Location: Gold Coast, Oz
Posts: 119
Default

Are you running logged in as eqemu?

have you tried making a shortcut on the panel that goes like:

xterm -e /home/eqemu/server/start

if you use metacity it's add launcher, add custom launcher, and put the command in the box.

what happens if you open a terminal and run at the command line there?

It's hard to say what's going west without some output.
Reply With Quote
  #9  
Old 04-26-2010, 12:57 AM
kai4785
Fire Beetle
 
Join Date: Sep 2007
Posts: 18
Default

This script, though full of bugs and duplicate lines, is awesome! It took me no time at all to get the server up and running.

Ok folks, I'm in. I'm game. This is too easy now. This is my third attempt at trying to find a good way to maintain the server and keep it up to date. With everything in svn on google code, I'm very happy. This script is the perfect starting point for getting what I want done. Thanks so much!

I do most of my work on CentOS servers. I'm sad to see that the server code doesn't compile for 64-bit CentOS 5.4 with out some major modifications to either your system or the code/make files from svn. I'm happy to find that CentOS 32-bit works great. Picking up the broken peices left ove from your script was very easy to do. So I want to give back. I'll try and have another version of the shell script that will actually work here soon.
Reply With Quote
  #10  
Old 04-26-2010, 02:05 AM
Kobaz
Hill Giant
 
Join Date: Nov 2008
Location: Gold Coast, Oz
Posts: 119
Default

That would be great. The script (less the duplicate lines) worked for me. It would be good if we had a script that allowed ppl to build on different distributions and processors with a minimum of trouble.

I'm pretty sure that there needs to be a few changes to cater for SOD, and it would be good if the script could simplify building the login server. I won't have the energy to look at it until after my next trip to hospital <sigh>.
Reply With Quote
  #11  
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
  #12  
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
  #13  
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
  #14  
Old 05-10-2010, 09:43 PM
orkim
Sarnak
 
Join Date: Sep 2008
Location: -
Posts: 31
Default

I did locate a bug in my script. There is a 'ln -s ../projecteqquests .' command which should read
'ln -s ../projecteqquests quests' as the symlink made is not correct. I fixed this manually here.

Likewise, I found a command missing (from at least mine, and maybe from your script too) to make
a symlink for commands.pl in the server directory.

None of the quests worked until I manually made that symlink (in utils/defaults/commands.pl) so I must
have somehow skipped this one.

I've added it to the symtargets variable and all is well again locally.

I'm not reposting the script for the 2 fixes listed above, but these do need to be done.

Hope that helps!

-ork
Reply With Quote
  #15  
Old 05-11-2010, 06:45 PM
kai4785
Fire Beetle
 
Join Date: Sep 2007
Posts: 18
Default

Ha, beat me to it. If there was no such thing as school and work, I might have been able to compete!

I have a webserver on a 100Mb internet connection running SVN if you would like a spot to host the script.
Reply With Quote
Reply


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 12:34 AM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3