Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Info] Fedora / Redhat / CentOS -- FirewallD and SystemD Service Files for dedicated

#1
Thread Starter / note for later reference,

I noticed at the time of writing, CentOS 8 does not have Xonotic in the EPEL repo yet...
Fedora 32 has it.

packaged versions are missing a FirewallD and SystemD 'service' files.
maybe this can make it's way to mainstream packaging/release..

the following should be sufficient (and would be handy if included in the 'xonotic-dedicated' package in the repo):


FirewallD Service (where):
Code:
/usr/lib/firewalld/services/xonotic-server.xml

Contents:
Code:
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Xonotic Server</short>
<description>Xonotic AFPS Game Server for users on your server to play.</description>
<port protocol="udp" port="26000"/>
</service>


Load it up (persistent after reboots & run it now):
Code:
sudo firewall-cmd --add-service=xonotic-server --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-all



-------------
-------------


SystemD Service (where):
Code:
/usr/lib/systemd/system/xonotic-server.service

Contents:
Code:
####Xonotic Server SystemD service configuration file
[Unit]
Description=Xonotic FPS Game Server
After=network.target

[Service]
Type=simple
ExecStart=xonotic-dedicated -game data/maps -game data
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
##Direct Logs to null if you specify a logfile elsewhere in the config
StandardOutput=null
StandardError=null
SyslogIdentifier=xonotic-server-log
User=dedicatedxonoticuseraccount
Group=dedicatedxonoticusergroup
WorkingDirectory=/usr/share/xonotic/

[Install]
WantedBy=multi-user.target
#Alias=

Might need to reload  systemD and also might need to fix SElinux context for systemd to work with the service (running this as root):
Code:
restorecon -R -v /usr/lib/systemd/system/
systemctl daemon-reload



Load it up (persistent after reboots & run it now):
Code:
sudo systemctl enable --now xonotic-server.service

Check the status:
Code:
sudo systemctl status xonotic-server

Manage:
Code:
sudo systemctl start xonotic-server
sudo systemctl stop xonotic-server
sudo systemctl restart xonotic-server

Turn it off(persistent after reboots):

Code:
sudo systemctl disable xonotic-server.service

With this way, you can load custom maps in ~/.xonotic/data/maps for custom maps to be loaded, and have ~/.xonotic/data/server.cfg in the default locations for the dedicatedxonoticuser you create.
tune to your liking. good starting point to get this pushed into the repos.



Thanks
Reply

#2
You can always wrap 
Code:
xonotic-dedicated -game data/maps

in a script, which will then look at a flag (say the content of a file) to determine whether or not to continue run the command above. And to quit the server, you can just send the quit command to the server via rcon.
Reply

#3
(06-04-2020, 04:44 PM)BuddyFriendGuy Wrote: You can always wrap 
Code:
xonotic-dedicated -game data/maps

in a script, which will then look at a flag (say the content of a file) to determine whether or not to continue run the command above. And to quit the server, you can just send the quit command to the server via rcon.

the systemD seems to handle it okay.. (this is the package manager installed version, so the command is in path)
It was also working fine with static xonotic 0.82 downloaded in /usr/games/Xonotic

i noticed some funky behaviour missing the last -game arg, so i edited the original post back to this line

Code:
ExecStart=xonotic-dedicated -game data/maps -game data
so there is a dedicated 'maps' folder for cleanliness. 

it seems when you rcon quit, the systemD will restart the server automatically for you. there are delay and other parameters which can be set. this suits my purposes well. and now with the original -gamdir its behaving as intended again.
so just issue systemctl stop xonotic-server.service should handle it well. (i'm sure you can set more args to make it not restart the service upon quit, which i don't know off the top of my head)
Reply

#4
I thought by the "softer" approach, you meant controling the service without the root privilege or changing system files. Perhaps I didn't explain it well. The idea is your systemd would call a script like this (pseudo code):

Code:
#!/usb/bin/bash

$FILE_SWITCH="/opt/xonotic/run_switch.txt"
# check the content of a file
if grep -Fxq "up" ${FILE_SWITCH}
then
   # run Xonotic
   /opt/xonotic/repo/xonotic-dedicated -game data/maps -game data
else
   # don't run
   :
fi
That way, you can just control the content of /opt/xonotic/run_switch.txt to decide whether you want the service up or not, without having to run systemctl upon booting.


To prevent systemd from restarting automatically upon quit, change this line in your /usr/lib/systemd/system/xonotic-server.service:

Code:
#Restart=always
Restart=no

Or, you can also use systemd user services.
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Fedora Repo Updateto 8.2 preactive 2 2,671 05-05-2017, 12:32 PM
Last Post: preactive
  missing shader files BuddyFriendGuy 0 2,677 07-05-2015, 07:19 PM
Last Post: BuddyFriendGuy
  Question and Rant on the LG and MG changes. GegoXAREN 5 5,586 11-26-2012, 04:16 PM
Last Post: hutty
Brick Weapons defined in text files / de-harding weapons [feature debate] MirceaKitsune 41 44,398 10-10-2012, 03:59 PM
Last Post: hutty
Question media source files of vehicles? poVoq 13 10,497 02-21-2012, 06:16 PM
Last Post: tZork
  [SOLVED] How does the decompression of files within pk3s work? joshbeck 3 5,202 09-29-2011, 09:28 PM
Last Post: joshbeck
  Missing credit info divVerent 7 9,183 08-23-2011, 10:18 AM
Last Post: Taximus

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-