Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
irobot73 opened this issue Nov 23, 2023 · 5 comments

Comments

@irobot73
Copy link

irobot73 commented Nov 23, 2023

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

�[K[ .... ] Updating pzserver: 
�[K[�[31m FAIL �[0m] Updating pzserver: Cannot access /app/serverfiles: No such directory

�[K[ .... ] Updating pzserver: 
�[K[ .... ] Backing up pzserver: 
�[K[�[31m FAIL �[0m] Updating pzserver: Cannot access /app/serverfiles: No such directory
�[K[�[31m FAIL �[0m] Backing up pzserver: Cannot access /app/serverfiles: No such directory


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

�[K[�[36m INFO �[0m] Updating LinuxGSM pzserver: Checking for log files: Creating log files
installing log dir: /app/log...�[32mOK�[0m
installing LinuxGSM log dir: /app/log/script...�[32mOK�[0m
creating LinuxGSM log: /app/log/script/pzserver-script.log...�[32mOK�[0m
installing console log dir: /app/log/console...�[32mOK�[0m
creating console log: /app/log/console/pzserver-console.log...�[32mOK�[0m
creating symlink to game log dir: /app/log/server -> /data/Zomboid/Logs...�[32mOK�[0m
creating symlink to steam log dir: /app/log/steam -> /data/.steam/steam/logs...�[32mOK�[0m

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

�[K[�[32m  OK  �[0m] Updating LinuxGSM pzserver: Updating modules

�[K[ .... ] Updating pzserver: 
�[K[ .... ] Backing up pzserver: 
�[K[�[31m FAIL �[0m] Updating pzserver: Cannot access /app/serverfiles: No such directory
�[K[�[31m FAIL �[0m] Backing up pzserver: Cannot access /app/serverfiles: No such directory


�[K[ .... ] Updating pzserver: 
�[K[�[31m FAIL �[0m] Updating pzserver: Cannot access /app/serverfiles: No such directory

�[K[ .... ] Updating pzserver: 
�[K[ .... ] Updating LinuxGSM pzserver: 
�[K[ .... ] Backing up pzserver: 
�[K[�[31m FAIL �[0m] Updating pzserver: Cannot access /app/serverfiles: No such directory
�[K[�[31m FAIL �[0m] Backing up pzserver: Cannot access /app/serverfiles: No such directory

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

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

�[K[�[32m  OK  �[0m] Updating LinuxGSM pzserver: Updating modules
bash: pzserver: command not found

�[K[ .... ] Updating pzserver: 
�[K[ .... ] Updating pzserver: SteamCMD
�[K[ .... ] Updating pzserver: Checking local build: SteamCMD
�[K[�[32m  OK  �[0m] Updating pzserver: Checking local build: SteamCMD
�[K[ .... ] Updating pzserver: Checking remote build: SteamCMD
�[K[�[32m  OK  �[0m] Updating pzserver: Checking remote build: SteamCMD
�[K[ .... ] Updating pzserver: Checking for update: SteamCMD
�[K[�[32m  OK  �[0m] Updating pzserver: Checking for update: SteamCMD

No update available
* Local build: �[32m10105838�[0m
* Remote build: �[32m10105838�[0m
* 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
Copy link
Member

dgibbs64 commented Dec 4, 2023

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
Copy link
Author

irobot73 commented Dec 6, 2023

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 :

�[K[�[32m  OK  �[0m] Updating LinuxGSM pzserver: Updating modules

�[K[ .... ] Backing up pzserver: 
�[K[�[31m FAIL �[0m] Backing up pzserver: Cannot access /app/serverfiles: No such directory

�[K[ .... ] Backing up pzserver: 
�[K[�[31m FAIL �[0m] Backing up pzserver: Cannot access /app/serverfiles: No such directory

�[K[ .... ] Stopping pzserver: 
�[K[�[31m FAIL �[0m] Stopping pzserver: Cannot access /app/serverfiles: No such directory

�[K[�[31m FAIL �[0m] Stopping pzserver: Cannot access /app/serverfiles: No such directory

�[K[ .... ] Backing up pzserver: 
�[K[�[31m FAIL �[0m] Backing up pzserver: Cannot access /app/serverfiles: No such directory

�[K[ .... ] Backing up pzserver: 
�[K[�[31m FAIL �[0m] Backing up pzserver: Cannot access /app/serverfiles: No such directory

@irobot73
Copy link
Author

irobot73 commented Dec 8, 2023

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:

�[K[ .... ] Backing up pzserver: 
�[K[�[31m FAIL �[0m] Backing up pzserver: Cannot access /app/serverfiles: No such directory

�[K[ .... ] Backing up pzserver: 
�[K[ .... ] Stopping pzserver: 
�[K[�[31m FAIL �[0m] Backing up pzserver: Cannot access /app/serverfiles: No such directory
�[K[�[31m FAIL �[0m] Stopping pzserver: Cannot access /app/serverfiles: No such directory


�[K[�[31m FAIL �[0m] Stopping pzserver: Cannot access /app/serverfiles: No such directory

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

�[K[�[36m INFO �[0m] Updating LinuxGSM pzserver: Checking for log files: Creating log files
installing log dir: /app/log...�[32mOK�[0m
installing LinuxGSM log dir: /app/log/script...�[32mOK�[0m
creating LinuxGSM log: /app/log/script/pzserver-script.log...�[32mOK�[0m
installing console log dir: /app/log/console...�[32mOK�[0m
creating console log: /app/log/console/pzserver-console.log...�[32mOK�[0m
creating symlink to game log dir: /app/log/server -> /data/Zomboid/Logs...�[32mOK�[0m
creating symlink to steam log dir: /app/log/steam -> /data/.steam/steam/logs...�[32mOK�[0m

�[K[ .... ] Updating LinuxGSM pzserver: Selecting repo
�[K[�[32m  OK  �[0m] Updating LinuxGSM pzserver: Selecting repo: GitHub

crontab.log

@irobot73
Copy link
Author

irobot73 commented Dec 23, 2023

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'.

  • Guess I don't REALLY need the /APP folder, but it's small enough
  • This is specific for my '7 Days to Die' server (I only need the 'SAVES' & config file(s)):
/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
Copy link
Member

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

@github-project-automation github-project-automation bot moved this from 🆕 New Issues to ✅ Done in LinuxGSM Backlog Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment