GameServerManagers / LinuxGSM

The command-line tool for quick, simple deployment and management of Linux dedicated game servers.
https://linuxgsm.com
MIT License
4.28k stars 818 forks source link

[Bug]: (Some) command/scripts don't utilize proper path(s) [running both PZ & SDTD servers. Same on both] #4387

Closed irobot73 closed 7 months ago

irobot73 commented 11 months ago

User story

As a server admin I want the included scripts to utilize the proper paths to execute properly & successfully

Game

SDTDServer

Linux distro

Ubuntu 22.04

Command

command: update, command: backup

Further information

Part of #4384 ??

(Some) Scripts/commands, when executed via console, would successfully execute & complete (though incomplete [backup])

Appears they are pointing to the /app folder & ignoring the /data

In the cron jobs screenshot, you can see I manually exec. one of the same scripts & it was successful in the log (last entry) while the same script via cron failed (top of log file)

Cron jobs & manual execution attempts: Cron jobs

Cron output: crontab.log

Server setup: Setup

Duped log files. Script creates new LOG paths, these exist under /DATA already (NOTE the symlink path): Duped

Relevant log output

copying _default.cfg...OK
fetching GitHub common.cfg...OK
fetching GitHub secrets-common.cfg...OK
fetching GitHub pzserver.cfg...OK
fetching GitHub secrets-pzserver.cfg...OK

[ .... ] Updating pzserver: 
[ FAIL ] Updating pzserver: Cannot access /app/serverfiles: No such directory

[ .... ] Updating pzserver: 
[ .... ] Backing up pzserver: 
[ FAIL ] Updating pzserver: Cannot access /app/serverfiles: No such directory
[ FAIL ] Backing up pzserver: Cannot access /app/serverfiles: No such directory

[ .... ] Updating LinuxGSM pzserver: 
[ .... ] Updating pzserver: 
[ .... ] Updating LinuxGSM pzserver: Checking for log files
[ FAIL ] Updating pzserver: Cannot access /app/serverfiles: No such directory

[ INFO ] Updating LinuxGSM pzserver: Checking for log files: Creating log files
installing log dir: /app/log...OK
installing LinuxGSM log dir: /app/log/script...OK
creating LinuxGSM log: /app/log/script/pzserver-script.log...OK
installing console log dir: /app/log/console...OK
creating console log: /app/log/console/pzserver-console.log...OK
creating symlink to game log dir: /app/log/server -> /data/Zomboid/Logs...OK
creating symlink to steam log dir: /app/log/steam -> /data/.steam/steam/logs...OK

[ .... ] Updating LinuxGSM pzserver: Selecting repo
[  OK  ] Updating LinuxGSM pzserver: Selecting repo: GitHub
checking GitHub linuxgsm.sh...OK
checking pzserver...OK
checking GitHub config _default.cfg...OK
checking GitHub config ubuntu-22.04.csv...OK
checking GitHub module README.md...OK
...
checking GitHub module update_ts3.sh...OK
checking GitHub module update_ut99.sh...OK
checking GitHub module update_vints.sh...OK

[  OK  ] Updating LinuxGSM pzserver: Updating modules

[ .... ] Updating pzserver: 
[ .... ] Backing up pzserver: 
[ FAIL ] Updating pzserver: Cannot access /app/serverfiles: No such directory
[ FAIL ] Backing up pzserver: Cannot access /app/serverfiles: No such directory

[ .... ] Updating pzserver: 
[ FAIL ] Updating pzserver: Cannot access /app/serverfiles: No such directory

[ .... ] Updating pzserver: 
[ .... ] Updating LinuxGSM pzserver: 
[ .... ] Backing up pzserver: 
[ FAIL ] Updating pzserver: Cannot access /app/serverfiles: No such directory
[ FAIL ] Backing up pzserver: Cannot access /app/serverfiles: No such directory

[ .... ] Updating LinuxGSM pzserver: Selecting repo

[  OK  ] Updating LinuxGSM pzserver: Selecting repo: GitHub
checking GitHub linuxgsm.sh...OK
checking pzserver...OK
checking GitHub config _default.cfg...OK
checking GitHub config ubuntu-22.04.csv...OK
checking GitHub module README.md...OK
checking GitHub module alert.sh...OK
...
checking GitHub module update_ts3.sh...OK
checking GitHub module update_ut99.sh...OK
checking GitHub module update_vints.sh...OK

[  OK  ] Updating LinuxGSM pzserver: Updating modules
bash: pzserver: command not found

[ .... ] Updating pzserver: 
[ .... ] Updating pzserver: SteamCMD
[ .... ] Updating pzserver: Checking local build: SteamCMD
[  OK  ] Updating pzserver: Checking local build: SteamCMD
[ .... ] Updating pzserver: Checking remote build: SteamCMD
[  OK  ] Updating pzserver: Checking remote build: SteamCMD
[ .... ] Updating pzserver: Checking for update: SteamCMD
[  OK  ] Updating pzserver: Checking for update: SteamCMD

No update available
* Local build: 10105838
* Remote build: 10105838
* Branch: public
https://steamdb.info/app/380870/

Steps to reproduce

  1. Setup/install server
  2. Add cron job to LinuxGSM user
  3. Note failure
dgibbs64 commented 10 months ago

This is an issue with the docker container. Backup does need some changes made to work better with the container. however in general I recommend using 3rd party tools for regular backups like rsync as they are more efficient than the LinuxGSM just compress it solution šŸ˜„

irobot73 commented 10 months ago

This is an issue with the docker container. Backup does need some changes made to work better with the container. however in general I recommend using 3rd party tools for regular backups like rsync as they are more efficient than the LinuxGSM just compress it solution šŸ˜„

I understand the BACKUP script needs some tweaking, but the script execution (esp. via CRON) believes the SERVERFILES exist in the '/app' folder & NOT the '/data'.

Compose YML: compose.txt

Server install & running: Install

My CRON changes (using Portainer): CRON

The CRON log: crontab.log

/data/serverfiles (proper) vs. CRON /app/serverfiles :

[  OK  ] Updating LinuxGSM pzserver: Updating modules

[ .... ] Backing up pzserver: 
[ FAIL ] Backing up pzserver: Cannot access /app/serverfiles: No such directory

[ .... ] Backing up pzserver: 
[ FAIL ] Backing up pzserver: Cannot access /app/serverfiles: No such directory

[ .... ] Stopping pzserver: 
[ FAIL ] Stopping pzserver: Cannot access /app/serverfiles: No such directory

[ FAIL ] Stopping pzserver: Cannot access /app/serverfiles: No such directory

[ .... ] Backing up pzserver: 
[ FAIL ] Backing up pzserver: Cannot access /app/serverfiles: No such directory

[ .... ] Backing up pzserver: 
[ FAIL ] Backing up pzserver: Cannot access /app/serverfiles: No such directory
irobot73 commented 10 months ago

I created another instance & set the SERVERFILES ENV variable

services:
  lgsm-test:
    image: gameservermanagers/gameserver:pz # https://github.com/GameServerManagers/docker-gameserver
    container_name: lgsm-test
    environment:
      - LGSM_SERVERFILES=/data/serverfiles
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro

      - ./:/data
    ports:
      - 16264-16265:16261-16262/udp
      - 27017:27015
    restart: unless-stopped

Brought up the container & initial logs sees/creates

Screenshot from 2023-12-08 15-53-45

Setup the CRON w/ logging:

