RCON Utility
Reference:
My Steam Guide: RCON Command-Line Utility
The game instances will be running as a service and thus, the console will not be directly available. This is where RCON comes in handy. Avorion has built-in support for RCON clients sending console commands such as /save, /stop, /status, /players, /version, etc.
Avorion does not ship with an RCON client and neither does Ubuntu.
You can get source code written in C by
[ASY]Zyrain that you can compile for use with your server. However, I did not like the fact that his version required the password to be passed as a command-line parameter which exposes it to anyone that is watching the process list. So I modified it to pull the password from a configuration file and a few other minor tweaks documented in the change log. Both versions are on my github so you can easily see what was changed if interested.
All the scripts that interact with the service will be using this RCON utility.
Here are the steps to download and compile my variation of the RCON utility.
Code: Select all
sudo apt install gcc
mkdir --parents /var/script/prod
wget https://raw.githubusercontent.com/LHammonds/rcon/main/rcon.c --output-document /var/scripts/prod/rcon.c
sudo gcc -o /var/scripts/prod/rcon /var/scripts/prod/rcon.c
sudo chown avserver:avserver /var/scripts/prod/rcon
sudo chmod 0750 /var/scripts/prod/rcon
sudo apt remove gcc
(I know, super difficult wasn't it!)
Might as well grab the manual for RCON and copy it where you can reference it anywhere:
Code: Select all
wget https://raw.githubusercontent.com/LHammonds/rcon/main/rcon.man --output-document /var/scripts/prod/rcon.man
sudo mkdir -p /usr/local/share/man/man1
sudo cp /var/scripts/prod/rcon.man /usr/local/share/man/man1/rcon.1
sudo chown root:root /usr/local/share/man/man1/rcon.1
sudo chmod 0644 /usr/local/share/man/man1/rcon.1
Now you can pull up the help page anytime you want:
The scripts that I created look for an rcon config file with a prefix of "rcon-" and then the galaxy name and then a suffix of ".ini"
You can use whatever you want but my scripts expect the use of one rcon config file per galaxy so the name is included in the filename but all the instance details are stored in the file such as password, IP and port number.
Create an RCON configuration file for use with galaxy1.
Code: Select all
sudo touch /etc/rcon-galaxy1.ini
sudo chown avserver:avserver /etc/rcon-galaxy1.ini
sudo chmod 0640 /etc/rcon-galaxy1.ini
cat << EOF > /etc/rcon-galaxy1.ini
[rcon]
password=YOUR_RCON_PASSWORD
ipaddress=127.0.0.1
port=27201
EOF
Create an RCON configuration file for use with galaxy2:
Code: Select all
sudo touch /etc/rcon-galaxy2.ini
sudo chown avserver:avserver /etc/rcon-galaxy2.ini
sudo chmod 0640 /etc/rcon-galaxy2.ini
cat << EOF > /etc/rcon-galaxy2.ini
[rcon]
password=YOUR_RCON_PASSWORD
ipaddress=127.0.0.1
port=27202
EOF
Be sure to edit the RCON config files and match the password to what you will / have set for "rconPassword" in your server.ini file(s).
Usage Examples
Run a Save command using a generic config file for a common password but specify a different IP/port:
Code: Select all
rcon -f "/etc/rcon-all.ini" -a 127.0.0.1 -p 27110 "/save"
Run a Stop command using a pre-defined password, IP address and port in a specific instance config file:
Code: Select all
rcon -f "/etc/rcon-galaxy1.ini" "/stop"
Run a Status command using a pre-defined password, IP address and port in a specific instance config file:
Code: Select all
rcon -f "/etc/rcon-galaxy2.ini" "/status"
Run a Players command using a pre-defined password, IP address and port in a specific instance config file:
Code: Select all
rcon -f "/etc/rcon-galaxy3.ini" "/players"