Author Topic: Linux Dedicated Server Script  (Read 1914 times)

I kept having issues with Greek's script and felt it was overdone a bit, wrote my own and made it a bit lighter.

Automatically sets the server root directory and server number (via $Pref::Server::Port, this should be a unique number) as well, all that really has to be passed as an argument is the gamemode.

Requires xvfb, wine, and screen.

Just drop this into your Blockland server's folder, chmod +x run.sh, and ./run.sh -g [gamemode].

Code: [Select]
#!/bin/sh

NO_SCREEN=false
ATTACH=false
GAMEMODE="Custom"

OPTIND=1
while getopts "ag:hz" opt; do
case "$opt" in
a) ATTACH=true
;;
g) GAMEMODE=$OPTARG
;;
h) echo "Blockland Dedicated Server Script"
echo "version 1 -- August 29th, 2017 15:46 CDT"
echo "TheBlackParrot (BL_ID 18701)"
echo ""
echo "Usage: ./run.sh [options]"
echo ""
echo "Options: -a Automatically attach to the session [default false]"
echo " -g Specify a gamemode [default \"Custom\"]"
echo " -z Don't attach to a seperate session [default false]"
exit 1
;;
z) NO_SCREEN=true
ATTACH=false
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift


SERVER_PATH=$(dirname "$(readlink -f "$0")")
echo "Using $SERVER_PATH as the server directory."
PORT=$(cat "$SERVER_PATH/config/server/prefs.cs" | grep '$Pref::Server::Port' | sed 's/[^0-9]*//g')
echo "Should be running on port $PORT."
SERVER_NAME="BL$PORT"


if [ ! -f "$SERVER_PATH/Blockland.exe" ]; then
echo "Blockland executable is missing!"
exit 1
fi

if [ ! -f "$SERVER_PATH/Add-Ons/Gamemode_$GAMEMODE" ]; then
if [ ! -f "$SERVER_PATH/Add-Ons/GameMode_$GAMEMODE" ]; then
if [ ! -f "$SERVER_PATH/Add-Ons/Gamemode_$GAMEMODE.zip" ]; then
if [ ! -f "$SERVER_PATH/Add-Ons/GameMode_$GAMEMODE.zip" ]; then
echo "Gamemode_$GAMEMODE does not exist in your Add-Ons folder!"
exit 1
fi
fi
fi
fi


if [ $(screen -list | grep -c "$SERVER_NAME") -gt 0 ]; then
echo "Session already running on screen $SERVER_NAME, please shut that down first."
exit 1
fi


if [ $NO_SCREEN = false ]; then
screen -dmS \
"$SERVER_NAME" \
xvfb-run -a \
-n 100 \
-e /dev/stdout \
wine wineconsole \
--backend=curses \
"$SERVER_PATH/Blockland.exe" \
ptlaaxobimwroe \
-dedicated \
-gamemode "$GAMEMODE"
else
xvfb-run -a \
-n 100 \
-e /dev/stdout \
wine wineconsole \
--backend=curses \
"$SERVER_PATH/Blockland.exe" \
ptlaaxobimwroe \
-dedicated \
-gamemode "$GAMEMODE"
fi

if [ $NO_SCREEN = false ]; then
sleep 3

if [ $(screen -list | grep -c "$SERVER_NAME") -gt 0 ]; then
echo "Session started on screen $SERVER_NAME"
if [ "$ATTACH" = true ]; then
screen -x "$SERVER_NAME"
else
screen -list
fi
else
echo "Failed to start server."
exit 1
fi
fi



If you use PM2 for process management, you can use this if you want, instead:
pm2 start wineconsole -n BlocklandServerName --interpreter bash --cwd $(pwd) -- --backend=curses Blockland.exe ptlaaxobimwroe -dedicated -gamemode [gamemode]
all one line
« Last Edit: August 29, 2017, 03:52:19 PM by TheBlackParrot »

who is ptlaaxobimwroe?

who is ptlaaxobimwroe?
It's what blockland use to run the game with Torque3D (i think?)

you're talking to a bot. and no it's the super duper secret segment used to launch blockland without a launcher

you're talking to a bot. and no it's the super duper secret segment used to launch blockland without a launcher
i beg your pardon

you're talking to a bot. and no it's the super duper secret segment used to launch blockland without a launcher
ah, okay, now I know what is that segment. Also this "bot" is really annoying, so useless

ah, okay, now I know what is that segment. Also this "bot" is really annoying, so useless
stop. i am a human



who is ptlaaxobimwroe?
its an parameter that bypasses the blockland launcher