Skip to content

Instantly share code, notes, and snippets.

@St3eT
Created September 11, 2014 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save St3eT/ffb02e792d10a2041b26 to your computer and use it in GitHub Desktop.
Save St3eT/ffb02e792d10a2041b26 to your computer and use it in GitHub Desktop.
L2j Manager v2.0 BETA
#
# Version 1.0 [BETA]
# Created by: Street Empire™ - St3eT @ St3eT@seznam.cz
#
#!/bin/bash
SERVER_USER="root" # Linux user what run server
DIR="/home/L2jServer" # Home folder of L2j server
SVN_DIR="/home/SVN" # SVN folder
CORE_NAME="L2J_Server_BETA" #
DP_NAME="L2J_DataPack_BETA" #
ANT="/usr/java/apache-ant-1.9.4/bin/ant" # Ant dir
status() {
echo "-----------------------------"
if ps w -u $SERVER_USER | grep java | grep l2jlogin.jar > /dev/null; then
echo "Login Server is running."
else
echo "Login Server is not running."
fi
if ps w -u $SERVER_USER | grep java | grep l2jserver.jar > /dev/null; then
echo "Game Server is running."
else
echo "Game Server is not running."
fi
echo "-----------------------------"
}
start_ls() {
if ps w -u $SERVER_USER | grep java | grep l2jlogin.jar > /dev/null; then
echo "Login Server is running! Please shutdown Login Server first ..."
else
cd $DIR/login
./startLoginServer.sh
echo "Starting Login Server ..."
fi
}
start_gs() {
if ps w -u $SERVER_USER | grep java | grep l2jserver.jar > /dev/null; then
echo "Game Server is running! Please shutdown Game Server first ..."
else
cd $DIR/game
./startGameServer.sh
echo "Starting Game Server ..."
sleep 2
gslog
fi
}
stop_ls() {
if ps w -u $SERVER_USER | grep java | grep l2jlogin.jar > /dev/null; then
lsPID=0
lsLoopPID=0
lsPID=`ps w -u $SERVER_USER | grep java | grep l2jlogin.jar | awk '{print $1}'`
lsLoopPID=`ps w -u $SERVER_USER | grep /bin/bash | grep LoginServer_loop.sh | awk '{print $1}'`
if [ $lsPID = 0 ]
then
echo "Cant find Login Server PID !!!"
else
echo "Stopping Login Server ..."
kill $lsPID
fi
if [ $lsLoopPID = 0 ]
then
echo "Cant find Login Server PID !!!"
else
echo "Stopping Login Loop ..."
kill $lsLoopPID
fi
else
echo "Login Server is not running!"
fi
}
stop_gs() {
if ps w -u $SERVER_USER | grep java | grep l2jserver.jar > /dev/null; then
lsPID=0
lsLoopPID=0
lsPID=`ps w -u $SERVER_USER | grep java | grep l2jserver.jar | awk '{print $1}'`
lsLoopPID=`ps w -u $SERVER_USER | grep /bin/bash | grep GameServer_loop.sh | awk '{print $1}'`
if [ $lsPID = 0 ]; then
echo "Cant find Game Server PID !!!"
else
echo "Stopping Game Server ..."
kill $lsPID
fi
if [ $lsLoopPID = 0 ]; then
echo "Cant find Game Loop PID !!!"
else
echo "Stopping Game Loop ..."
kill $lsLoopPID
fi
else
echo "Game Server is not running!"
fi
}
update() {
echo "======================== Checking Login and Game server! ========================"
if ps w -u $SERVER_USER | grep java | grep l2jserver.jar > /dev/null; then
echo "Game Server still running and cannot be killed (For safety reasons). Please shutdown Game Server and try it again."
echo "=================================================================================="
./manager.sh
exit
fi
if ps w -u $SERVER_USER | grep java | grep l2jlogin.jar > /dev/null; then
echo "Login Server still running! Trying to switching off ..."
stop_ls
fi
echo "======================== Core: Update SVN + compile sources! ========================"
cd $SVN_DIR/$CORE_NAME/
svn up
$ANT
echo "======================== DataPack: Update SVN + compile sources! ========================"
cd $SVN_DIR/$DP_NAME/
svn up
$ANT
echo "======================== Moving zip files to L2j home folder! ========================"
mv $SVN_DIR/$CORE_NAME/build/$CORE_NAME.zip $DIR/$CORE_NAME.zip
mv $SVN_DIR/$DP_NAME/build/$DP_NAME.zip $DIR/$DP_NAME.zip
echo "======================== Backup up ban files! ========================"
# mv $DIR/game/lameguard/banned_hwid.txt $DIR/banned_hwid.txt -- If you have Lame Guard delete "#" and this text.
mv $DIR/login/banned_ip.cfg $DIR/banned_ip.cfg
echo "======================== Removing old server files! ========================"
rm -rf $DIR/tools
rm -rf $DIR/sql
rm -rf $DIR/login
rm -rf $DIR/libs
rm -rf $DIR/languages
rm -rf $DIR/images
rm -rf $DIR/game
rm -rf $DIR/doc
rm -rf $DIR/community
echo "======================== Unziping new server files! ========================"
cd $DIR
unzip $DIR/$CORE_NAME.zip
cd $DIR
unzip $DIR/$DP_NAME.zip
echo "======================== Deleting .zip files! ========================"
rm $DIR/$CORE_NAME.zip
rm $DIR/$DP_NAME.zip
echo "======================== Copying Geodata files! ========================"
cp -avr $DIR/geodata $DIR/game/data
echo "======================== Restoring ban files! ========================"
# mv $DIR/banned_hwid.txt $DIR/game/lameguard/banned_hwid.txt -- If you have Lame Guard delete "#" and this text.
mv $DIR/banned_ip.cfg $DIR/login/banned_ip.cfg
echo "======================== Starting Login and Game server! ========================"
chmod u=rwx $DIR/login/startLoginServer.sh
chmod u=rwx $DIR/login/LoginServer_loop.sh
chmod u=rwx $DIR/game/startGameServer.sh
chmod u=rwx $DIR/game/GameServer_loop.sh
start_ls
start_gs
}
lslog() {
if ps w -u $SERVER_USER | grep java | grep l2jlogin.jar > /dev/null; then
tail -n 500 -f $DIR/login/log/stdout.log
else
echo "Login server is not running."
fi
}
gslog() {
if ps w -u $SERVER_USER | grep java | grep l2jserver.jar > /dev/null; then
tail -n 500 -f $DIR/game/log/stdout.log
else
echo "Game server is not running."
fi
}
PS3='Please enter your choice: '
options=("Show Server Status" "Start Login Server" "Start Game Server" "Stop Login Server" "Stop Game Server" "Update Server" "Show Login Server log" "Show Game Server log" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Show Server Status")
status
;;
"Start Login Server")
start_ls
;;
"Start Game Server")
start_gs
;;
"Stop Login Server")
stop_ls
;;
"Stop Game Server")
stop_gs
;;
"Update Server")
update
;;
"Show Login Server log")
lslog
;;
"Show Game Server log")
gslog
;;
"Quit")
break
;;
*) echo invalid option;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment