From 285982efd5e5da22d066dece656bc516839d46a4 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt <2270806+jammsen@users.noreply.github.com> Date: Sun, 11 Feb 2024 11:15:03 +0100 Subject: [PATCH] refactored Dockerfile, managers, wrapper and scripts --- Dockerfile | 3 +-- includes/cron.sh | 2 +- includes/install.sh | 2 +- scripts/backup.sh | 9 --------- scripts/backupmanager.sh | 24 ++++++++++++------------ scripts/rconcli.sh | 7 ++++--- 6 files changed, 19 insertions(+), 28 deletions(-) delete mode 100644 scripts/backup.sh diff --git a/Dockerfile b/Dockerfile index 08849ed..cb29d40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -126,8 +126,7 @@ COPY --chown=steam:steam --chmod=755 includes/ /includes COPY --chown=steam:steam --chmod=755 configs/rcon.yaml /home/steam/steamcmd/rcon.yaml COPY --chown=steam:steam --chmod=755 entrypoint.sh / -RUN ln -s /scripts/backupmanager.sh /usr/local/bin/backupmanager \ - && ln -s /scripts/backup.sh /usr/local/bin/backup \ +RUN ln -s /scripts/backupmanager.sh /usr/local/bin/backup \ && ln -s /scripts/rconcli.sh /usr/local/bin/rconcli # Install minimum required packages for dedicated server diff --git a/includes/cron.sh b/includes/cron.sh index 3abc649..cbe9349 100644 --- a/includes/cron.sh +++ b/includes/cron.sh @@ -4,7 +4,7 @@ function setup_crons() { echo "" > cronlist if [[ -n ${BACKUP_ENABLED} ]] && [[ ${BACKUP_ENABLED} == "true" ]]; then - echo "${BACKUP_CRON_EXPRESSION} backupmanager --create" >> cronlist + echo "${BACKUP_CRON_EXPRESSION} backup create" >> cronlist fi /usr/local/bin/supercronic -passthrough-logs cronlist & ei ">>> Supercronic started" diff --git a/includes/install.sh b/includes/install.sh index 7a42c56..e4baee8 100644 --- a/includes/install.sh +++ b/includes/install.sh @@ -13,7 +13,7 @@ function fresh_install_server() { function update_server() { if [[ -n $STEAMCMD_VALIDATE_FILES ]] && [[ $STEAMCMD_VALIDATE_FILES == "true" ]]; then - ei ">>> Doing an update and validate of the gameserver files..." + ei ">>> Doing an update with validation of the gameserver files..." if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then send_update_and_validate_notification fi diff --git a/scripts/backup.sh b/scripts/backup.sh deleted file mode 100644 index 4087347..0000000 --- a/scripts/backup.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# Wrapper for backup manager -# Add '--' to the beginning of the first argument -arg1="--${1}" - -# Remove the first argument from the list of arguments -shift - -backupmanager "${arg1}" "$@" diff --git a/scripts/backupmanager.sh b/scripts/backupmanager.sh index 2988018..329f5b3 100644 --- a/scripts/backupmanager.sh +++ b/scripts/backupmanager.sh @@ -14,19 +14,19 @@ LOCAL_BACKUP_RETENTION_AMOUNT_TO_KEEP=${BACKUP_RETENTION_AMOUNT_TO_KEEP} # Numbe function print_usage() { script_name=$(basename "$0") echo "Usage:" - echo " ${script_name} --create" - echo " ${script_name} --list [number_of_entries]" - echo " ${script_name} --clean [number_to_keep]" - echo " ${script_name} --help" + echo " ${script_name} create" + echo " ${script_name} list [number_of_entries]" + echo " ${script_name} clean [number_to_keep]" + echo " ${script_name} help" echo "" echo "Options:" - echo " --create Create a backup" - echo " --list [number_to_list] List the backup files. If number_to_list isn't" + echo " create Create a backup" + echo " list [number_to_list] List the backup files. If number_to_list isn't" echo " provided, all backup files will be listed" - echo " --clean [number_to_keep] Deletes old backups keeping the number_to_keep" + echo " clean [number_to_keep] Deletes old backups keeping the number_to_keep" echo " most recent backups. If number_to_keep isn't" echo " provided, keep 30 most recent backups" - echo " --help Display this help message" + echo " help Display this help message" echo "" echo "Arguments:" echo " number_to_list (optional) The number of backup files to list." @@ -46,7 +46,7 @@ function parse_arguments() { # Evaluate the command case "$1" in - --create) + create) if [ ${#} -ne 1 ]; then ee ">>> Invalid number of arguments for 'create'" print_usage @@ -54,7 +54,7 @@ function parse_arguments() { fi create_backup ;; - --list) + list) if [ ${#} -gt 2 ]; then ee ">>> Invalid number of arguments for 'list'" print_usage @@ -70,7 +70,7 @@ function parse_arguments() { list_backups "${number_to_list}" ;; - --clean) + clean) if [ ${#} -gt 2 ]; then ee ">>> Invalid number of arguments for 'clean'" print_usage @@ -86,7 +86,7 @@ function parse_arguments() { clean_backups "${num_backup_entries}" ;; - --help) + help) if [ ${#} -ne 1 ]; then ee ">>> Invalid number of arguments for 'help'" print_usage diff --git a/scripts/rconcli.sh b/scripts/rconcli.sh index 73eb462..56a9271 100644 --- a/scripts/rconcli.sh +++ b/scripts/rconcli.sh @@ -13,9 +13,10 @@ run_rcon_cli() { ee ">>> RCON is not enabled. Aborting RCON command ..." exit fi - ei "${message}" - output=$(rconcli -c /configs/rcon.yaml "${cmd}") - ei "> RCON: ${output}" + ei "> Sending: ${cmd} ${message}" + output=$(rcon -c "$RCON_CONFIG_FILE" "${cmd}") + ei "> RCON-Ouput:" + ei "${output}" } run_rcon_cli "$@"