L2JMobius

Frost Lord Shell script to start/stop both login and game servers.

mrk · 1 · 359

Offline mrk

  • Heir
  • **
    • Posts: 20
Save the following code with the name "m.sh" in the root folder. Give him execute permissions.

Code: [Select]
#!/bin/bash
# stop both game and login server
if [[ $1 = "stop" ]]
then
echo "Stoping All..."
ps -ef | grep 'LoginServerTask.sh' | grep -v grep | awk '{print $2}' | xargs -r kill -9
ps -ef | grep 'GameServerTask.sh' | grep -v grep | awk '{print $2}' | xargs -r kill -9
pkill -9 -f GameServer.jar
pkill -9 -f LoginServer.jar
# starts both game and login server
else
cd login
./LoginServer.sh
cd ../game
./GameServer.sh
cd ..
# space-delimited list of colon-delimited tab name, log file pairs
LOGS="./login/log/stdout.log ./game/log/stdout.log"

args=""
for log in $LOGS
do
 tab_name=${log%:*}
 log_file=${log#*:}
 args=" $args --tab -e \"bash -c \\\"printf '\033]2;%s\007' '$tab_name'; tail -f $log_file\\\"\""
done
eval "gnome-terminal --hide-menubar --maximize $args"
fi

Use the command below to start both login/game servers:

Code: [Select]
$ ./m.sh
or

Code: [Select]
$ ./m.sh stop
to stop both.