Skip to content

Instantly share code, notes, and snippets.

@SeriousBuggie
Last active July 6, 2022 19:16
Show Gist options
  • Save SeriousBuggie/5264022a5837ed7179bfa4ee6e91c16a to your computer and use it in GitHub Desktop.
Save SeriousBuggie/5264022a5837ed7179bfa4ee6e91c16a to your computer and use it in GitHub Desktop.
Simple script for run unreal tournament linux server
#!/bin/bash
# Simple script for run unreal tournament linux server
# required cron
# start automatically at server boot.
#
# Installation:
# 1. rename script to some unique name.
# 2. Put it in your UT directory.
# 3. Add it to your crontab, for run every minute.
#
# Possible commands:
# 1. Run without params - start server in current console. Press Ctrl+C few times for interrupt it.
# 2. stop - kill current instance of server and prevent start new for 24 hours.
# 3. start - allow run server. Canceled active stop command.
# 4. status - show current pid of script, which run server, if any.
#
# Configuration:
# Edit UT_SERVER variable located near file end.
#
# Log files stored in System folder of UT server and called as server.log and server_ucc.log.
#
# Script use replacement system on each restart UT server.
# All new files from folder Pending copied in UT folder.
# So if you need update file SuperMutator.u, which currently used by server,
# you need place updated version in Pending/System/ folder and restart server from game.
# via Nexgen Controller for example. Server restarted and new files will be copied before it run.
# Mutators like RebootOnNextMap allow do this unnoticeable for players, and even on server a lot players.
if [ "$1" = "stop" ]; then
touch "$0.stop"
echo "Start blocked."
if [ $(pgrep -c "${0##*/}") -gt 1 ]; then
kill -- -$(pgrep -f -o "${0##*/}")
echo "Server instance killed."
fi
exit
fi
if [ "$1" = "start" ]; then
if [ -f "$0.stop" ]; then
rm "$0.stop"
fi
echo "Start allowed. Server will start soon."
exit
fi
if [ "$1" = "status" ]; then
if [ $(pgrep -c "${0##*/}") -gt 1 ]; then
echo "Server run with pid $(pgrep -o "${0##*/}")"
else
echo "Server not run"
fi
exit
fi
if [ -f "$0.stop" ] && [ `find "$0.stop" -mmin -1440` ]; then
exit
fi
if [ $(pgrep -c "${0##*/}") -gt 1 ]; then
echo "Another instance of the script is running. Aborting."
exit
fi
cd ${0%/*}/System
while true; do
if [ "$UT_SERVER" != "" ]
then
$UT_SERVER >server_ucc.log
cp server.log server_prev.log
cp server_ucc.log server_ucc_prev.log
rsync -au ../Pending/ ..
fi
UT_SERVER="./ucc-bin server CTF-Command?game=BotPack.CTFGame?mutator=MapVoteULv1_2.BDBMapVote?MaxPlayers=32 -multihome=85.214.243.170 port=7277 -nohomedir log=server.log"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment