Skip to content

Commit

Permalink
#122 added native rcon/rconcli binary to enable other feature request…
Browse files Browse the repository at this point in the history
… to be able to work
  • Loading branch information
jammsen committed Jan 29, 2024
1 parent 1545088 commit d6ca794
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ RUN curl -fsSLO "$SUPERCRONIC_URL" \
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic

# Latest releases available at https://github.com/gorcon/rcon-cli/releases
ENV RCON_URL=https://github.com/gorcon/rcon-cli/releases/download/v0.10.3/rcon-0.10.3-amd64_linux.tar.gz \
RCON_TGZ=rcon-0.10.3-amd64_linux.tar.gz \
RCON_TGZ_MD5SUM=8601c70dcab2f90cd842c127f700e398 \
RCON_BINARY=rcon

RUN curl -fsSLO "$RCON_URL" \
&& echo "${RCON_TGZ_MD5SUM} ${RCON_TGZ}" | md5sum -c - \
&& tar xfz rcon-0.10.3-amd64_linux.tar.gz \
&& chmod +x "rcon-0.10.3-amd64_linux/$RCON_BINARY" \
&& mv "rcon-0.10.3-amd64_linux/$RCON_BINARY" "/usr/local/bin/${RCON_BINARY}" \
&& ln -s "/usr/local/bin/${RCON_BINARY}" /usr/local/bin/rconcli \
&& rm -Rf rcon-0.10.3-amd64_linux rcon-0.10.3-amd64_linux.tar.gz

ADD --chown=steam:steam --chmod=755 servermanager.sh /servermanager.sh
ADD --chown=steam:steam --chmod=755 backupmanager.sh /backupmanager.sh

Expand All @@ -33,6 +47,7 @@ VOLUME [ "/palworld" ]

USER steam

ADD --chown=steam:steam --chmod=440 rcon.yaml ./rcon.yaml

ENV DEBIAN_FRONTEND=noninteractive \
PUID=0 \
Expand Down
11 changes: 10 additions & 1 deletion backupmanager.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#!/bin/bash

DATE=$(date +%Y%m%d_%H%M%S)
TIME=$(date +%H-%M-%S)

echo ">>> Creating backup"
echo "> Sending message to gameserver"
cd ~/steamcmd/
rconcli "broadcast $TIME-Backup_in_progress"
sleep 1
rconcli 'broadcast Saving...'
rconcli 'save'
rconcli 'broadcast Done...'
sleep 15
# Create backup dir and change into it
mkdir -p /palworld/backups && cd /palworld/Pal
echo ">>> Creating backup"
tar cfz /palworld/backups/saved-$DATE.tar.gz Saved/
echo ">>> Done"
3 changes: 3 additions & 0 deletions rcon.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
default:
address: "127.0.0.1:###RCON_PORT###"
password: "###ADMIN_PASSWORD###"
8 changes: 8 additions & 0 deletions servermanager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ function setupPalWorldSettingsIni() {
if [[ ! -z ${RCON_ENABLED+x} ]]; then
echo "> Setting rcon-enabled to $RCON_ENABLED"
sed -E -i "s/RCONEnabled=[a-zA-Z]*/RCONEnabled=$RCON_ENABLED/" ${GAME_PATH}/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
echo "> Because rcon is enabled, setting rcon.yml config file"
sed -i "s/###RCON_PORT###/$RCON_PORT/" ~/steamcmd/rcon.yaml
sed -i "s/###ADMIN_PASSWORD###/$ADMIN_PASSWORD/" ~/steamcmd/rcon.yaml
fi
if [[ ! -z ${RCON_PORT+x} ]]; then
echo "> Setting RCONPort to $RCON_PORT"
Expand Down Expand Up @@ -389,6 +392,11 @@ function startMain() {
}

term_handler() {
rconcli 'broadcast Server_Shutdown_requested'
rconcli 'broadcast Saving...'
rconcli 'save'
rconcli 'broadcast Done...'
sleep 3
kill -SIGTERM $(pidof PalServer-Linux-Test)
tail --pid=$(pidof PalServer-Linux-Test) -f 2>/dev/null
exit 143;
Expand Down

0 comments on commit d6ca794

Please sign in to comment.