Skip to content

Commit

Permalink
update entrypoint.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusraupach committed Jan 7, 2025
1 parent 13774a8 commit c494f4b
Showing 1 changed file with 37 additions and 62 deletions.
99 changes: 37 additions & 62 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#!/bin/bash

: "${NAME:="My Server"}"

# : "${PORT:=2456}"

: "${PORT:=""}"
: "${WORLD:="Dedicated"}"
: "${PASSWORD:="Secret"}"
: "${SAVEDIR:=""}"
: "${PUBLIC:=}"
: "${SAVEDIR:="/home/steam/Valheim"}"
: "${PUBLIC:=""}"
: "${LOG_FILE:=""}"
: "${SAVEINTERVAL:=}"
: "${BACKUPS:=}"
: "${BACKUPSHORT:=}"
: "${BACKUPLONG:=}"
: "${CROSSPLAY:=false}"
: "${SAVEINTERVAL:=""}"
: "${BACKUPS:=""}"
: "${BACKUPSHORT:=""}"
: "${BACKUPLONG:=""}"
: "${CROSSPLAY:="false"}"
: "${INSTANCEID:=""}"

# PRESET="${PRESET:-""}"
Expand All @@ -25,12 +23,18 @@
# SETKEY="${SETKEY:-""}"

function start() {
local ARGS=()

while [[ $# -gt 0 ]]; do
case "$1" in
--name)
NAME="$2"
shift 2
;;
--port)
PORT="$2"
shift 2
;;
--world)
WORLD="$2"
shift 2
Expand Down Expand Up @@ -82,61 +86,32 @@ function start() {
esac
done

ARGS=()

ARGS+=("-batchmode" "-nographics")

if [[ -n "$NAME" ]]; then
ARGS+=("-name" "$NAME")
fi

if [[ -n "$WORLD" ]]; then
ARGS+=("-world" "$WORLD")
fi

if [[ -n "$PASSWORD" ]]; then
ARGS+=("-password" "$PASSWORD")
fi

if [[ -n "$SAVEDIR" ]]; then
ARGS+=("-savedir" "$SAVEDIR")
fi

if [[ -n "$PUBLIC" ]]; then
ARGS+=("-public" "$PUBLIC")
fi

if [[ -n "$LOG_FILE" ]]; then
ARGS+=("-logfile" "$LOG_FILE")
fi

if [[ -n "$BACKUPS" ]]; then
ARGS+=("-backups" "$BACKUPS")
fi

if [[ -n "$BACKUPSHORT" ]]; then
ARGS+=("-backupshort" "$BACKUPSHORT")
fi

if [[ -n "$BACKUPLONG" ]]; then
ARGS+=("-backuplong" "$BACKUPLONG")
[[ -n "$NAME" ]] && ARGS+=("-name" "${NAME}")
[[ -n "$PORT" ]] && ARGS+=("-port" "${PORT}")
[[ -n "$WORLD" ]] && ARGS+=("-world" "${WORLD}")
[[ -n "$PASSWORD" ]] && ARGS+=("-password" "${PASSWORD}")
[[ -n "$SAVEDIR" ]] && ARGS+=("-savedir" "${SAVEDIR}")
[[ -n "$PUBLIC" ]] && ARGS+=("-public" "${PUBLIC}")
[[ -n "$LOG_FILE" ]] && ARGS+=("-logfile" "${LOG_FILE}")
[[ -n "$BACKUPS" ]] && ARGS+=("-backups" "${BACKUPS}")
[[ -n "$BACKUPSHORT" ]] && ARGS+=("-backupshort" "${BACKUPSHORT}")
[[ -n "$BACKUPLONG" ]] && ARGS+=("-backuplong" "${BACKUPLONG}")
[[ "$CROSSPLAY" == "true" ]] && ARGS+=("-crossplay")
[[ -n "$INSTANCEID" ]] && ARGS+=("-instanceid" "${INSTANCEID}")

if ! cd /home/steam/valheim-dedicated-server; then
exit 1
fi

if [[ "$CROSSPLAY" == "true" ]]; then
ARGS+=("-crossplay")
fi

if [[ "$INSTANCEID" == "true" ]]; then
ARGS+=("-instanceid" "$INSTANCEID")
fi

cd /home/steam/valheim-dedicated-server

./start_server.sh "${ARGS[@]}"
exec ./start_server.sh "${ARGS[@]}"
}

function update() {
cd /home/steam/steamcmd
if ! cd /home/steam/steamcmd; then
exit 1
fi

./steamcmd.sh +@sSteamCmdForcePlatformType linux \
+app_update 896660 validate \
Expand All @@ -145,16 +120,16 @@ function update() {
+quit
}

case "$1" in
case "${1:-start}" in
start)
shift
start "$@"
;;
update)
update
;;
*)
shift
start "$@"
--help | -h)
show_usage
;;
*) ;;
esac

0 comments on commit c494f4b

Please sign in to comment.