From 5ca9446078c71b71f6f281bcd7d140baa964ecd9 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Wed, 10 Aug 2022 00:12:33 +1000 Subject: [PATCH] Add shellcheck --- .github/workflows/shellcheck.yml | 18 ++ netinstall.sh | 24 +- tools/arkmanager | 59 +++-- tools/arkmanager.cfg.shellcheck | 417 +++++++++++++++++++++++++++++++ tools/install.sh | 10 +- tools/lsb/arkdaemon | 9 +- tools/migrate-config.sh | 1 + tools/redhat/arkdaemon | 9 +- tools/uninstall.sh | 1 + 9 files changed, 504 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/shellcheck.yml create mode 100644 tools/arkmanager.cfg.shellcheck diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..123e5b6 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,18 @@ +name: ShellCheck + +on: [push] + +jobs: + shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + severity: warning + env: + SHELLCHECK_OPTS: --norc --external-sources --source-path=SCRIPTDIR + diff --git a/netinstall.sh b/netinstall.sh index 0a82124..0e7e0ec 100644 --- a/netinstall.sh +++ b/netinstall.sh @@ -10,23 +10,19 @@ steamcmd_user="$1" shift args=() -output=/dev/null unstable= userinstall= userinstall2= -installservice= for arg in "$@"; do case "$arg" in - --verbose) output=/dev/fd/1; ;; - --output=*) output="${arg#--output=}"; ;; --unstable) unstable=1; ;; --repo=*) arkstGithubRepo="${arg#--repo=}"; ;; --perform-user-install) userinstall2=yes; ;; --yes-i-really-want-to-perform-a-user-install) userinstall=yes; ;; *) if [[ -n "$channel" || "$arg" == --* ]]; then - args+="$arg" + args+=("$arg") else channel="$arg" fi @@ -57,15 +53,20 @@ elif [[ "$steamcmd_user" == "--me" ]]; then echo "You have been warned." fi +function die(){ + echo "$@" >&2 + exit +} + function doInstallFromCommit(){ local commit="$1" shift tmpdir="$(mktemp -t -d "ark-server-tools-XXXXXXXX")" if [ -z "$tmpdir" ]; then echo "Unable to create temporary directory"; exit 1; fi - cd "$tmpdir" + cd "$tmpdir" || die "Unable to change to temporary directory" echo "Downloading installer" curl -s -L "https://github.com/${arkstGithubRepo}/archive/${commit}.tar.gz" | tar -xz - cd "ark-server-tools-${commit}/tools" + cd "ark-server-tools-${commit}/tools" || die "Unable to change to extracted directory" if [ ! -f "install.sh" ]; then echo "install.sh not found in $PWD"; exit 1; fi sed -i -e "s|^arkstCommit='.*'|arkstCommit='${commit}'|" \ -e "s|^arkstTag='.*'|arkstTag='${tagname}'|" \ @@ -86,20 +87,19 @@ function doInstallFromCommit(){ function doInstallFromRelease(){ local tagname= - local desc= echo "Getting latest release..." # Read the variables from github - while IFS=$'\t' read n v; do + while IFS=$'\t' read -r n v; do case "${n}" in tag_name) tagname="${v}"; ;; - body) desc="${v}" esac done < <(curl -s "https://api.github.com/repos/${arkstGithubRepo}/releases/latest" | sed -n 's/^ "\([^"]*\)": "*\([^"]*\)"*,*/\1\t\2/p') if [ -n "$tagname" ]; then echo "Latest release is ${tagname}" echo "Getting commit for latest release..." + # shellcheck disable=SC2155 local commit="$(curl -s "https://api.github.com/repos/${arkstGithubRepo}/git/refs/tags/${tagname}" | sed -n 's/^ *"sha": "\(.*\)",.*/\1/p')" doInstallFromCommit "$commit" "$@" else @@ -111,7 +111,7 @@ function doInstallFromRelease(){ function doInstallFromBranch(){ channel="$1" shift - commit="`curl -s "https://api.github.com/repos/${arkstGithubRepo}/git/refs/heads/${channel}" | sed -n 's/^ *"sha": "\(.*\)",.*/\1/p'`" + commit="$(curl -s "https://api.github.com/repos/${arkstGithubRepo}/git/refs/heads/${channel}" | sed -n 's/^ *"sha": "\(.*\)",.*/\1/p')" if [ -z "$commit" ]; then if [ -n "$unstable" ]; then @@ -126,7 +126,7 @@ function doInstallFromBranch(){ } # Download and untar installation files -cd "$TEMP" +cd "$TEMP" || die "Unable to change to temporary directory" if [ "$channel" = "master" ] && [ -z "$unstable" ]; then doInstallFromRelease "${args[@]}" diff --git a/tools/arkmanager b/tools/arkmanager index 0b79961..613b7a7 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2031,SC2155 # ARK: survival evolved manager # @@ -262,12 +263,12 @@ fi # Global variables if [ -f "${arkstGlobalCfgFile}" ]; then - # shellcheck source=arkmanager.cfg + # shellcheck source=arkmanager.cfg.shellcheck source "${arkstGlobalCfgFile}" fi if [ -f "${HOME}/${arkstUserCfgFile}" ]; then - # shellcheck source=arkmanager.cfg + # shellcheck source=arkmanager.cfg.shellcheck source "${HOME}/${arkstUserCfgFile}" fi @@ -298,7 +299,6 @@ GREEN="\\033[1;32m" RED="\\033[1;31m" YELLOW="\\e[0;33m" NORMAL="\\033[0;39m" -maxOpenFiles=100000 # Set TERM to "dumb" if TERM is not set export TERM=${TERM:-dumb} @@ -409,15 +409,20 @@ checkConfig() { # $2 is the default # getArkServerSetting() { + # shellcheck disable=SC2018,SC2019 local lcname="$(tr 'A-Z' 'a-z' <<<"${1}")" local varname + # shellcheck disable=SC2154 for varname in "${!ark_@}"; do + # shellcheck disable=SC2018,SC2019 if [ "$(tr 'A-Z' 'a-z' <<<"$varname")" == "ark_${lcname}" ]; then echo "${!varname}" return fi done + # shellcheck disable=SC2154 for varname in "${!arkopt_@}"; do + # shellcheck disable=SC2018,SC2019 if [ "$(tr 'A-Z' 'a-z' <<<"$varname")" == "arkopt_${lcname}" ]; then echo "${!varname}" return @@ -448,10 +453,12 @@ getRconPort() { # # Gets server bind IP # +# shellcheck disable=SC2120 getMultiHome() { getArkServerSetting "MultiHome" "${1}" } +# shellcheck disable=SC2120 getMultiHomeIP() { getArkServerSetting "MultiHome" "${1:-127.0.0.1}" } @@ -676,10 +683,11 @@ function notify(){ local msg local notifymsg="$1" msg="${notifyTemplate:-Message from instance \`{instance\}\` on server \`{server\}\`: {msg\}}" - msg="${msg//\{msg\}/${1}}" + msg="${msg//\{msg\}/${notifymsg}}" msg="${msg//\{instance\}/${instance}}" msg="${msg//\{server\}/${HOSTNAME}}" + #shellcheck disable=SC2154 for v in "${!notifyvar_@}"; do vn="${v#notifyvar_}" msg="${msg//\{${vn}\}/${!v}}" @@ -712,12 +720,14 @@ function runSteamCMD(){ if [[ -z "${steamcmdhome}" || ! -d "${steamcmdhome}" ]]; then steamcmdhome="${HOME}" fi + # shellcheck disable=SC2086 HOME="${steamcmdhome}" "$steamcmdroot/$steamcmdexec" +@NoPromptForPassword 1 ${steamcmd_cmds_prelogin} "${steamcmd_force_install_dir[@]}" +login "${steamlogin:-anonymous}" ${steamcmd_cmds_postlogin} "$@" +quit } function runSteamCMDspinner(){ if [ -n "$verbose" ]; then printf "Executing" + # shellcheck disable=SC2086 printf " %q" "$steamcmdroot/$steamcmdexec" +@NoPromptForPassword 1 ${steamcmd_cmds_prelogin} "${steamcmd_force_install_dir[@]}" +login "${steamlogin:-anonymous}" ${steamcmd_cmds_postlogin} "$@" +quit printf "\n" if (command >&3) 2>/dev/null; then @@ -741,6 +751,7 @@ function runSteamCMDspinner(){ fi local scpid=$! local pos=0 + # shellcheck disable=SC1003 local spinner=( '\b-' '\b/' '\b|' '\b\\' ) if [ "$progressDisplayType" == "dots" ]; then spinner=( '.' ) @@ -1231,6 +1242,7 @@ doRun() { done < <(sed -n 's/^\(ark\(\|opt\|flag\)_[^= ]*\)=.*/\1/p' <"$configfile") # bring in ark_... options + # shellcheck disable=SC2154 for varname in "${!ark_@}"; do if [ -z "${usedoptions[${varname}]}" ]; then name="${varname#ark_}" @@ -1253,6 +1265,7 @@ doRun() { done # bring in arkflag_... flags + # shellcheck disable=SC2154 for varname in "${!arkflag_@}"; do if [ -z "${usedoptions[${varname}]}" ]; then name="${varname#arkflag_}" @@ -1263,6 +1276,7 @@ doRun() { done # bring in arkopt_... options + # shellcheck disable=SC2154 for varname in "${!arkopt_@}"; do if [ -z "${usedoptions[${varname}]}" ]; then name="${varname#arkopt_}" @@ -1533,10 +1547,11 @@ doStart() { # doStartAll(){ doStart + # shellcheck disable=SC2154 for cfg in "${!configfile_@}"; do if [ -f "${!cfg}" ]; then ( - # shellcheck source=instance.cfg.example + # shellcheck source=arkmanager.cfg.shellcheck source "${!cfg}" doStart ) @@ -1624,7 +1639,7 @@ doStopAll(){ for cfg in "${!configfile_@}"; do if [ -f "${!cfg}" ]; then ( - # shellcheck source=instance.cfg.example + # shellcheck source=arkmanager.cfg.shellcheck source "${!cfg}" doStop ) @@ -1639,6 +1654,7 @@ runSteamCMDAppUpdate(){ local installdir="$1" shift local steamcmd_force_install_dir=( +force_install_dir "$installdir" ) + # shellcheck disable=SC2086 runSteamCMDspinner +app_update "$appid" $steamcmd_appextraopts "$@" } @@ -1737,8 +1753,8 @@ printWarnMessage(){ reason="an update to mod(s) {modnamesupdated}" fi fi - elif [ -n "$shutdownreason" ]; then - reason="$shutdownreason" + elif [ -n "$2" ]; then + reason="$2" elif [ "$1" == "restart" ]; then if [ -n "$msgReasonRestart" ]; then reason="$msgReasonRestart" @@ -1876,7 +1892,6 @@ doWarn(){ usenotify= fi if [ -n "$pid" ]; then - local warnmsg local warnminutes=$(( arkwarnminutes )) if (( warnminutes == 0 )); then warnminutes=60 @@ -2109,6 +2124,8 @@ doUpdate() { doDownloadSteamCMD cd "$steamcmdroot" runSteamCMDAppUpdate "$arkStagingDir" ${appbeta:+-beta} $appbeta ${appbetapass:+-betapassword} $appbetapass $validate + + # shellcheck disable=SC2181 if [ $? -eq 0 ]; then rm -rf "${arkStagingDir}/steamapps/downloading/${appid}" elif [ $? -eq 5 ]; then @@ -2152,6 +2169,7 @@ doUpdate() { fi logprint "Not applying update - download-only requested" elif [ -n "$appupdate" ] || [ -n "$modupdate" ] || [ -n "$bgupdate" ]; then + # version.txt is frequently missing, empty, or out of date if false && [ -f "$arkserverroot/version.txt" ]; then arkversion="$(<"$arkserverroot/version.txt")" else @@ -2319,8 +2337,6 @@ doUpdate() { # checkForModUpdate(){ local updateavail= - local instmft= - local availmft= local modname= local steamworkshopdir="$(getSteamWorkshopDir)" local cancheckmodavail=1 @@ -2407,6 +2423,7 @@ getModIds(){ echo "${serverMapModId}" echo "${ark_TotalConversionMod}" echo "${ark_GameModIds}" | tr ',' '\n' + # shellcheck disable=SC2154 for v in "${!arkmod_@}"; do if [ "${!v}" != "disabled" ]; then echo "${v#arkmod_}" @@ -2451,7 +2468,7 @@ getCollectionMods(){ # listMods(){ local modlist - local modid moddir moddesc + local modid moddir declare -A modlist if [ -n "${serverMapModId}" ]; then modlist[${serverMapModId}]="serverMapModId" @@ -2638,6 +2655,7 @@ isModUpdateNeeded(){ modsrcdir="${modsrcdirs[$modid]}" fi + # shellcheck disable=SC2154 for varname in "${!mod_branch_@}"; do if [ "mod_branch_$modid" == "$varname" ]; then modbranch="${!varname}" @@ -3299,6 +3317,7 @@ doRestore(){ if [ -n "${restorePath}" ]; then echo "Restoring ${file} to ${restorePath}" tar -xjvf "${backupFile}" -C "${restorePath}" --strip-components=1 "${file}" + # shellcheck disable=SC2181 if [ $? == 0 ] ; then echo -e "${NORMAL}\e[68G[ ${GREEN}OK${NORMAL} ]" else @@ -3606,7 +3625,7 @@ doPrintConfig(){ for cfgfile in "$configfile" "${HOME}/${arkstUserCfgFile}" "${arkstGlobalCfgFile}"; do if [ -r "$cfgfile" ]; then while read -r v; do - # shellcheck source=arkmanager.cfg,instance.cfg.example + # shellcheck source=arkmanager.cfg.shellcheck val="$(source "$cfgfile"; echo "${!v}")" if [[ "$val" = "${vals[$v]}" && -z "${vars[$v]}" ]]; then vars["$v"]="$cfgfile" @@ -3620,17 +3639,17 @@ doPrintConfig(){ doTestConfig(){ set -e if [ -r "${arkstGlobalCfgFile}" ]; then - # shellcheck source=arkmanager.cfg + # shellcheck source=arkmanager.cfg.shellcheck source "${arkstGlobalCfgFile}" fi if [ -r "${HOME}/${arkstUserCfgFile}" ]; then - # shellcheck source=arkmanager.cfg + # shellcheck source=arkmanager.cfg.shellcheck source "${HOME}/${arkstUserCfgFile}" fi if [ -r "$configfile" ]; then - # shellcheck source=instance.cfg.example + # shellcheck source=arkmanager.cfg.shellcheck source "$configfile" fi @@ -3673,7 +3692,7 @@ useConfig() { echo "Error: config file $configfile does not exist" exit 1 fi - # shellcheck source=instance.cfg.example + # shellcheck source=arkmanager.cfg.shellcheck source "$configfile" fi if [ -z "$arkserverroot" ]; then @@ -3822,12 +3841,12 @@ EOE main(){ if [ -f "${arkstGlobalCfgFile}" ]; then - # shellcheck source=arkmanager.cfg + # shellcheck source=arkmanager.cfg.shellcheck source "${arkstGlobalCfgFile}" fi if [ -f "${HOME}/${arkstUserCfgFile}" ]; then - # shellcheck source=arkmanager.cfg + # shellcheck source=arkmanager.cfg.shellcheck source "${HOME}/${arkstUserCfgFile}" fi @@ -3860,6 +3879,7 @@ main(){ continue ;; --cronjob) + # shellcheck disable=SC2034 inCronJob=true continue ;; @@ -4014,6 +4034,7 @@ main(){ # Handle all instances being requested if [[ "$allinstances" == "yes" ]]; then + # shellcheck disable=SC2207 instances=( $(getAllInstanceNames) ) fi diff --git a/tools/arkmanager.cfg.shellcheck b/tools/arkmanager.cfg.shellcheck new file mode 100644 index 0000000..0e9e36f --- /dev/null +++ b/tools/arkmanager.cfg.shellcheck @@ -0,0 +1,417 @@ +### arkmanager variables + +# Script version +arkstVersion='1.6' + +# Set by installer to git tag (i.e. release version) +arkstTag= + +# Set by installer to git commit +arkstCommit= + +# Set this if you are a distribution package maintainer otherwise leave empty +arkstUsePkgManager= + +# Set this to allow variable expansion in variables sourced from arkmanager.cfg +arkstRootUseEnv= + +# Set this to override the main fork +arkstGithubRepoOverride= + +# Set this to override the global config file path +arkstGlobalCfgFileOverride= + +# Set this to override the user config file path +arkstUserCfgFileOverride= + +### arkmanager.cfg + +# Git branch in above ${arkstGithubRepoOverride} repository +arkstChannel="master" + +# Set by installer to directory containing installed executable. +install_bindir="/usr/bin" + +# Set by installer to directory containing installed miscellaneous executables. +install_libexecdir="/usr/libexec/arkmanager" + +# Set by installer to directory containing installed miscellaneous data. +install_datadir="/usr/share/arkmanager" + +## SteamCMD Configuration + +# Path to SteamCMD directory - change this to "/usr/games" on Debian/Ubuntu/CentOS if you have the steamcmd package installed. +steamcmdroot="/home/steam/steamcmd" + +# Name of SteamCMD executable - change this to "steamcmd" on Debian/Ubuntu/CentOS if you have the steamcmd package installed. +steamcmdexec="steamcmd.sh" + +# User under which this script should be run. +steamcmd_user="steam" + +# Use sudo when executing user does not match ${steamcmd_user} +usesudo= + +# Path to SteamCMD AppInfo cache (appinfo.vdf) - change this to "/home/steam/.steam/appcache/appinfo.vdf" on Debian/Ubuntu/CentOS if you have the steamcmd package installed. +steamcmd_appinfocache="/home/steam/Steam/appcache/appinfo.vdf" + +# Path to SteamCMD Workshop log (workshop_log.txt) - change this to "/home/steam/.steam/logs/workshop_log.txt" on Debian/Ubuntu/CentOS if you have the steamcmd package installed. +steamcmd_workshoplog="/home/steam/Steam/logs/workshop_log.txt" + +# SteamCMD login - may be required for non-public mods. Must have already been logged in manually. +steamlogin= + +# SteamCMD home directory override +steamcmdhome= + +# SteamCMD commands to execute before login command +steamcmd_cmds_prelogin= + +# SteamCMD commands to execute after login but before main command +steamcmd_cmds_postlogin= + +# SteamCMD extra options to app_update command +steamcmd_appextraopts= + +## ARK server global config + +# Working directory +serverbasedir= + +# Path of server executable relative to ${arkserverroot} +arkserverexec="ShooterGame/Binaries/Linux/ShooterGameServer" + +# Path in which to store ARK server backups +arkbackupdir="/home/steam/ARK-Backups" + +# Compress ARK server backups - true to enable, false to disable +arkbackupcompress="true" + +# Disable old Port - 1 behaviour - true to disable behaviour, false to use old behaviour +arkNoPortDecrement="true" + +# Auto-restart file path relative to ${arkserverroot} - used to signal if server should be automatically restarted if it exits +arkautorestartfile="ShooterGame/Saved/.autorestart" + +# Update ARK server before startup - true to enable, false to disable +arkAutoUpdateOnStart="false" + +# Backup ARK server config and save before updating - true to enable, false to disable +arkBackupPreUpdate="false" + +# Command to run after creating backup - e.g. to upload backup to an external service +# Executed using eval +# ${backupfile} will be set to path of backup file +arkBackupPostCommand='aws s3 cp "$backupfile" "s3://bucket_name/backups"' + +# Maximum delay before starting next instance - 0 or unset for no delay +arkStartDelay=20 + +# Same as above, for v1.6.43 compatibility +defaultinstance_max=20 + +# SteamCMD staging directory - used to enable updates to be fully downloaded before restarting the server (reduces downtime while updating). +# Also used for reducing disk space used by multiple instances +arkStagingDir="/home/steam/ARK-Staging" + +# Use reflinks instead of hard links when updating from staging directory +# Only on filesystems that support reflinks - e.g. btrfs +useRefLinks= + +# Ignore installed mods when checking for mods to update +ignoreInstalledMods= + +# Extra options to pass when creating cron job +arkCronExtraOpts= + +## Options to automatically remove old backups to keep backup size in check +## Each compressed backup is generally about 1-2MB in size. + +# Maximum backup directory usage in Megabytes - old backups will be deleted to keep the backup directory usage below this size +arkMaxBackupSizeMB="500" + +# Maximum backup directory usage in whole Gigabytes - alternative for above ${arkMaxBackupSizeMB} +arkMaxBackupSizeGB="2" + +## Shutdown warnings + +# Number of minutes to warn players when using --warn +arkwarnminutes="60" + +# Obey ${arkwarnminutes} even if no players are connected - true to enable, false to disable +arkprecisewarn="false" + +## Warning messages +## Modify as desired, putting the %d replacement operator where the number belongs + +# Message template when updating with 1 or more minutes remaining +msgWarnUpdateMinutes="This ARK server will shutdown for an update in %d minutes" + +# Message template when updating with less than 1 minute remaining +msgWarnUpdateSeconds="This ARK server will shutdown for an update in %d seconds" + +# Message template when restarting with 1 or more minutes remaining +msgWarnRestartMinutes="This ARK server will shutdown for a restart in %d minutes" + +# Message template when restarting with less than 1 minute remaining +msgWarnRestartSeconds="This ARK server will shutdown for a restart in %d seconds" + +# Message template when shutting down with 1 or more minutes remaining +msgWarnShutdownMinutes="This ARK server will shutdown in %d minutes" + +# Message template when shutting down with less than 1 minute remaining +msgWarnShutdownSeconds="This ARK server will shutdown in %d seconds" + +# Message when update / restart / shutdown cancelled by player request +msgWarnCancelled="Restart cancelled by player request" + +# Message when update / restart / shutdown cancelled by operator +msgUpdateCancelled="Shutdown cancelled by operator (%s)" + +# RCON command to use for broadcast command +broadcastcmd="broadcast" +#broadcastcmd="serverchat" + +## Notifications + +# Discord Webhook URL +discordWebhookURL="https://discordapp.com/api/webhooks/{webhook.id}/{webhook.token}" + +# Notify template {msg} when shutting down +notifyMsgShuttingDown="Shutting down" + +# Notify template {msg} when starting +notifyMsgStarting="Starting" + +# Notify template {msg} when server is up +notifyMsgServerUp="Server is up" + +# Notify template {msg} when server has stopped listening +notifyMsgStoppedListening="Server has stopped listening - restarting" + +# Notify template {msg} when server has unexpectedly exited +notifyMsgServerTerminated="Server exited - restarting" + +# Warning message template - alternative to msgWarn* above +# {time} is replaced with msgTimeMinutes or msgTimeSeconds +# {reason} is replaced with the reason appropriate for the update / shutdown / restart +msgWarnReason="This ARK server will shut down in {time} {reason}" + +# {time} template used when time remaining is 1 or more minutes +msgTimeMinutes="{minutes} minutes" + +# {time} template used when time remaining is less than 1 minute +msgTimeSeconds="{seconds} seconds" + +# {reason} template used for app-only updates +msgReasonUpdateApp="for an update to the game" + +# {update} template used for mod-only updates +# {modnames} is replaced with names of mods updated +msgReasonUpdateMod="for an update to mod(s) {modnamesupdated}" + +# {update} template used for app and mod updates +# {modnames} is replaced with names of mods updated +msgReasonUpdateAppMod="for an update to the game and an update to mod(s) {modnamesupdated}" + +# {update} template used for restarts +msgReasonRestart="for a server restart" + +# {update} template used for shutdown +msgReasonShutdown="" + +# Notification template +# {instance} is replaced with instance name +# {server} is replaced with server name +# {msg} is replaced with template {msg} above +notifyTemplate="Message from instance {instance} on server {server}: {msg}" + +# Disable sending update / shutdown / restart warnings via notifications +noNotifyWarn=true + +# Additional command to send notifications +# Executed using eval +# ${instance} is expanded to instance name +# ${msg} is expanded to message +notifyCommand='echo "$msg" | mailx -s "Message from instance ${instance} on server ${HOSTNAME}" "email@domain.com"' + +# Chat message players can use to cancel update / restart +chatCommandRestartCancel="/cancelupdate" + +# Server map +serverMap="TheIsland" + +# Server map mod Id ( in http://steamcommunity.com/sharedfiles/filedetails/?id=) - alternative to above ${serverMap} +serverMapModId="469987622" + +## ARK server common options - use ark_= +## comment out these values if you want to define them +## inside your GameUserSettings.ini file +## This is not an exhaustive list of options + +# Total Conversion Mod Id +ark_TotalConversionMod="496735411" + +# Enable RCON +ark_RCONEnabled="True" + +# ARK server password, empty: no password required to login +ark_ServerPassword="" + +# ARK server admin password +ark_ServerAdminPassword="keyboardcat" + +# Maximum player connection count +ark_MaxPlayers="70" + +# Additional game Mod Ids +ark_GameModIds="487516323,487516324,487516325" + +# Alternative Save Directory name +ark_AltSaveDirectoryName="SotF" + +## ARK server flags - use arkflag_=true +## These are only examples - this is not an exhaustive list of options + +# Only allow admins to rejoin as spectator +arkflag_OnlyAdminRejoinAsSpectator=true + +# Disallow players from becoming spectators when they die +arkflag_DisableDeathSpectator=true + +# ARK server manages mods itself +arkflag_automanagedmods= + +## ARK server options - i.e. for -optname=val, use arkopt_optname=val +## These are only examples - this is not an exhaustive list of options + +# Structure Destruction Tag - This was a one-time option when upgrading from before ARK v216 +arkopt_StructureDestructionTag=DestroySwampSnowStructures + +# Logs path (default /var/log/arktools) +logdir="/var/log/arktools" + +# ARK server Steam App ID +appid=376030 + +# Steam App ID for downloading mods +mod_appid=346110 + +# Mod OS Selection - should be Windows - Linux mods are known to be incompatible with the ARK server +mod_branch=Windows + +# Mod-specific OS selection +mod_branch_496735411=Windows + +# Specify that you understand the above warning about Linux mods, and want to use Linux mods anyway +nowarnmodbranch= + +# alternate configs +# example for config name "ark1": +configfile_ark1="/path/to/config/file" + +# Default instance when no instance is specified when running commands +defaultinstance="main" + +# Single-instance mode +arkSingleInstance= + +### instance.cfg + +# Absolute path of ARK server instance +arkserverroot="/home/steam/ARK" + +# Server map +serverMap="TheIsland" + +# Server map mod Id ( in http://steamcommunity.com/sharedfiles/filedetails/?id=) - alternative to above ${serverMap} +serverMapModId="469987622" + +# Custom Dynamic Config URL +# This is equivalent to specifying ark_customdynamicconfigurl and arkflag_UseDynamicConfig at the end of the config +arkCustomDynamicConfigURL="http://arkdedicated.com/dynamicconfig.ini" + +# Script to run before instance starts +arkPreStart="/etc/arkmanager/instances/instance.start" + +# Use Steam player list query instead of player count from server query for player count +arkUsePlayerList= + +# Mod collection Ids to include in GameModIds +arkModCollections= + +# Overwrite GameUserSettings.ini from this file +arkGameUserSettingsIniFile= + +# Overwrite Game.ini from this file +arkGameIniFile= + +# Attempt to renice (boost priority) of ARK server process +arkPriorityBoost= + +# Set ARK server CPU affinity +arkCpuAffinity= + + + +## ARK server instance options - use ark_= +## comment out these values if you want to define them +## inside your GameUserSettings.ini file +## This is not an exhaustive list of options + +# Total Conversion Mod Id +ark_TotalConversionMod="496735411" + +# Enable RCON +ark_RCONEnabled="True" + +# RCON Port - this must be unique for each game server running on the host +ark_RCONPort="32330" + +# Server Name - this is the name that appears in the server browser. +# If this name should contain characters outside the 7-bit ASCII character set, this should be commented out and the server name should be specified in a UTF-16 encoded GameUserSettings.ini instead +ark_SessionName="ARK Server Tools" + +# Game Port - this port and the port above / below it must be unique for each game server running on the host +ark_Port="7778" + +# Query Port - this port must be unique for each game server running on the host +ark_QueryPort="27015" + +# ARK server password, empty: no password required to login +ark_ServerPassword="" + +# ARK server admin password +ark_ServerAdminPassword="keyboardcat" + +# Maximum player connection count +ark_MaxPlayers="70" + +# Additional game Mod Ids +ark_GameModIds="487516323,487516324,487516325" + +# Alternative Save Directory name +ark_AltSaveDirectoryName="SotF" + +## ARK server flags - use arkflag_=true +## These are only examples - this is not an exhaustive list of options + +# Only allow admins to rejoin as spectator +arkflag_OnlyAdminRejoinAsSpectator=true + +# Disallow players from becoming spectators when they die +arkflag_DisableDeathSpectator=true + +# Enable crossplay between Steam and Epic players - mods cannot be used +arkflag_crossplay= + +# Enable Epic connections only - mods cannot be used +arkflag_epiconly= + +## ARK server options - i.e. for -optname=val, use arkopt_optname=val +## These are only examples - this is not an exhaustive list of options + +# Structure Destruction Tag - This was a one-time option when upgrading from before ARK v216 +arkopt_StructureDestructionTag=DestroySwampSnowStructures + + diff --git a/tools/install.sh b/tools/install.sh index a330e3e..3d3e013 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -93,12 +93,12 @@ while [ -n "$1" ]; do shift done -if [ "$userinstall" == "yes" -a "$UID" -eq 0 ]; then +if [ "$userinstall" == "yes" ] && [ "$UID" -eq 0 ]; then echo "Refusing to perform user-install as root" showusage=yes fi -if [ "$showusage" == "no" -a -z "$steamcmd_user" ]; then +if [ "$showusage" == "no" ] && [ -z "$steamcmd_user" ]; then echo "No user specified" showusage=yes fi @@ -245,7 +245,7 @@ else chmod +x "${INSTALL_ROOT}/etc/init.d/arkmanager" sed -i "s|^DAEMON=\"/usr/bin/|DAEMON=\"${BINDIR}/|" "${INSTALL_ROOT}/etc/init.d/arkmanager" # add to startup if the system use sysinit - if [ -x /usr/sbin/update-rc.d -a -z "${INSTALL_ROOT}" ]; then + if [ -x /usr/sbin/update-rc.d ] && [ -z "${INSTALL_ROOT}" ]; then update-rc.d arkmanager defaults echo "Ark server will now start on boot, if you want to remove this feature run the following line" echo "update-rc.d -f arkmanager remove" @@ -272,7 +272,7 @@ else cp redhat/arkdaemon "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager" chmod +x "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager" sed -i "s@^DAEMON=\"/usr/bin/@DAEMON=\"${BINDIR}/@" "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager" - if [ -x /sbin/chkconfig -a -z "${INSTALL_ROOT}" ]; then + if [ -x /sbin/chkconfig ] && [ -z "${INSTALL_ROOT}" ]; then chkconfig --add arkmanager echo "Ark server will now start on boot, if you want to remove this feature run the following line" echo "chkconfig arkmanager off" @@ -282,7 +282,7 @@ else cp openrc/arkdaemon "${INSTALL_ROOT}/etc/init.d/arkmanager" chmod +x "${INSTALL_ROOT}/etc/init.d/arkmanager" sed -i "s@^DAEMON=\"/usr/bin/@DAEMON=\"${BINDIR}/@" "${INSTALL_ROOT}/etc/init.d/arkmanager" - if [ -x /sbin/rc-update -a -z "${INSTALL_ROOT}" ]; then + if [ -x /sbin/rc-update ] && [ -z "${INSTALL_ROOT}" ]; then rc-update add arkmanager default echo "Ark server will now start on boot, if you want to remove this feature run the following line" echo "rc-update del arkmanager default" diff --git a/tools/lsb/arkdaemon b/tools/lsb/arkdaemon index 6390f59..7e76303 100755 --- a/tools/lsb/arkdaemon +++ b/tools/lsb/arkdaemon @@ -14,10 +14,11 @@ . /lib/lsb/init-functions # Global variables +# shellcheck source=../arkmanager.cfg source /etc/arkmanager/arkmanager.cfg NAME="ShooterGameServer" -LOGFILE="${logdir}/${NAME}.log" +#LOGFILE="${logdir}/${NAME}.log" DAEMON="/usr/bin/arkmanager" SVCNAME="${0##*/}" @@ -59,12 +60,12 @@ function start_instance(){ function start_all_instances(){ local nosuccess=0 - local anyfailure=0 + #local anyfailure=0 for instance in $("${DAEMON}" list-instances --brief); do if start_instance "$instance"; then nosuccess=0 - else - anyfailure=1 + #else + # anyfailure=1 fi done diff --git a/tools/migrate-config.sh b/tools/migrate-config.sh index e7bd017..8911216 100755 --- a/tools/migrate-config.sh +++ b/tools/migrate-config.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2034 configfile="$1" newopts=( arkbackupdir arkautorestartfile install_bindir install_libexecdir install_datadir mod_appid ) diff --git a/tools/redhat/arkdaemon b/tools/redhat/arkdaemon index 48f0594..24b7dda 100755 --- a/tools/redhat/arkdaemon +++ b/tools/redhat/arkdaemon @@ -24,10 +24,11 @@ . /etc/rc.d/init.d/functions # Global variables +# shellcheck source=../arkmanager.cfg source /etc/arkmanager/arkmanager.cfg NAME="ShooterGameServer" -LOGFILE="${logdir}/${NAME}.log" +#LOGFILE="${logdir}/${NAME}.log" DAEMON="/usr/bin/arkmanager" GREEN="\\033[1;32m" @@ -74,12 +75,12 @@ function start_instance(){ function start_all_instances(){ local nosuccess=0 - local anyfailure=0 + #local anyfailure=0 for instance in $("${DAEMON}" list-instances --brief); do if start_instance "$instance"; then nosuccess=0 - else - anyfailure=1 + #else + # anyfailure=1 fi done diff --git a/tools/uninstall.sh b/tools/uninstall.sh index 0b7d096..f188732 100644 --- a/tools/uninstall.sh +++ b/tools/uninstall.sh @@ -3,6 +3,7 @@ # uninstall.sh BINDIR="/usr/bin" +# shellcheck disable=SC2034 DATADIR="/usr/share/arkmanager" LIBEXECDIR="/usr/libexec/arkmanager" INITSCRIPT=