Skip to content

Commit

Permalink
Move shared functions to importable file.
Browse files Browse the repository at this point in the history
Fix combination boolean logic.
  • Loading branch information
ericfoss-sel committed Mar 2, 2023
1 parent 838b0fa commit 196b0d1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ RUN mkdir -p /ark \
COPY crontab /home/steam/crontab

# 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
Expand Down
12 changes: 4 additions & 8 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,12 +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\"`: $@"; }

function error {
log "!!! $1"
exit 1
}
. /shared.sh

function stop {
if [ ${BACKUPONSTOP} -eq 1 ] && [ "$(ls -A /ark/server/ShooterGame/Saved/SavedArks)" ]; then
Expand Down Expand Up @@ -98,7 +92,9 @@ verify_dir /etc/arkmanager
verify_dir /home/steam

# Create custom config if not set, use custom config
[ ! -f /ark/arkmanager.cfg ] && su steam -c "cp /etc/arkmanager/instances/main.cfg /ark/arkmanager.cfg" || warn "Could not save default config file."
if [ ! -f /ark/arkmanager.cfg ]; then
su steam -c "cp /etc/arkmanager/instances/main.cfg /ark/arkmanager.cfg" || warn "Could not save default config file."
fi
su steam -c "cp /ark/arkmanager.cfg /etc/arkmanager/instances/main.cfg" || warn "Could not save main instance config file."

########################
Expand Down
8 changes: 8 additions & 0 deletions shared.sh
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 2 additions & 4 deletions user-space.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/usr/bin/env bash

# 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."
. /shared.sh

if [ ! -f /ark/server/ShooterGame/Binaries/Linux/ShooterGameServer ] || [ ! -f /ark/server/version.txt ]; then
warn "No game files found. Installing..."
# touch /ark/server/ShooterGame/Binaries/Linux/ShooterGameServer
arkmanager install || error "Could not install game files."
else
if [ ${BACKUPONSTART} -eq 1 ] && [ "$(ls -A /ark/server/ShooterGame/Saved/SavedArks/)" ]; then
Expand Down

0 comments on commit 196b0d1

Please sign in to comment.