
Dear CentOS users, this guide will explain what to do, to make WarGame: Red Dragon Dedicated Server run on CentOS 6 (x86) (*), will help to create easy-to-use control script for it, will help add WarGame: Red Dragon Dedicated Server as service to easily manage it. In addition this tutorial will help to setup right rules for IPtables, to avoid any connectivity problems between dedicated server and clients and still leave your server protected. So let us start.
(*) Edit by Shifu: Doesn't work for Centos 7
1) Installing all required utilities:
Code: Select all
yum install wget p7zip nano
2) Getting libraries in place:
Code: Select all
cd /
mkdir libhelp
cd libhelp
wget http://soon-tm.info/t_stuff/libhelp.7z
7za x libhelp.7z
rm -f libhelp.7z
chmod 755 lib*
3) Preparing dedicated server:
Code: Select all
useradd wargame
cd /opt
wget --no-check-certificate https://link_to_ip_from_eugen/wargame3_server.tar.bz2
tar -xvjf wargame3_server.tar.bz2
rm -f wargame3_server.tar.bz2
cd wargame3_server
ln -sf /libhelp/libssl.so.1.0.0 libssl.so.1.0.0
ln -sf /libhelp/libcrypto.so.1.0.0 libcrypto.so.1.0.0
ln -sf /libhelp/libstdc++.so.6 libstdc++.so.6
touch wargame3-launcher.sh
chmod 755 wargame3-launcher.sh
nano wargame3-launcher.sh
Code: Select all
#!/bin/sh
# No Copyrights (c) 2014 WarStalkeR
# No Right Reserved, do with it what you want :D
cd "$(dirname "$0")"
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:./ ./wargame3-server +port XXXX +port_mms 10804 +rcon_port ZZZZ +rcon_password PPPPPPPP +ip YY.YY.YY.YY
Code: Select all
cd ..
chown wargame:wargame -R wargame3_server
4) Adding dedicated server as service:
Code: Select all
cd /opt/wargame3_server/
touch wargame3-controlscript.sh
chown wargame:wargame wargame3-controlscript.sh
chmod 755 wargame3-controlscript.sh
nano wargame3-controlscript.sh
Code: Select all
#!/bin/sh
# No Copyrights (c) 2014 WarStalkeR
# No Right Reserved, do with it what you want :D
# Allows only one instance of WarGame Server per machine!
COMMANDLINE_PARAMETERS=""
BINARYNAME="wargame3-server"
BINARYEXEC="wargame3-launcher.sh"
BINARYPATH="$(dirname "${D1}")"
cd "${BINARYPATH}"
case "$1" in
start)
if ( kill -0 $(pidof wargame3-server) 2> /dev/null ); then
echo "WarGame Server is already running, try restart or stop."
exit 1
elif [ -e wargame3-server.pid ]; then
echo "wargame3-server.pid found, but no server running. Possibly your previously started WarGame Server has crashed."
echo "Please view the logfile for details."
rm wargame3-server.pid
fi
if [ "${UID}" = "0" ]; then
echo WARNING! FOR SECURITY REASONS DO NOT RUN THE WarGame Server AS ROOT!
c=1
while [ "$c" -le 10 ]; do
echo -n "!"
sleep 1
c=$(($c+1))
done
echo "!"
fi
echo "Starting the WarGame Server."
if [ -e "$BINARYNAME" ]; then
if [ ! -x "$BINARYNAME" ]; then
echo "${BINARYNAME} is not executable, trying to set it!"
chmod 755 "${BINARYNAME}"
fi
if [ -x "$BINARYNAME" ]; then
"./${BINARYEXEC}" > /dev/null &
echo $! > wargame3-server.pid
echo "WarGame Server has started!"
else
echo "${BINARNAME} is not exectuable, cannot start WarGame Server!"
fi
else
echo "WARNING! Could not find binary! Aborting."
exit 5
fi
;;
stop)
if ( kill -0 $(pidof wargame3-server) 2> /dev/null ); then
echo -n "Stopping the WarGame Server. "
if ( kill -SIGINT $(pidof wargame3-server) 2> /dev/null ); then
c=1
while [ "$c" -le 300 ]; do
if ( kill -0 $(pidof wargame3-server) 2> /dev/null ); then
echo -n "."
sleep 1
else
break
fi
c=$((++c))
done
fi
if ( kill -TERM $(pidof wargame3-server) 2> /dev/null ); then
c=1
while [ "$c" -le 300 ]; do
if ( kill -0 $(pidof wargame3-server) 2> /dev/null ); then
echo -n "."
sleep 1
else
break
fi
c=$((++c))
done
fi
if ( kill -0 $(pidof wargame3-server) 2> /dev/null ); then
echo "WarGame Server is not shutting down correctly! Terminating!"
kill -KILL $(pidof wargame3-server)
fi
sleep 3
if [ -e wargame3-server.pid ]; then
rm wargame3-server.pid
fi
echo "Done."
else
echo "WarGame Server is not running."
exit 7
fi
;;
restart)
if ( kill -0 $(pidof wargame3-server) 2> /dev/null ); then
echo -n "Stopping the WarGame Server. "
if ( kill -SIGINT $(pidof wargame3-server) 2> /dev/null ); then
c=1
while [ "$c" -le 300 ]; do
if ( kill -0 $(pidof wargame3-server) 2> /dev/null ); then
echo -n "."
sleep 1
else
break
fi
c=$((++c))
done
fi
if ( kill -TERM $(pidof wargame3-server) 2> /dev/null ); then
c=1
while [ "$c" -le 300 ]; do
if ( kill -0 $(pidof wargame3-server) 2> /dev/null ); then
echo -n "."
sleep 1
else
break
fi
c=$((++c))
done
fi
if ( kill -0 $(pidof wargame3-server) 2> /dev/null ); then
echo "WarGame Server is not shutting down correctly! Terminating!"
kill -KILL $(pidof wargame3-server)
fi
sleep 3
if [ -e wargame3-server.pid ]; then
rm wargame3-server.pid
fi
echo "Done."
else
echo "WarGame Server is not running."
fi
if ( kill -0 $(pidof wargame3-server) 2> /dev/null ); then
echo "WarGame Server is already running, try restart or stop."
exit 1
elif [ -e wargame3-server.pid ]; then
echo "wargame3-server.pid found, but no server running. Possibly your previously started WarGame Server has crashed."
echo "Please view the logfile for details."
rm wargame3-server.pid
fi
if [ "${UID}" = "0" ]; then
echo WARNING! FOR SECURITY REASONS DO NOT RUN THE WarGame Server AS ROOT!
c=1
while [ "$c" -le 10 ]; do
echo -n "!"
sleep 1
c=$(($c+1))
done
echo "!"
fi
echo "Starting the WarGame Server."
if [ -e "$BINARYNAME" ]; then
if [ ! -x "$BINARYNAME" ]; then
echo "${BINARYNAME} is not executable, trying to set it!"
chmod 755 "${BINARYNAME}"
fi
if [ -x "$BINARYNAME" ]; then
"./${BINARYEXEC}" > /dev/null &
echo $! > wargame3-server.pid
echo "WarGame Server has started!"
else
echo "${BINARNAME} is not exectuable, cannot start WarGame Server!"
fi
else
echo "WARNING! Could not find binary! Aborting."
exit 5
fi
;;
status)
if ( kill -0 $(pidof wargame3-server) 2> /dev/null ); then
echo "WarGame Server is running."
elif [ -e wargame3-server.pid ]; then
echo "WarGame Server seems to be dead."
else
echo "WarGame Server is not running."
fi
;;
*)
echo "Usage: ${0} {start|stop|restart|status}"
exit 2
esac
exit 0
Code: Select all
touch /etc/rc.d/init.d/wargame3
chmod 755 /etc/rc.d/init.d/wargame3
nano /etc/rc.d/init.d/wargame3
Code: Select all
#!/bin/sh
# chkconfig: 2345 98 8
# description: Start/Stop/Restart/Status the WarGame Server
# install: chkconfig --add wargame3
# uninstall: chkconfig --del wargame3
# author: WarStalkeR
su=/bin/su
user=wargame #user you want to use for Starbound Server
dir=/opt/wargame3_server/ #folder where you installed Starbound
exec=./wargame3-controlscript.sh #name of the control script
case "$1" in
start)
$su - $user -c "cd $dir;$exec start"
;;
stop)
$su - $user -c "cd $dir;$exec stop"
;;
restart)
$su - $user -c "cd $dir;$exec restart"
;;
status)
$su - $user -c "cd $dir;$exec status"
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 2
esac
exit 0
Code: Select all
chkconfig --add wargame3
Code: Select all
service wargame3 start
service wargame3 stop - will stop the dedicated server software.
service wargame3 restart - will restart the dedicated server software.
service wargame3 status - will show status whether dedicated server software running, stopped or crashed.
5) Adding WarGame: Red Dragon Dedicated Server compatible rules to IPtables:
Code: Select all
iptables -A INPUT -p tcp --sport 513:65535 --dport XXXX -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport XXXX --dport 513:65535 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 44000:45000 --dport 10804 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --sport 10804 --dport 44000:45000 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 513:65535 --dport 10280:10820 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --sport 10280:10820 --dport 513:65535 -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -p tcp --sport 513:65535 --dport ZZZZ -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport ZZZZ --dport 513:65535 -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp --dport XXXX -j ACCEPT
iptables -A OUTPUT -p udp --sport XXXX -j ACCEPT
6) Enjoy!
P.S. Maybe later I will add feature in to service script that will allow to work with multiple dedicated service configuration files to start all kinds of different game types instantly.