diff --git a/.gitignore b/.gitignore index cec92f6..ba17baf 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 # User-specific stuff: +.env .idea/**/workspace.xml .idea/**/tasks.xml .idea/dictionaries diff --git a/.vscode/settings.json b/.vscode/settings.json index bfba6c1..34b4c21 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,18 @@ { "cSpell.words": [ - "arkmanager" - ] + "arkmanager", + "BATTLEYE", + "cifs", + "CROSSPLAY", + "fjordur", + "healthcheck", + "RCON", + "theisland" + ], + "gitlens.autolinks": [ + { + "prefix": "#", + "url": "https://github.com/fossum/ark-cluster/issues/" + } + ], } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a122c07..d07a722 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,7 +6,7 @@ { "label": "Build Image", "type": "shell", - "command": "docker build -t ark-cluster .", + "command": "docker build -t fossum/ark-cluster:dev .", "problemMatcher": [], "group": { "kind": "build", @@ -16,7 +16,13 @@ { "label": "Run Image", "type": "shell", - "command": "docker stop ark; docker rm ark; docker run -v ${pwd}/ark:/ark -p 7777:7777/udp -p 7778:7778/udp -p 32330:32330 -p 27015:27015/udp -e SESSIONNAME=myserver -e ADMINPASSWORD=\"mypasswordadmin\" --name ark ark-cluster" + "command": "docker stop ark; docker rm ark; docker run -v ${pwd}/ark:/ark -p 7777:7777/udp -p 7778:7778/udp -p 32330:32330 -p 27015:27015/udp -e SESSIONNAME=myserver -e ADMINPASSWORD=\"mypasswordadmin\" --name ark fossum/ark-cluster:dev" + }, + { + "label": "Push Dev Image", + "type": "shell", + "command": "docker push fossum/ark-cluster:dev", + "problemMatcher": [] } ] } \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index fff6b11..3b98945 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ ENV CRON_AUTO_UPDATE="0 */3 * * *" \ GROUP_ID=1000 \ TZ=UTC \ MAX_BACKUP_SIZE=500 \ - SERVERMAP="TheIsland" \ + SERVER_MAP="TheIsland" \ SESSION_NAME="ARK Cluster" \ MAX_PLAYERS=20 \ RCON_ENABLE="True" \ @@ -36,7 +36,8 @@ ENV CRON_AUTO_UPDATE="0 */3 * * *" \ CLUSTER_ID="" \ KILL_PROCESS_TIMEOUT=300 \ KILL_ALL_PROCESSES_TIMEOUT=300 \ - TOOLS_GIT_REF="" + TOOLS_GIT_REF="" \ + ARK_SERVER_VOLUME="/ark" # Install Ark Server Tools # Get tag version or master. @@ -63,9 +64,14 @@ RUN mkdir -p /ark \ COPY crontab /home/steam/crontab -# Setup run script +# Add run and user scripts +COPY shared.sh /shared.sh +RUN chmod +x /shared.sh COPY run.sh /run.sh RUN chmod +x /run.sh +COPY user-space.sh /user-space.sh +RUN chmod +x /user-space.sh +COPY arkmanager-completion.bash /etc/bash_completion.d/arkmanager-completion.bash # Skip expose, not all servers will use the same ports. VOLUME /ark /cluster diff --git a/README.md b/README.md index e82f6c9..751ce9b 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ For example : After updating the `/my/path/to/ark/crontab` please run the command `docker exec ark crontab -u steam /ark/crontab` -To add mods, you only need to change the variable ark_GameModIds in *arkmanager.cfg* with a list of your modIds (like this `ark_GameModIds="987654321,1234568"`). If UPDATEONSTART is enable, just restart your docker or use `docker exec ark arkmanager update --update-mods`. +To add mods, you only need to change the variable ark_GameModIds in *arkmanager.cfg* with a list of your modIds (like this `ark_GameModIds="987654321,1234568"`). If UPDATE_ON_START is enabled, just restart your docker or use `docker exec ark arkmanager update --update-mods`. ## Recommended Usages @@ -109,19 +109,19 @@ To add mods, you only need to change the variable ark_GameModIds in *arkmanager. ## Variables - __SESSIONNAME__: Name of your ark server (default: "Ark Docker") -- __SERVERMAP__: Map of your ark server (default: "TheIsland") -- __SERVERPASSWORD__: Password of your ark server (default: "") -- __ADMINPASSWORD__: Admin password of your ark server (default: "adminpassword") -- __SERVERPORT__: Ark server port (can't rebind with docker, it doesn't work) (default: 27015) -- __STEAMPORT__: Steam server port (can't rebind with docker, it doesn't work) (default: 7778) +- __SERVER_MAP__: Map of your ark server (default: "TheIsland") +- __SERVER_PASSWORD__: Password of your ark server (default: "") +- __ADMIN_PASSWORD__: Admin password of your ark server (default: "adminpassword") +- __SERVER_PORT__: Ark server port (can't rebind with docker, it doesn't work) (default: 27015) +- __STEAM_PORT__: Steam server port (can't rebind with docker, it doesn't work) (default: 7778) - __MAX_PLAYERS__: Number of maximum players (default: 70) -- __BACKUPONSTART__: Backup the server when the container is started. 0: no backup (default: 1) -- __UPDATEPONSTART__: Update the server when the container is started. 0: no update (default: 1) -- __BACKUPONSTOP__: Backup the server when the container is stopped. 0: no backup (default: 1) -- __WARNONSTOP__: Warn the players before the container is stopped. 0: no warning (default: 1) +- __BACKUP_ON_START__: Backup the server when the container is started. 0: no backup (default: 1) +- __UPDATE_ON_START__: Update the server when the container is started. 0: no update (default: 1) +- __BACKUP_ON_STOP__: Backup the server when the container is stopped. 0: no backup (default: 1) +- __WARN_ON_STOP__: Warn the players before the container is stopped. 0: no warning (default: 1) - __TZ__: container timezone (for crontab). (default: "UTC"). -- __UID__: UID of the user used. Owner of the volume /ark (default: 1000) -- __GID__: GID of the user used. Owner of the volume /ark (default: 1000) +- __USER_ID__: UID of the user used. Owner of the volume /ark (default: 1000) +- __GROUP_ID__: GID of the user used. Owner of the volume /ark (default: 1000) ## Volumes diff --git a/arkmanager-completion.bash b/arkmanager-completion.bash new file mode 100644 index 0000000..b398e2f --- /dev/null +++ b/arkmanager-completion.bash @@ -0,0 +1,3 @@ +#/usr/bin/env bash + +complete -W "upgrade-tools uninstall-tools useconfig remove-mods list-instances Command backup restore broadcast saveworld rconcmd checkupdate checkmodupdate install installmod uninstallmod reinstallmod enablemod disablemod installmods uninstallmods install-cronjob remove-cronjob restart run start stop cancelshutdown status printconfig getpid update" arkmanager diff --git a/arkmanager-user.cfg b/arkmanager-user.cfg index b03f9cf..7dd6548 100644 --- a/arkmanager-user.cfg +++ b/arkmanager-user.cfg @@ -1,13 +1,13 @@ # ARK server options - use ark_= # comment out these values if you want to define them # inside your GameUserSettings.ini file -serverMap="${SERVERMAP:=TheIsland}" # server map (default TheIsland) +serverMap="${SERVER_MAP:=TheIsland}" # server map (default TheIsland) #serverMapModId="469987622" # Uncomment this to specify the Map Mod Id ( in http://steamcommunity.com/sharedfiles/filedetails/?id=) #ark_TotalConversionMod="496735411" # Uncomment this to specify a total-conversion mod ark_RCONEnabled="${RCON_ENABLE:=false}" # Enable RCON Protocol -ark_RCONPort="${RCON_PORT:=32330}" # RCON Port +ark_RCONPort="${RCON_PORT:=27020}" # RCON Port ark_SessionName="${SESSION_NAME:=ARK Docker}" # if your session name needs special characters please use the .ini instead -ark_Port="${GAME_PORT:=7778}" # ARK server port (default 7777) +ark_Port="${GAME_PORT:=7777}" # ARK server port (default 7777) ark_QueryPort="${QUERY_PORT:=27015}" # ARK query port (default 27015) ark_ServerPassword="${SERVER_PASSWORD}" # ARK server password, empty: no password required to login ark_ServerAdminPassword="${ADMIN_PASSWORD}" # ARK server admin password, KEEP IT SAFE! diff --git a/docker-compose.yml b/docker-compose.yml index 02f1f12..2d44766 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,6 +4,14 @@ version: "3.5" services: theisland: image: fossum/ark-cluster:master + + # healthcheck: + # test: arkmanager status | grep 'Server listening:.\+No' && exit 1 + # interval: 60s + # retries: 5 + # start_period: 600s + # timeout: 10s + deploy: restart_policy: condition: on-failure @@ -22,14 +30,14 @@ services: failure_action: rollback environment: - SERVERMAP: "TheIsland" + SERVER_MAP: "TheIsland" SESSION_NAME: "ARK Cluster TheIsland" CRON_AUTO_UPDATE: ${CRON_AUTO_UPDATE:-0 */3 * * *} CRON_AUTO_BACKUP: ${CRON_AUTO_BACKUP:-0 */1 * * *} - UPDATEONSTART: ${UPDATEONSTART:-1} - BACKUPONSTART: ${BACKUPONSTART:-1} - BACKUPONSTOP: ${BACKUPONSTOP:-1} - WARNONSTOP: ${WARNONSTOP:-1} + UPDATE_ON_START: ${UPDATEONSTART:-1} + BACKUP_ON_START: ${BACKUPONSTART:-1} + BACKUP_ON_STOP: ${BACKUPONSTOP:-1} + WARN_ON_STOP: ${WARNONSTOP:-1} USER_ID: ${USER_ID:-1000} GROUP_ID: ${GROUP_ID:-1000} TZ: ${TZ:-UTC} @@ -76,7 +84,7 @@ services: order: stop-first failure_action: rollback environment: - SERVERMAP: "Valguero_P" + SERVER_MAP: "Valguero_P" SESSION_NAME: "ARK Cluster" RCON_PORT: ${RCON_PORT:-32331} GAME_PORT: ${GAME_PORT:-7779} diff --git a/personal-stack.yml b/personal-stack.yml new file mode 100644 index 0000000..1a6147a --- /dev/null +++ b/personal-stack.yml @@ -0,0 +1,144 @@ +version: "3.5" + +services: + theisland: + image: fossum/ark-cluster:dev + # healthcheck: + # test: arkmanager status | grep 'Server listening:.\+No' && exit 1 + # interval: 60s + # retries: 5 + # start_period: 600s + # timeout: 10s + deploy: + restart_policy: + condition: on-failure + delay: 15s + max_attempts: 2 + window: 600s + mode: replicated + replicas: 1 + resources: + reservations: + memory: 8gb + update_config: + parallelism: 1 + delay: 30s + order: stop-first + failure_action: rollback + placement: + constraints: + - node.hostname==dockers + volumes: + # - theisland:/ark + - type: bind + source: /mnt/nfs/ark/theisland + target: /ark + - cluster:/cluster + environment: + SERVER_MAP: TheIsland + SESSION_NAME: Venture Bros (TheIsland) + TZ: ${TIME_ZONE} + SERVER_PASSWORD: ${SERVER_PASSWORD} + ADMIN_PASSWORD: ${ADMIN_PASSWORD} + MAX_PLAYERS: ${MAX_PLAYERS} + UPDATE_ON_START: ${UPDATE_ON_START} + BACKUP_ON_STOP: ${BACKUP_ON_STOP} + PRE_UPDATE_BACKUP: ${PRE_UPDATE_BACKUP} + WARN_ON_STOP: ${WARN_ON_STOP} + ENABLE_CROSSPLAY: ${ENABLE_CROSSPLAY} + DISABLE_BATTLEYE: ${DISABLE_BATTLEYE} + GAME_MOD_IDS: ${GAME_MOD_IDS} + CLUSTER_ID: ${CLUSTER_ID} + GAME_PORT: 7777 + QUERY_PORT: 27015 + RCON_PORT: 27020 + BACKUP_TO_LOAD: backup/main.2023-03-01_20.08.36.tar.bz2 + ports: + - "7777:7777/udp" + - "7778:7778/udp" + - "27015:27015/udp" + - "27020:27020/tcp" + # fjordur: + # image: fossum/ark-cluster:dev + # # entrypoint: /bin/bash + # # command: -c "tail -F anything" + # # healthcheck: + # # test: arkmanager status | grep 'Server listening:.\+No' && exit 1 + # # interval: 60s + # # retries: 5 + # # start_period: 600s + # # timeout: 10s + # deploy: + # restart_policy: + # condition: on-failure + # delay: 15s + # max_attempts: 3 + # window: 600s + # mode: replicated + # replicas: 1 + # resources: + # reservations: + # memory: 8gb + # update_config: + # parallelism: 1 + # delay: 30s + # order: stop-first + # failure_action: rollback + # placement: + # constraints: + # - node.hostname==dockers + # environment: + # SERVER_MAP: Fjordur + # SESSION_NAME: Venture Bros (Fjordur) + # TZ: ${TIME_ZONE} + # SERVER_PASSWORD: ${SERVER_PASSWORD} + # ADMIN_PASSWORD: ${ADMIN_PASSWORD} + # MAX_PLAYERS: ${MAX_PLAYERS} + # UPDATE_ON_START: ${UPDATE_ON_START} + # BACKUP_ON_STOP: ${BACKUP_ON_STOP} + # PRE_UPDATE_BACKUP: ${PRE_UPDATE_BACKUP} + # WARN_ON_STOP: ${WARN_ON_STOP} + # ENABLE_CROSSPLAY: ${ENABLE_CROSSPLAY} + # DISABLE_BATTLEYE: ${DISABLE_BATTLEYE} + # GAME_MOD_IDS: ${GAME_MOD_IDS} + # CLUSTER_ID: ${CLUSTER_ID} + # GAME_PORT: 7780 + # QUERY_PORT: 27016 + # RCON_PORT: 27021 + # ports: + # - "7780:7780/udp" + # - "7781:7781/udp" + # - "27016:27016/udp" + # - "27021:27021/tcp" + # volumes: + # - fjordur:/ark + # - cluster:/cluster + +volumes: + # theisland: + # driver: local + # driver_opts: + # type: "nfs" + # o: "addr=truenas.thefoss.org,nolock,rw,nfsvers=4,sync,noatime,tcp" + # device: ":/mnt/no-backup/games/ark/theisland" + # # type: "cifs" + # # o: "addr=truenas.thefoss.org,username=${CIFS_USER},password=${CIFS_PASS},file_mode=0777,dir_mode=0777" + # # device: "//truenas.thefoss.org/ark/theisland" + # fjordur: + # driver: local + # driver_opts: + # #type: "nfs" + # #o: "addr=truenas.thefoss.org,nolock,rw,nfsvers=4,async,noatime,rsize=8192,wsize=8192,tcp,timeo=14" + # #device: ":/mnt/no-backup/games/ark/fjordur" + # type: "cifs" + # o: "addr=truenas.thefoss.org,username=${CIFS_USER},password=${CIFS_PASS},file_mode=0777,dir_mode=0777" + # device: "//truenas.thefoss.org/ark/fjordur" + cluster: + driver: local + driver_opts: + type: "nfs" + o: "addr=truenas.thefoss.org,nolock,rw,nfsvers=4,sync,noatime,tcp" + device: ":/mnt/no-backup/games/ark/cluster" + # type: "cifs" + # o: "addr=truenas.thefoss.org,username=${CIFS_USER},password=${CIFS_PASS},file_mode=0777,dir_mode=0777" + # device: "//truenas.thefoss.org/ark/cluster" diff --git a/run.sh b/run.sh index 8e5ee9d..dad08a8 100644 --- a/run.sh +++ b/run.sh @@ -1,24 +1,6 @@ #!/usr/bin/env bash -function log { echo "`date +\"%Y-%m-%dT%H:%M:%SZ\"`: $@"; } -function warn { >&2 echo "`date +\"%Y-%m-%dT%H:%M:%SZ\"`: $@"; } - -log "###########################################################################" -log "# Started - `date`" -log "# Server - ${SESSION_NAME} (${SERVERMAP})" -log "# Cluster - ${CLUSTER_ID}" -log "# User - ${USER_ID}" -log "# Group - ${GROUP_ID}" -log "###########################################################################" -[ -p /tmp/FIFO ] && rm /tmp/FIFO -mkfifo /tmp/FIFO - -export TERM=linux - -function error { - log "$1" - exit 1 -} +. /shared.sh function stop { if [ ${BACKUPONSTOP} -eq 1 ] && [ "$(ls -A /ark/server/ShooterGame/Saved/SavedArks)" ]; then @@ -30,65 +12,97 @@ function stop { else arkmanager stop fi - exit + exit 0 } function verify_dir { + # Must be used after steam UID/GID set. + local dir="$1" if [ ! -d $dir ]; then - mkdir -p $dir || error "Could not create $dir directory." + su -c "mkdir -p $dir" steam || error "Could not create $dir directory." fi + # Put steam owner of directories (if the uid changed, then it's needed) - chown -R steam:steam $dir || error "Could not set $dir permissions." + owner_id="$(stat --format '%u' "$dir")" + group_id="$(stat --format '%g' "$dir")" + if [ "${owner_id}" != "${USER_ID}" ] || [ "${group_id}" != "${GROUP_ID}" ]; then + chown -R $USER_ID:$GROUP_ID $dir + #chmod -R 777 $dir || error "Could not set $dir permissions." + fi + + # Verify user can modify files. + # Some file systems may not show user change. + owner_id="$(stat --format '%u' "$dir")" + if [ "${owner_id}" != "${USER_ID}" ]; then + su -c "touch '$dir/test_file'" steam || error "Could get permission for $dir" + su -c "rm '$dir/test_file'" steam || error "Could get permission for $dir" + log "$dir is not owned by steam user, but is writable." + fi } +log "###########################################################################" +log "# Started - `date`" +log "# Server - ${SESSION_NAME} (${SERVER_MAP})" +log "# Cluster - ${CLUSTER_ID}" +log "# User - ${USER_ID}" +log "# Group - ${GROUP_ID}" +log "###########################################################################" + +[ -p /tmp/FIFO ] && rm /tmp/FIFO +mkfifo /tmp/FIFO + +export TERM=linux + ######################## # -# System Setup +log "System Setup" # ######################## +if [ -f /usr/share/zoneinfo/${TZ} ]; then + log "Setting timezone to ${TZ} ..." + ln -sf "/usr/share/zoneinfo/${TZ}" /etc/localtime +else + warn "Timezone '${TZ}' does not exist!" +fi + # Change the USER_ID if needed if [ ! "$(id -u steam)" -eq "$USER_ID" ]; then log "Changing steam uid to $USER_ID." - usermod -o -u "$USER_ID" steam ; + usermod -o -u "$USER_ID" steam fi -# Change gid if needed + +# Change the GROUP_ID if needed if [ ! "$(id -g steam)" -eq "$GROUP_ID" ]; then log "Changing steam gid to $GROUP_ID." - groupmod -o -g "$GROUP_ID" steam ; -fi - -if [ -f /usr/share/zoneinfo/${TZ} ]; then - log "Setting timezone to ${TZ} ..." - ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime -else - warn "Timezone '${TZ}' does not exist!" + groupmod -o -g "$GROUP_ID" steam fi ######################## # -# File Setup +log "File Setup" # ######################## -# Add a template directory to store the last version of config file verify_dir /ark verify_dir /ark/backup verify_dir /ark/log +verify_dir /ark/server +# verify_dir /ark/server/ShooterGame/Binaries/Linux +# verify_dir /ark/server/ShooterGame/Content/Mods +# verify_dir /ark/server/ShooterGame/Saved/SavedArks verify_dir /ark/staging verify_dir /ark/template verify_dir /cluster -verify_dir /home/steam verify_dir /etc/arkmanager +verify_dir /home/steam -# Create custom config if not set, use custom config -[ ! -f /ark/arkmanager.cfg ] && cp /etc/arkmanager/instances/main.cfg /ark/arkmanager.cfg || warn "Could not save default config file." -cp /ark/arkmanager.cfg /etc/arkmanager/instances/main.cfg || warn "Could not save main instance config file." +#chmod -R 777 /ark/server || log ">>> Could not set /ark/server permissions." ######################## # -# CRON Setup +log "CRON Setup" # ######################## @@ -107,40 +121,14 @@ if [ ! -f /etc/cron.d/arkbackup ]; then fi log "###########################################################################" -if [ ! -f /ark/server/ShooterGame/Binaries/Linux/ShooterGameServer ] || [ ! -f /ark/server/version.txt ]; then - warn "No game files found. Installing..." - export free_space=$(df -Pk . | sed 1d | grep -v used | awk '{ print $4 }') - [ $free_space -gt 20000000 ] || warn "Only $free_space bytes available. Installation may fail." - verify_dir /ark/server/ShooterGame/Saved/SavedArks - verify_dir /ark/server/ShooterGame/Content/Mods - verify_dir /ark/server/ShooterGame/Binaries/Linux - touch /ark/server/ShooterGame/Binaries/Linux/ShooterGameServer - verify_dir /ark/server - arkmanager install || error "Could not install game files." -else - if [ ${BACKUPONSTART} -eq 1 ] && [ "$(ls -A /ark/server/ShooterGame/Saved/SavedArks/)" ]; then - log "Creating Backup ..." - arkmanager backup || warn "Could not create backup." - fi -fi +# Add bash complete for arkmanager +# cp /home/steam/arkmanager-complete.bash /etc/bash_completion.d/ +# source /home/steam/arkmanager-complete.bash -log "###########################################################################" -log "Installing Mods ..." -arkmanager installmods || error "Could not install mods." - -log "###########################################################################" -log "Launching ark server ..." -if [ ${UPDATEONSTART} -eq 1 ]; then - arkmanager start || error "Could not start server." -else - arkmanager start -noautoupdate || error "Could not start server." -fi - -# Stop server in case of signal INT or TERM -log "###########################################################################" -log "Running ... (waiting for INT/TERM signal)" -trap stop INT -trap stop TERM +######################## +# +log "Dropping to steam User Space" +# +######################## -read < /tmp/FIFO & -wait +su steam -c "bash /user-space.sh" diff --git a/shared.sh b/shared.sh new file mode 100644 index 0000000..33d6982 --- /dev/null +++ b/shared.sh @@ -0,0 +1,8 @@ + +function log { echo "`date +\"%Y-%m-%dT%H:%M:%SZ\"`: $@"; } +function warn { >&2 echo "`date +\"%Y-%m-%dT%H:%M:%SZ\"`: $@"; } + +function error { + log "!!! $1" + exit 1 +} diff --git a/user-space.sh b/user-space.sh new file mode 100644 index 0000000..021add0 --- /dev/null +++ b/user-space.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +. /shared.sh + +function verify_dir { + # This user space version does not set permissions. + + local dir="$1" + if [ ! -d $dir ]; then + mkdir -p $dir || error "Could not create $dir directory." + fi +} + +# Add bash complete for arkmanager +source /etc/bash_completion.d/arkmanager-completion.bash + +# Create custom config if not set, use custom config +if [ ! -f /ark/arkmanager.cfg ]; then + cp /etc/arkmanager/instances/main.cfg /ark/arkmanager.cfg || warn "Could not save default config file." +fi +cp /ark/arkmanager.cfg /etc/arkmanager/instances/main.cfg || warn "Could not save main instance config file." + +if [ ! -f /ark/server/ShooterGame/Binaries/Linux/ShooterGameServer ] || [ ! -f /ark/server/version.txt ]; then + warn "No game files found. Installing..." + arkmanager install || error "Could not install game files." +else + if [ ${BACKUP_ON_STOP} -eq 1 ] && [ "$(ls -A /ark/server/ShooterGame/Saved/SavedArks/)" ]; then + log "Creating Backup ..." + arkmanager backup || warn "Could not create backup." + fi +fi + +log "###########################################################################" +log "Installing Mods ..." +arkmanager installmods || error "Could not install mods." + +if [ "${BACKUP_TO_LOAD}" != "" ]; then + log "Restoring from backup..." + arkmanager restore "/ark/${BACKUP_TO_LOAD}" +fi + +log "###########################################################################" +log "Launching ark server ..." +if [ ${UPDATE_ON_START} -eq 1 ]; then + arkmanager start || error "Could not start server." +else + arkmanager start -noautoupdate || error "Could not start server." +fi + +# Stop server in case of signal INT or TERM +log "###########################################################################" +log "Running ... (waiting for INT/TERM signal)" +trap stop INT +trap stop TERM + +read < /tmp/FIFO & +wait