First, a disclaimer... I have no idea about Linux, this is my first attempt to write a bash script in 10 years... so forgive me if it's a) not formatted properly, b) fails on your system, or c) can be improved.
My goal was to make one script for start, stop, status, and restarting Emu. I think I have everything working except that last MiniLogin.exe thing. I've tried eq4me's last suggestion, but I am getting a "Failed to open port 5999". If I run wine MiniLogin.exe by itself, I usually get it to work (though, connecting a client *still* isn't quite working hehe...)
Ok, this post is just about the script. So, take this, tweak,and hope it comes in handy. It's a little "heavy", but adds some checks and balances.
Code:
#! /bin/bash
# Original Script Author: ???
# Editor: John Adams - 10/2006
#
case "$1" in
start)
if [ -e .lock-world ] || [ -e .lock-launcher ] || [ -e .lock-minilogin ]
then
echo "The emulator appears to already be running ?";
echo "If you are sure the server is not running, delete .lock-world and .lock-launcher."
exit 1
else
if [ "$UID" = "0" ]
then
echo WARNING ! For security reasons we advise: DO NOT RUN THE SERVER AS ROOT
exit 1
fi
echo "Attempting to start the World..."
if [ -e world ]
then
if [ ! -x world ]
then
echo "world is not executable, trying to set it"
chmod u+x world
fi
if [ -x world ]
then
ulimit -c 99999999
rm -f .world_shutdown
set -x
LNAME="peq" #launcher name
if [ "$1" = "test" ]
then
LNAME="test"
fi
P=`pwd`
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$P"
mkdir -p logs 2>&1 > /dev/null
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
if [ ! -e .lock-world ]
then
touch .lock-world
./persist_world 2>&1 > logs/world &
sleep 15
fi
else
echo "World is still not executable. Fix this!"
exit 4
fi
else
echo "Couldnt find world"
exit 5
fi
# Launcher
echo "Attempting to start Launcher/Zones..."
if [ -e eqlaunch ]
then
if [ ! -x eqlaunch ]
then
echo "Launcher is not executable, trying to set it..."
chmod u+x eqlaunch
fi
if [ -x eqlaunch ]
then
rm -f .zone_shutdown
LNAME="zones" #launcher name
if [ ! -e .lock-launcher ]
then
touch .lock-launcher
./eqlaunch $LNAME 2>&1 > logs/launcher &
sleep 40 #wait on launchers to start minilogin
fi
else
echo "World is still not executable. Fix this!"
exit 4
fi
else
echo "Couldnt find eqlaunch"
exit 5
fi
# If MiniLogin.exe exists, launch it last (Angelox)
echo "Attempting to start MiniLogin.exe . . ."
if [ -e MiniLogin.exe ]
then
if [ ! -x MiniLogin.exe ]
then
echo "MiniLogin.exe is not executable, trying to set it..."
chmod u+x MiniLogin.exe
fi
if [ -x MiniLogin.exe ]
then
rm -f .minilogin_shutdown
if [ ! -e .lock-minilogin ]
then
touch .lock-minilogin
wine MiniLogin.exe > /tmp/Minilogin.log &
fi
else
echo "World is still not executable. Fix this!"
exit 4
fi
else
echo "Couldnt find eqlaunch"
exit 5
fi
fi
;;
stop)
echo "Attempting to stop the World..."
touch .minilogin_shutdown
touch .zone_shutdown
touch .world_shutdown
killall world eqlaunch zone wineserver MiniLogin.exe
sleep 3
if ps ax|grep -e 'w[o]rld' -e 'z[o]ne' -e 'eq[l]aunch' >/dev/null
then
killall -9 world eqlaunch zone wineserver MiniLogin.exe
sleep 2
fi
./cleanipc
rm -f .lock-zones .lock-world .lock-login .lock-launcher .lock-minilogin
;;
status)
if [ -e world.pid ]; then
echo "the server seems to be running"
exit 0
else
echo "the server seems to be stopped"
exit 3
fi
;;
restart)
echo "restart all eqemulator services - not implemented yet"
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 2
esac
exit 0
Drop this in your server dir, and run it as ./emu start|stop|status (one of those three options)
Not sure how to do the restart option. Anyone?