Add shellcheck

This commit is contained in:
Ben Peddell 2022-08-10 00:12:33 +10:00
parent 6e2c92549d
commit 5ca9446078
9 changed files with 504 additions and 44 deletions

18
.github/workflows/shellcheck.yml vendored Normal file
View File

@ -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

View File

@ -10,23 +10,19 @@ steamcmd_user="$1"
shift shift
args=() args=()
output=/dev/null
unstable= unstable=
userinstall= userinstall=
userinstall2= userinstall2=
installservice=
for arg in "$@"; do for arg in "$@"; do
case "$arg" in case "$arg" in
--verbose) output=/dev/fd/1; ;;
--output=*) output="${arg#--output=}"; ;;
--unstable) unstable=1; ;; --unstable) unstable=1; ;;
--repo=*) arkstGithubRepo="${arg#--repo=}"; ;; --repo=*) arkstGithubRepo="${arg#--repo=}"; ;;
--perform-user-install) userinstall2=yes; ;; --perform-user-install) userinstall2=yes; ;;
--yes-i-really-want-to-perform-a-user-install) userinstall=yes; ;; --yes-i-really-want-to-perform-a-user-install) userinstall=yes; ;;
*) *)
if [[ -n "$channel" || "$arg" == --* ]]; then if [[ -n "$channel" || "$arg" == --* ]]; then
args+="$arg" args+=("$arg")
else else
channel="$arg" channel="$arg"
fi fi
@ -57,15 +53,20 @@ elif [[ "$steamcmd_user" == "--me" ]]; then
echo "You have been warned." echo "You have been warned."
fi fi
function die(){
echo "$@" >&2
exit
}
function doInstallFromCommit(){ function doInstallFromCommit(){
local commit="$1" local commit="$1"
shift shift
tmpdir="$(mktemp -t -d "ark-server-tools-XXXXXXXX")" tmpdir="$(mktemp -t -d "ark-server-tools-XXXXXXXX")"
if [ -z "$tmpdir" ]; then echo "Unable to create temporary directory"; exit 1; fi 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" echo "Downloading installer"
curl -s -L "https://github.com/${arkstGithubRepo}/archive/${commit}.tar.gz" | tar -xz 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 if [ ! -f "install.sh" ]; then echo "install.sh not found in $PWD"; exit 1; fi
sed -i -e "s|^arkstCommit='.*'|arkstCommit='${commit}'|" \ sed -i -e "s|^arkstCommit='.*'|arkstCommit='${commit}'|" \
-e "s|^arkstTag='.*'|arkstTag='${tagname}'|" \ -e "s|^arkstTag='.*'|arkstTag='${tagname}'|" \
@ -86,20 +87,19 @@ function doInstallFromCommit(){
function doInstallFromRelease(){ function doInstallFromRelease(){
local tagname= local tagname=
local desc=
echo "Getting latest release..." echo "Getting latest release..."
# Read the variables from github # Read the variables from github
while IFS=$'\t' read n v; do while IFS=$'\t' read -r n v; do
case "${n}" in case "${n}" in
tag_name) tagname="${v}"; ;; tag_name) tagname="${v}"; ;;
body) desc="${v}"
esac esac
done < <(curl -s "https://api.github.com/repos/${arkstGithubRepo}/releases/latest" | sed -n 's/^ "\([^"]*\)": "*\([^"]*\)"*,*/\1\t\2/p') done < <(curl -s "https://api.github.com/repos/${arkstGithubRepo}/releases/latest" | sed -n 's/^ "\([^"]*\)": "*\([^"]*\)"*,*/\1\t\2/p')
if [ -n "$tagname" ]; then if [ -n "$tagname" ]; then
echo "Latest release is ${tagname}" echo "Latest release is ${tagname}"
echo "Getting commit for latest release..." 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')" local commit="$(curl -s "https://api.github.com/repos/${arkstGithubRepo}/git/refs/tags/${tagname}" | sed -n 's/^ *"sha": "\(.*\)",.*/\1/p')"
doInstallFromCommit "$commit" "$@" doInstallFromCommit "$commit" "$@"
else else
@ -111,7 +111,7 @@ function doInstallFromRelease(){
function doInstallFromBranch(){ function doInstallFromBranch(){
channel="$1" channel="$1"
shift 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 [ -z "$commit" ]; then
if [ -n "$unstable" ]; then if [ -n "$unstable" ]; then
@ -126,7 +126,7 @@ function doInstallFromBranch(){
} }
# Download and untar installation files # Download and untar installation files
cd "$TEMP" cd "$TEMP" || die "Unable to change to temporary directory"
if [ "$channel" = "master" ] && [ -z "$unstable" ]; then if [ "$channel" = "master" ] && [ -z "$unstable" ]; then
doInstallFromRelease "${args[@]}" doInstallFromRelease "${args[@]}"

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
# shellcheck disable=SC2031,SC2155
# ARK: survival evolved manager # ARK: survival evolved manager
# #
@ -262,12 +263,12 @@ fi
# Global variables # Global variables
if [ -f "${arkstGlobalCfgFile}" ]; then if [ -f "${arkstGlobalCfgFile}" ]; then
# shellcheck source=arkmanager.cfg # shellcheck source=arkmanager.cfg.shellcheck
source "${arkstGlobalCfgFile}" source "${arkstGlobalCfgFile}"
fi fi
if [ -f "${HOME}/${arkstUserCfgFile}" ]; then if [ -f "${HOME}/${arkstUserCfgFile}" ]; then
# shellcheck source=arkmanager.cfg # shellcheck source=arkmanager.cfg.shellcheck
source "${HOME}/${arkstUserCfgFile}" source "${HOME}/${arkstUserCfgFile}"
fi fi
@ -298,7 +299,6 @@ GREEN="\\033[1;32m"
RED="\\033[1;31m" RED="\\033[1;31m"
YELLOW="\\e[0;33m" YELLOW="\\e[0;33m"
NORMAL="\\033[0;39m" NORMAL="\\033[0;39m"
maxOpenFiles=100000
# Set TERM to "dumb" if TERM is not set # Set TERM to "dumb" if TERM is not set
export TERM=${TERM:-dumb} export TERM=${TERM:-dumb}
@ -409,15 +409,20 @@ checkConfig() {
# $2 is the default # $2 is the default
# #
getArkServerSetting() { getArkServerSetting() {
# shellcheck disable=SC2018,SC2019
local lcname="$(tr 'A-Z' 'a-z' <<<"${1}")" local lcname="$(tr 'A-Z' 'a-z' <<<"${1}")"
local varname local varname
# shellcheck disable=SC2154
for varname in "${!ark_@}"; do for varname in "${!ark_@}"; do
# shellcheck disable=SC2018,SC2019
if [ "$(tr 'A-Z' 'a-z' <<<"$varname")" == "ark_${lcname}" ]; then if [ "$(tr 'A-Z' 'a-z' <<<"$varname")" == "ark_${lcname}" ]; then
echo "${!varname}" echo "${!varname}"
return return
fi fi
done done
# shellcheck disable=SC2154
for varname in "${!arkopt_@}"; do for varname in "${!arkopt_@}"; do
# shellcheck disable=SC2018,SC2019
if [ "$(tr 'A-Z' 'a-z' <<<"$varname")" == "arkopt_${lcname}" ]; then if [ "$(tr 'A-Z' 'a-z' <<<"$varname")" == "arkopt_${lcname}" ]; then
echo "${!varname}" echo "${!varname}"
return return
@ -448,10 +453,12 @@ getRconPort() {
# #
# Gets server bind IP # Gets server bind IP
# #
# shellcheck disable=SC2120
getMultiHome() { getMultiHome() {
getArkServerSetting "MultiHome" "${1}" getArkServerSetting "MultiHome" "${1}"
} }
# shellcheck disable=SC2120
getMultiHomeIP() { getMultiHomeIP() {
getArkServerSetting "MultiHome" "${1:-127.0.0.1}" getArkServerSetting "MultiHome" "${1:-127.0.0.1}"
} }
@ -676,10 +683,11 @@ function notify(){
local msg local msg
local notifymsg="$1" local notifymsg="$1"
msg="${notifyTemplate:-Message from instance \`{instance\}\` on server \`{server\}\`: {msg\}}" msg="${notifyTemplate:-Message from instance \`{instance\}\` on server \`{server\}\`: {msg\}}"
msg="${msg//\{msg\}/${1}}" msg="${msg//\{msg\}/${notifymsg}}"
msg="${msg//\{instance\}/${instance}}" msg="${msg//\{instance\}/${instance}}"
msg="${msg//\{server\}/${HOSTNAME}}" msg="${msg//\{server\}/${HOSTNAME}}"
#shellcheck disable=SC2154
for v in "${!notifyvar_@}"; do for v in "${!notifyvar_@}"; do
vn="${v#notifyvar_}" vn="${v#notifyvar_}"
msg="${msg//\{${vn}\}/${!v}}" msg="${msg//\{${vn}\}/${!v}}"
@ -712,12 +720,14 @@ function runSteamCMD(){
if [[ -z "${steamcmdhome}" || ! -d "${steamcmdhome}" ]]; then if [[ -z "${steamcmdhome}" || ! -d "${steamcmdhome}" ]]; then
steamcmdhome="${HOME}" steamcmdhome="${HOME}"
fi fi
# shellcheck disable=SC2086
HOME="${steamcmdhome}" "$steamcmdroot/$steamcmdexec" +@NoPromptForPassword 1 ${steamcmd_cmds_prelogin} "${steamcmd_force_install_dir[@]}" +login "${steamlogin:-anonymous}" ${steamcmd_cmds_postlogin} "$@" +quit HOME="${steamcmdhome}" "$steamcmdroot/$steamcmdexec" +@NoPromptForPassword 1 ${steamcmd_cmds_prelogin} "${steamcmd_force_install_dir[@]}" +login "${steamlogin:-anonymous}" ${steamcmd_cmds_postlogin} "$@" +quit
} }
function runSteamCMDspinner(){ function runSteamCMDspinner(){
if [ -n "$verbose" ]; then if [ -n "$verbose" ]; then
printf "Executing" 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 " %q" "$steamcmdroot/$steamcmdexec" +@NoPromptForPassword 1 ${steamcmd_cmds_prelogin} "${steamcmd_force_install_dir[@]}" +login "${steamlogin:-anonymous}" ${steamcmd_cmds_postlogin} "$@" +quit
printf "\n" printf "\n"
if (command >&3) 2>/dev/null; then if (command >&3) 2>/dev/null; then
@ -741,6 +751,7 @@ function runSteamCMDspinner(){
fi fi
local scpid=$! local scpid=$!
local pos=0 local pos=0
# shellcheck disable=SC1003
local spinner=( '\b-' '\b/' '\b|' '\b\\' ) local spinner=( '\b-' '\b/' '\b|' '\b\\' )
if [ "$progressDisplayType" == "dots" ]; then if [ "$progressDisplayType" == "dots" ]; then
spinner=( '.' ) spinner=( '.' )
@ -1231,6 +1242,7 @@ doRun() {
done < <(sed -n 's/^\(ark\(\|opt\|flag\)_[^= ]*\)=.*/\1/p' <"$configfile") done < <(sed -n 's/^\(ark\(\|opt\|flag\)_[^= ]*\)=.*/\1/p' <"$configfile")
# bring in ark_... options # bring in ark_... options
# shellcheck disable=SC2154
for varname in "${!ark_@}"; do for varname in "${!ark_@}"; do
if [ -z "${usedoptions[${varname}]}" ]; then if [ -z "${usedoptions[${varname}]}" ]; then
name="${varname#ark_}" name="${varname#ark_}"
@ -1253,6 +1265,7 @@ doRun() {
done done
# bring in arkflag_... flags # bring in arkflag_... flags
# shellcheck disable=SC2154
for varname in "${!arkflag_@}"; do for varname in "${!arkflag_@}"; do
if [ -z "${usedoptions[${varname}]}" ]; then if [ -z "${usedoptions[${varname}]}" ]; then
name="${varname#arkflag_}" name="${varname#arkflag_}"
@ -1263,6 +1276,7 @@ doRun() {
done done
# bring in arkopt_... options # bring in arkopt_... options
# shellcheck disable=SC2154
for varname in "${!arkopt_@}"; do for varname in "${!arkopt_@}"; do
if [ -z "${usedoptions[${varname}]}" ]; then if [ -z "${usedoptions[${varname}]}" ]; then
name="${varname#arkopt_}" name="${varname#arkopt_}"
@ -1533,10 +1547,11 @@ doStart() {
# #
doStartAll(){ doStartAll(){
doStart doStart
# shellcheck disable=SC2154
for cfg in "${!configfile_@}"; do for cfg in "${!configfile_@}"; do
if [ -f "${!cfg}" ]; then if [ -f "${!cfg}" ]; then
( (
# shellcheck source=instance.cfg.example # shellcheck source=arkmanager.cfg.shellcheck
source "${!cfg}" source "${!cfg}"
doStart doStart
) )
@ -1624,7 +1639,7 @@ doStopAll(){
for cfg in "${!configfile_@}"; do for cfg in "${!configfile_@}"; do
if [ -f "${!cfg}" ]; then if [ -f "${!cfg}" ]; then
( (
# shellcheck source=instance.cfg.example # shellcheck source=arkmanager.cfg.shellcheck
source "${!cfg}" source "${!cfg}"
doStop doStop
) )
@ -1639,6 +1654,7 @@ runSteamCMDAppUpdate(){
local installdir="$1" local installdir="$1"
shift shift
local steamcmd_force_install_dir=( +force_install_dir "$installdir" ) local steamcmd_force_install_dir=( +force_install_dir "$installdir" )
# shellcheck disable=SC2086
runSteamCMDspinner +app_update "$appid" $steamcmd_appextraopts "$@" runSteamCMDspinner +app_update "$appid" $steamcmd_appextraopts "$@"
} }
@ -1737,8 +1753,8 @@ printWarnMessage(){
reason="an update to mod(s) {modnamesupdated}" reason="an update to mod(s) {modnamesupdated}"
fi fi
fi fi
elif [ -n "$shutdownreason" ]; then elif [ -n "$2" ]; then
reason="$shutdownreason" reason="$2"
elif [ "$1" == "restart" ]; then elif [ "$1" == "restart" ]; then
if [ -n "$msgReasonRestart" ]; then if [ -n "$msgReasonRestart" ]; then
reason="$msgReasonRestart" reason="$msgReasonRestart"
@ -1876,7 +1892,6 @@ doWarn(){
usenotify= usenotify=
fi fi
if [ -n "$pid" ]; then if [ -n "$pid" ]; then
local warnmsg
local warnminutes=$(( arkwarnminutes )) local warnminutes=$(( arkwarnminutes ))
if (( warnminutes == 0 )); then if (( warnminutes == 0 )); then
warnminutes=60 warnminutes=60
@ -2109,6 +2124,8 @@ doUpdate() {
doDownloadSteamCMD doDownloadSteamCMD
cd "$steamcmdroot" cd "$steamcmdroot"
runSteamCMDAppUpdate "$arkStagingDir" ${appbeta:+-beta} $appbeta ${appbetapass:+-betapassword} $appbetapass $validate runSteamCMDAppUpdate "$arkStagingDir" ${appbeta:+-beta} $appbeta ${appbetapass:+-betapassword} $appbetapass $validate
# shellcheck disable=SC2181
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rm -rf "${arkStagingDir}/steamapps/downloading/${appid}" rm -rf "${arkStagingDir}/steamapps/downloading/${appid}"
elif [ $? -eq 5 ]; then elif [ $? -eq 5 ]; then
@ -2152,6 +2169,7 @@ doUpdate() {
fi fi
logprint "Not applying update - download-only requested" logprint "Not applying update - download-only requested"
elif [ -n "$appupdate" ] || [ -n "$modupdate" ] || [ -n "$bgupdate" ]; then 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 if false && [ -f "$arkserverroot/version.txt" ]; then
arkversion="$(<"$arkserverroot/version.txt")" arkversion="$(<"$arkserverroot/version.txt")"
else else
@ -2319,8 +2337,6 @@ doUpdate() {
# #
checkForModUpdate(){ checkForModUpdate(){
local updateavail= local updateavail=
local instmft=
local availmft=
local modname= local modname=
local steamworkshopdir="$(getSteamWorkshopDir)" local steamworkshopdir="$(getSteamWorkshopDir)"
local cancheckmodavail=1 local cancheckmodavail=1
@ -2407,6 +2423,7 @@ getModIds(){
echo "${serverMapModId}" echo "${serverMapModId}"
echo "${ark_TotalConversionMod}" echo "${ark_TotalConversionMod}"
echo "${ark_GameModIds}" | tr ',' '\n' echo "${ark_GameModIds}" | tr ',' '\n'
# shellcheck disable=SC2154
for v in "${!arkmod_@}"; do for v in "${!arkmod_@}"; do
if [ "${!v}" != "disabled" ]; then if [ "${!v}" != "disabled" ]; then
echo "${v#arkmod_}" echo "${v#arkmod_}"
@ -2451,7 +2468,7 @@ getCollectionMods(){
# #
listMods(){ listMods(){
local modlist local modlist
local modid moddir moddesc local modid moddir
declare -A modlist declare -A modlist
if [ -n "${serverMapModId}" ]; then if [ -n "${serverMapModId}" ]; then
modlist[${serverMapModId}]="serverMapModId" modlist[${serverMapModId}]="serverMapModId"
@ -2638,6 +2655,7 @@ isModUpdateNeeded(){
modsrcdir="${modsrcdirs[$modid]}" modsrcdir="${modsrcdirs[$modid]}"
fi fi
# shellcheck disable=SC2154
for varname in "${!mod_branch_@}"; do for varname in "${!mod_branch_@}"; do
if [ "mod_branch_$modid" == "$varname" ]; then if [ "mod_branch_$modid" == "$varname" ]; then
modbranch="${!varname}" modbranch="${!varname}"
@ -3299,6 +3317,7 @@ doRestore(){
if [ -n "${restorePath}" ]; then if [ -n "${restorePath}" ]; then
echo "Restoring ${file} to ${restorePath}" echo "Restoring ${file} to ${restorePath}"
tar -xjvf "${backupFile}" -C "${restorePath}" --strip-components=1 "${file}" tar -xjvf "${backupFile}" -C "${restorePath}" --strip-components=1 "${file}"
# shellcheck disable=SC2181
if [ $? == 0 ] ; then if [ $? == 0 ] ; then
echo -e "${NORMAL}\e[68G[ ${GREEN}OK${NORMAL} ]" echo -e "${NORMAL}\e[68G[ ${GREEN}OK${NORMAL} ]"
else else
@ -3606,7 +3625,7 @@ doPrintConfig(){
for cfgfile in "$configfile" "${HOME}/${arkstUserCfgFile}" "${arkstGlobalCfgFile}"; do for cfgfile in "$configfile" "${HOME}/${arkstUserCfgFile}" "${arkstGlobalCfgFile}"; do
if [ -r "$cfgfile" ]; then if [ -r "$cfgfile" ]; then
while read -r v; do while read -r v; do
# shellcheck source=arkmanager.cfg,instance.cfg.example # shellcheck source=arkmanager.cfg.shellcheck
val="$(source "$cfgfile"; echo "${!v}")" val="$(source "$cfgfile"; echo "${!v}")"
if [[ "$val" = "${vals[$v]}" && -z "${vars[$v]}" ]]; then if [[ "$val" = "${vals[$v]}" && -z "${vars[$v]}" ]]; then
vars["$v"]="$cfgfile" vars["$v"]="$cfgfile"
@ -3620,17 +3639,17 @@ doPrintConfig(){
doTestConfig(){ doTestConfig(){
set -e set -e
if [ -r "${arkstGlobalCfgFile}" ]; then if [ -r "${arkstGlobalCfgFile}" ]; then
# shellcheck source=arkmanager.cfg # shellcheck source=arkmanager.cfg.shellcheck
source "${arkstGlobalCfgFile}" source "${arkstGlobalCfgFile}"
fi fi
if [ -r "${HOME}/${arkstUserCfgFile}" ]; then if [ -r "${HOME}/${arkstUserCfgFile}" ]; then
# shellcheck source=arkmanager.cfg # shellcheck source=arkmanager.cfg.shellcheck
source "${HOME}/${arkstUserCfgFile}" source "${HOME}/${arkstUserCfgFile}"
fi fi
if [ -r "$configfile" ]; then if [ -r "$configfile" ]; then
# shellcheck source=instance.cfg.example # shellcheck source=arkmanager.cfg.shellcheck
source "$configfile" source "$configfile"
fi fi
@ -3673,7 +3692,7 @@ useConfig() {
echo "Error: config file $configfile does not exist" echo "Error: config file $configfile does not exist"
exit 1 exit 1
fi fi
# shellcheck source=instance.cfg.example # shellcheck source=arkmanager.cfg.shellcheck
source "$configfile" source "$configfile"
fi fi
if [ -z "$arkserverroot" ]; then if [ -z "$arkserverroot" ]; then
@ -3822,12 +3841,12 @@ EOE
main(){ main(){
if [ -f "${arkstGlobalCfgFile}" ]; then if [ -f "${arkstGlobalCfgFile}" ]; then
# shellcheck source=arkmanager.cfg # shellcheck source=arkmanager.cfg.shellcheck
source "${arkstGlobalCfgFile}" source "${arkstGlobalCfgFile}"
fi fi
if [ -f "${HOME}/${arkstUserCfgFile}" ]; then if [ -f "${HOME}/${arkstUserCfgFile}" ]; then
# shellcheck source=arkmanager.cfg # shellcheck source=arkmanager.cfg.shellcheck
source "${HOME}/${arkstUserCfgFile}" source "${HOME}/${arkstUserCfgFile}"
fi fi
@ -3860,6 +3879,7 @@ main(){
continue continue
;; ;;
--cronjob) --cronjob)
# shellcheck disable=SC2034
inCronJob=true inCronJob=true
continue continue
;; ;;
@ -4014,6 +4034,7 @@ main(){
# Handle all instances being requested # Handle all instances being requested
if [[ "$allinstances" == "yes" ]]; then if [[ "$allinstances" == "yes" ]]; then
# shellcheck disable=SC2207
instances=( $(getAllInstanceNames) ) instances=( $(getAllInstanceNames) )
fi fi

View File

@ -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 (<fileid> in http://steamcommunity.com/sharedfiles/filedetails/?id=<fileid>) - alternative to above ${serverMap}
serverMapModId="469987622"
## ARK server common options - use ark_<optionname>=<value>
## 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_<optionname>=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 (<fileid> in http://steamcommunity.com/sharedfiles/filedetails/?id=<fileid>) - 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_<optionname>=<value>
## 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_<optionname>=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

View File

@ -93,12 +93,12 @@ while [ -n "$1" ]; do
shift shift
done done
if [ "$userinstall" == "yes" -a "$UID" -eq 0 ]; then if [ "$userinstall" == "yes" ] && [ "$UID" -eq 0 ]; then
echo "Refusing to perform user-install as root" echo "Refusing to perform user-install as root"
showusage=yes showusage=yes
fi fi
if [ "$showusage" == "no" -a -z "$steamcmd_user" ]; then if [ "$showusage" == "no" ] && [ -z "$steamcmd_user" ]; then
echo "No user specified" echo "No user specified"
showusage=yes showusage=yes
fi fi
@ -245,7 +245,7 @@ else
chmod +x "${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" sed -i "s|^DAEMON=\"/usr/bin/|DAEMON=\"${BINDIR}/|" "${INSTALL_ROOT}/etc/init.d/arkmanager"
# add to startup if the system use sysinit # 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 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 "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" echo "update-rc.d -f arkmanager remove"
@ -272,7 +272,7 @@ else
cp redhat/arkdaemon "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager" cp redhat/arkdaemon "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager"
chmod +x "${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" 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 chkconfig --add arkmanager
echo "Ark server will now start on boot, if you want to remove this feature run the following line" echo "Ark server will now start on boot, if you want to remove this feature run the following line"
echo "chkconfig arkmanager off" echo "chkconfig arkmanager off"
@ -282,7 +282,7 @@ else
cp openrc/arkdaemon "${INSTALL_ROOT}/etc/init.d/arkmanager" cp openrc/arkdaemon "${INSTALL_ROOT}/etc/init.d/arkmanager"
chmod +x "${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" 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 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 "Ark server will now start on boot, if you want to remove this feature run the following line"
echo "rc-update del arkmanager default" echo "rc-update del arkmanager default"

View File

@ -14,10 +14,11 @@
. /lib/lsb/init-functions . /lib/lsb/init-functions
# Global variables # Global variables
# shellcheck source=../arkmanager.cfg
source /etc/arkmanager/arkmanager.cfg source /etc/arkmanager/arkmanager.cfg
NAME="ShooterGameServer" NAME="ShooterGameServer"
LOGFILE="${logdir}/${NAME}.log" #LOGFILE="${logdir}/${NAME}.log"
DAEMON="/usr/bin/arkmanager" DAEMON="/usr/bin/arkmanager"
SVCNAME="${0##*/}" SVCNAME="${0##*/}"
@ -59,12 +60,12 @@ function start_instance(){
function start_all_instances(){ function start_all_instances(){
local nosuccess=0 local nosuccess=0
local anyfailure=0 #local anyfailure=0
for instance in $("${DAEMON}" list-instances --brief); do for instance in $("${DAEMON}" list-instances --brief); do
if start_instance "$instance"; then if start_instance "$instance"; then
nosuccess=0 nosuccess=0
else #else
anyfailure=1 # anyfailure=1
fi fi
done done

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
# shellcheck disable=SC2034
configfile="$1" configfile="$1"
newopts=( arkbackupdir arkautorestartfile install_bindir install_libexecdir install_datadir mod_appid ) newopts=( arkbackupdir arkautorestartfile install_bindir install_libexecdir install_datadir mod_appid )

View File

@ -24,10 +24,11 @@
. /etc/rc.d/init.d/functions . /etc/rc.d/init.d/functions
# Global variables # Global variables
# shellcheck source=../arkmanager.cfg
source /etc/arkmanager/arkmanager.cfg source /etc/arkmanager/arkmanager.cfg
NAME="ShooterGameServer" NAME="ShooterGameServer"
LOGFILE="${logdir}/${NAME}.log" #LOGFILE="${logdir}/${NAME}.log"
DAEMON="/usr/bin/arkmanager" DAEMON="/usr/bin/arkmanager"
GREEN="\\033[1;32m" GREEN="\\033[1;32m"
@ -74,12 +75,12 @@ function start_instance(){
function start_all_instances(){ function start_all_instances(){
local nosuccess=0 local nosuccess=0
local anyfailure=0 #local anyfailure=0
for instance in $("${DAEMON}" list-instances --brief); do for instance in $("${DAEMON}" list-instances --brief); do
if start_instance "$instance"; then if start_instance "$instance"; then
nosuccess=0 nosuccess=0
else #else
anyfailure=1 # anyfailure=1
fi fi
done done

View File

@ -3,6 +3,7 @@
# uninstall.sh # uninstall.sh
BINDIR="/usr/bin" BINDIR="/usr/bin"
# shellcheck disable=SC2034
DATADIR="/usr/share/arkmanager" DATADIR="/usr/share/arkmanager"
LIBEXECDIR="/usr/libexec/arkmanager" LIBEXECDIR="/usr/libexec/arkmanager"
INITSCRIPT= INITSCRIPT=