linuxgsm@a1d50ab924ee:/app$ whoami
linuxgsm
linuxgsm@a1d50ab924ee:/app$ crontab -l
# */60 * * * * /app/pzserver update > /dev/null 2>&1
*/15 * * * * /app/*server update-lgsm >> /data/log/crontab.log 2>&1 # EVERY SUN @ 1:30
*/10 * * * * /app/*server restart >> /data/log/crontab.log 2>&1     # EVERY Tu/Th/Sa @ 3:30
*/5 * * * * /app/*server backup >> /data/log/crontab.log 2>&1       # EVERY DAY @ 4:00
linuxgsm@a1d50ab924ee:/app$ 

& note the log. Scripts don't recognize variable:

[ .... ] Backing up pzserver: 
[ FAIL ] Backing up pzserver: Cannot access /app/serverfiles: No such directory

[ .... ] Backing up pzserver: 
[ .... ] Stopping pzserver: 
[ FAIL ] Backing up pzserver: Cannot access /app/serverfiles: No such directory
[ FAIL ] Stopping pzserver: Cannot access /app/serverfiles: No such directory

[ FAIL ] Stopping pzserver: Cannot access /app/serverfiles: No such directory

[ .... ] Backing up pzserver: 
[ .... ] Updating LinuxGSM pzserver: 
[ FAIL ] Backing up pzserver: Cannot access /app/serverfiles: No such directory
[ .... ] Updating LinuxGSM pzserver: Checking for log files

[ INFO ] Updating LinuxGSM pzserver: Checking for log files: Creating log files
installing log dir: /app/log...OK
installing LinuxGSM log dir: /app/log/script...OK
creating LinuxGSM log: /app/log/script/pzserver-script.log...OK
installing console log dir: /app/log/console...OK
creating console log: /app/log/console/pzserver-console.log...OK
creating symlink to game log dir: /app/log/server -> /data/Zomboid/Logs...OK
creating symlink to steam log dir: /app/log/steam -> /data/.steam/steam/logs...OK

[ .... ] Updating LinuxGSM pzserver: Selecting repo
[  OK  ] Updating LinuxGSM pzserver: Selecting repo: GitHub

crontab.log

irobot73 commented 10 months ago

I ended up rolling my own, for now. Again, I did redirect, via CONFIG-LGSM, the BACKUP location so it too existed in the /DATA folder.

## Backup Directory
backupdir="${HOME}/backup"

Could have changed the LSGM COMMAND_BACKUP script but every 'update-lgsm' would wipe it out & need to be redone. But you'd get the auto-rolling, purge & notifications (shrug)

tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "${excludedir}"... to tar -czf "${backupdir}/${backupname}.tar.gz" -C / -T /data/bkup_include.txt

Cut down the (expected via LGSM) 15GB backup, as it was grabbing /SERVERFILES+, to ~420MB by removing the 'bloat' (no TMP, LOGs & SteamCMD files+)

Create & add the file/folder(s) I needed to '/data/bkup_include.txt'.

/app/lgsm/config-default/
/app/lgsm/config-lgsm/
/app/lgsm/data/
/app/lgsm/modules/

/app/entrypoint.sh
/app/entrypoint-healthcheck.sh
/app/entrypoint-user.sh
/app/linuxgsm.sh
/app/sdtdserver

/data/config-lgsm/
/data/serverfiles/sdtdserver.xml
/data/userData/

/data/bkup_exclude.txt
/data/bkup_include.txt

Reference the same file via new script that I could add to CRONTAB (chmod +x!!) [my_backup.sh]:

#!/bin/sh

FILENAME=lgsm_$(date -d "today" +"%A").tar.gz
BACKUP="/data/backup/${FILENAME}"

# echo ${BACKUP}

tar -czf "${BACKUP}" -C / -T /data/bkup_include.txt

exitcode=$?

echo "Completed: '${BACKUP}', Exit Code: ${exitcode}, Size $(du -sh "${BACKUP}" | awk '{print $1}')"

Crontab:

#*/60 * * * * /app/sdtdserver update > /dev/null 2>&1
#
30 0 * * 0 cat /dev/null > /data/log/crontab.log                 # EVERY SUN @ 00:30
0 1 * * 0 /app/*server update-lgsm >> /data/log/crontab.log 2>&1 # EVERY SUN @ 1:00
0 3 * * 1,3,5 /app/*server restart >> /data/log/crontab.log 2>&1  # EVERY M,W,F @ 3:00
0 4 * * * /data/my_backup.sh >> /data/log/crontab.log 2>&1  # EVERY DAY @ 4:00

7 day rolling backup w/ any other logic/work:

Crontab.log

/data/backup/lgsm_Friday.tar.gz
tar: Removing leading `/' from member names
tar: Removing leading `/' from hard link targets
Completed: '/data/backup/lgsm_Friday.tar.gz', Exit Code: 0, Size 401M

Screenshot from 2023-12-22 21-11-18 Screenshot from 2023-12-22 21-15-21

vs. Docker container where /DATA is mapped (IE: Only getting what I need)

    volumes:...
      - ./:/data
      - ./userData:/data/userData # Utilized in the game's SERVER.XML.CFG file

Screenshot from 2023-12-22 21-29-22

dgibbs64 commented 7 months ago

I have since added a symlink from /app/serverfiles to /data/serverfiles this should help resolve these issues. But I think more work may be required