Skip to content

Commit

Permalink
Reverted spacing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dashboy1998 committed Feb 19, 2024
1 parent a718120 commit 408617b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 91 deletions.
89 changes: 18 additions & 71 deletions scripts/helper_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,39 +96,39 @@ export YellowBoldText='\033[1;33m' # Yellow
export CyanBoldText='\033[1;36m' # Cyan

LogInfo() {
Log "$1" "$WhiteText"
Log "$1" "$WhiteText"
}
LogWarn() {
Log "$1" "$YellowBoldText"
Log "$1" "$YellowBoldText"
}
LogError() {
Log "$1" "$RedBoldText"
Log "$1" "$RedBoldText"
}
LogSuccess() {
Log "$1" "$GreenBoldText"
Log "$1" "$GreenBoldText"
}
LogAction() {
Log "$1" "$CyanBoldText" "****" "****"
Log "$1" "$CyanBoldText" "****" "****"
}
Log() {
local message="$1"
local color="$2"
local prefix="$3"
local suffix="$4"
printf "$color%s$RESET$LINE" "$prefix$message$suffix"
local message="$1"
local color="$2"
local prefix="$3"
local suffix="$4"
printf "$color%s$RESET$LINE" "$prefix$message$suffix"
}

# Send Discord Message
# Level is optional variable defaulting to info
DiscordMessage() {
local message="$1"
local level="$2"
if [ -z "$level" ]; then
level="info"
fi
if [ -n "${DISCORD_WEBHOOK_URL}" ]; then
/home/steam/server/discord.sh "$message" "$level" &
fi
local message="$1"
local level="$2"
if [ -z "$level" ]; then
level="info"
fi
if [ -n "${DISCORD_WEBHOOK_URL}" ]; then
/home/steam/server/discord.sh "$message" "$level" &
fi
}

# RCON Call
Expand All @@ -143,59 +143,6 @@ RCON() {
return "$return_val"
}


# Returns 0 if Update Required
# Returns 1 if Update NOT Required
# Returns 2 if Check Failed
UpdateRequired() {
LogAction "Checking for new update"

temp_file=$(mktemp)
http_code=$(curl https://api.steamcmd.net/v1/info/2394010 --output "$temp_file" --silent --location --write-out "%{http_code}")
TARGET_MANIFEST=$(grep -Po '"2394012".*"gid": "\d+"' <"$temp_file" | sed -r 's/.*("[0-9]+")$/\1/')

CURRENT_MANIFEST=$(awk '/manifest/{count++} count==2 {print $2; exit}' /palworld/steamapps/appmanifest_2394010.acf)
rm "$temp_file"

if [ "$http_code" -ne 200 ]; then
LogError "There was a problem reaching the Steam api. Unable to check for updates!"
DiscordMessage "There was a problem reaching the Steam api. Unable to check for updates!" "failure"
return 2
fi

if [ -z "$TARGET_MANIFEST" ]; then
LogError "The server response does not contain the expected BuildID. Unable to check for updates!"
DiscordMessage "Steam servers response does not contain the expected BuildID. Unable to check for updates!" "failure"
return 2
fi

if [ "$CURRENT_MANIFEST" != "$TARGET_MANIFEST" ]; then
LogInfo "An Update Is Available."
LogInfo "Current Version: $CURRENT_MANIFEST"
LogInfo "Latest Version: $TARGET_MANIFEST."
return 0
fi

LogSuccess "The Server is up to date!"
return 1

}

InstallServer() {
DiscordMessage "${DISCORD_PRE_UPDATE_BOOT_MESSAGE}" "in-progress"
/home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType linux +@sSteamCmdForcePlatformBitness 64 +force_install_dir "/palworld" +login anonymous +app_update 2394010 validate +quit
DiscordMessage "${DISCORD_POST_UPDATE_BOOT_MESSAGE}" "success"
}

# Returns 0 if game is installed
# Returns 1 if game is not installed
IsInstalled() {
if [ -e /palworld/PalServer.sh ] && [ -e /palworld/steamapps/appmanifest_2394010.acf ]; then
return 0
fi
return 1
}

# Saves the server
# Returns 0 if it saves
# Returns 1 if it is not able to save
Expand Down
45 changes: 25 additions & 20 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,32 @@ if [ "${MULTITHREADING,,}" = true ]; then
fi

if [ "${DISABLE_GENERATE_SETTINGS,,}" = true ]; then
LogAction "GENERATING CONFIG"
LogWarn "Environment variables will not be applied due to DISABLE_GENERATE_SETTINGS being set to TRUE!"

# shellcheck disable=SC2143
if [ ! "$(grep -s '[^[:space:]]' /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini)" ]; then
LogAction "GENERATING CONFIG"
# Server will generate all ini files after first run.
if [ "$architecture" == "arm64" ]; then
timeout --preserve-status 15s ./PalServer-arm64.sh 1> /dev/null
else
timeout --preserve-status 15s ./PalServer.sh 1> /dev/null
fi

# Wait for shutdown
sleep 5
cp /palworld/DefaultPalWorldSettings.ini /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
fi
LogAction "GENERATING CONFIG"
LogWarn "Environment variables will not be applied due to DISABLE_GENERATE_SETTINGS being set to TRUE!"

# shellcheck disable=SC2143
if [ ! "$(grep -s '[^[:space:]]' /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini)" ]; then
LogAction "GENERATING CONFIG"
LogWarn "Environment variables will not be applied due to DISABLE_GENERATE_SETTINGS being set to TRUE!"

# shellcheck disable=SC2143
if [ ! "$(grep -s '[^[:space:]]' /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini)" ]; then
LogAction "GENERATING CONFIG"
# Server will generate all ini files after first run.
if [ "$architecture" == "arm64" ]; then
timeout --preserve-status 15s ./PalServer-arm64.sh 1> /dev/null
else
timeout --preserve-status 15s ./PalServer.sh 1> /dev/null
fi

# Wait for shutdown
sleep 5
cp /palworld/DefaultPalWorldSettings.ini /palworld/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
fi
else
LogAction "GENERATING CONFIG"
LogInfo "Using Env vars to create PalWorldSettings.ini"
/home/steam/server/compile-settings.sh || exit
LogAction "GENERATING CONFIG"
LogInfo "Using Env vars to create PalWorldSettings.ini"
/home/steam/server/compile-settings.sh || exit
fi

LogAction "GENERATING CRONTAB"
Expand Down

0 comments on commit 408617b

Please sign in to comment.