Skip to content

Commit

Permalink
Unified Pipelines (#960)
Browse files Browse the repository at this point in the history
* Unified Pipelines

* Remote a white space for a new commit

* Naming

* Build and Check

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
mbround18 and kodiakhq[bot] authored Sep 24, 2024
1 parent f61b617 commit 6f6ccd4
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 136 deletions.
1 change: 0 additions & 1 deletion .github/scripts/utils.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env bash


parse_version() {
# Strip git ref prefix from version
VERSION="${VERSION:-latest}"
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Build
name: Build & Check

on:
pull_request:
Expand All @@ -19,6 +19,7 @@ concurrency:

jobs:
lint:
name: Linting
runs-on: ubuntu-latest
continue-on-error: true
steps:
Expand All @@ -39,7 +40,12 @@ jobs:
echo "> These are development images, expect bugs!!"
fi
build:
build_rust:
name: Build Rust
uses: mbround18/gh-reusable/.github/workflows/rust-build-n-test.yml@main

build_docker:
name: "Build Docker"
runs-on: ubuntu-latest
strategy:
fail-fast: true
Expand Down
51 changes: 0 additions & 51 deletions .github/workflows/rust.yml

This file was deleted.

19 changes: 9 additions & 10 deletions src/scripts/auto_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ log() {
printf "%-16s: %s\n" "${PREFIX}" "$1"
}

line () {
line() {
log "###########################################################################"
}

Expand All @@ -37,26 +37,25 @@ fi
log "Starting auto backup process..."

if [ "${AUTO_BACKUP_REMOVE_OLD:=0}" -eq 1 ]; then
log "Removing old backups..."
find /home/steam/backups -mtime +$((${AUTO_BACKUP_DAYS_TO_LIVE:-5} - 1)) -exec rm {} \;
log "Removing old backups..."
find /home/steam/backups -mtime +$((${AUTO_BACKUP_DAYS_TO_LIVE:-5} - 1)) -exec rm {} \;
fi

log "Creating backup..."
file_name="$(date +"%Y%m%d-%H%M%S")-${1:-"backup"}.tar.gz"


if [ -x "$(command -v nice)" ] && [ "${AUTO_BACKUP_NICE_LEVEL:=0}" -ge "1" ] && [ "${AUTO_BACKUP_NICE_LEVEL:=0}" -le "19" ]; then
nice -n "${AUTO_BACKUP_NICE_LEVEL}" \
odin backup \
/home/steam/.config/unity3d/IronGate/Valheim \
"/home/steam/backups/${file_name}" \
|| exit 1
"/home/steam/backups/${file_name}" ||
exit 1
else
odin backup \
/home/steam/.config/unity3d/IronGate/Valheim \
"/home/steam/backups/${file_name}" \
|| exit 1
/home/steam/.config/unity3d/IronGate/Valheim \
"/home/steam/backups/${file_name}" ||
exit 1
fi

log "Backup process complete! Created ${file_name}"
line
line
62 changes: 31 additions & 31 deletions src/scripts/auto_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ log() {
PREFIX="[Valheim][steam]"
printf "%-16s: %s\n" "${PREFIX}" "$1"
}
line () {
line() {
log "###########################################################################"
}

Expand All @@ -20,49 +20,49 @@ log "Valheim Server - $(date)"
cd /home/steam/valheim || exit 1

if odin update --check; then
if [ "${PUBLIC:=0}" -eq 0 ] && [ "${AUTO_UPDATE_PAUSE_WITH_PLAYERS:=0}" -eq 1 ]; then
log "Woah, cannot pause auto update using AUTO_UPDATE_PAUSE_WITH_PLAYERS on your server with PUBLIC=0"
log "This is because we cannot query your server via the Steam API"
else
if [ "${AUTO_UPDATE_PAUSE_WITH_PLAYERS:=0}" -eq 1 ]; then
export ADDRESS=${ADDRESS:="127.0.0.1:2457"}
NUMBER_OF_PLAYERS=$(DEBUG_MODE=false odin status --address="${ADDRESS}" --json | jq -r '.players')
if [ "${NUMBER_OF_PLAYERS:=0}" -gt 0 ]; then
log "An update is available. Skipping update, while ${NUMBER_OF_PLAYERS} players online...."
exit 0
fi
if [ "${PUBLIC:=0}" -eq 0 ] && [ "${AUTO_UPDATE_PAUSE_WITH_PLAYERS:=0}" -eq 1 ]; then
log "Woah, cannot pause auto update using AUTO_UPDATE_PAUSE_WITH_PLAYERS on your server with PUBLIC=0"
log "This is because we cannot query your server via the Steam API"
else
if [ "${AUTO_UPDATE_PAUSE_WITH_PLAYERS:=0}" -eq 1 ]; then
export ADDRESS=${ADDRESS:="127.0.0.1:2457"}
NUMBER_OF_PLAYERS=$(DEBUG_MODE=false odin status --address="${ADDRESS}" --json | jq -r '.players')
if [ "${NUMBER_OF_PLAYERS:=0}" -gt 0 ]; then
log "An update is available. Skipping update, while ${NUMBER_OF_PLAYERS} players online...."
exit 0
fi
fi
fi

log "An update is available! Beginning update process..."
log "An update is available! Beginning update process..."

# Store if the server is currently running
! pidof valheim_server.x86_64 > /dev/null
SERVER_RUNNING=$?
# Store if the server is currently running
! pidof valheim_server.x86_64 >/dev/null
SERVER_RUNNING=$?

# Stop the server if it's running
if [ "${SERVER_RUNNING}" -eq 1 ]; then
odin stop || exit 1
fi
# Stop the server if it's running
if [ "${SERVER_RUNNING}" -eq 1 ]; then
odin stop || exit 1
fi

if [ "${AUTO_BACKUP_ON_UPDATE:=0}" -eq 1 ]; then
/bin/bash /home/steam/scripts/auto_backup.sh "pre-update-backup"
fi
if [ "${AUTO_BACKUP_ON_UPDATE:=0}" -eq 1 ]; then
/bin/bash /home/steam/scripts/auto_backup.sh "pre-update-backup"
fi

odin update || exit 1
odin update || exit 1

# Start the server if it was running before
if [ "${SERVER_RUNNING}" -eq 1 ]; then
odin start || exit 1
line
log "
# Start the server if it was running before
if [ "${SERVER_RUNNING}" -eq 1 ]; then
odin start || exit 1
line
log "
Finished updating and everything looks happy <3
Check your output.log for 'Game server connected'
"
fi
fi
else
log "No update available"
log "No update available"
fi

line
5 changes: 2 additions & 3 deletions src/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Exit immediately if a command exits with a non-zero status
set -e


export HOME="/home/steam"
export GAME_LOCATION=${GAME_LOCATION:-"${HOME}/valheim"}
export SAVE_LOCATION=${SAVE_LOCATION:-"${GAME_LOCATION}/saves"}
Expand Down Expand Up @@ -175,7 +174,7 @@ setup_filesystem() {
check_memory() {
local total_memory
total_memory=$(free -h | awk '/^Mem:/ {print $2}' | tr -d 'G')
if (( $(echo "$total_memory < 2" | bc -l) )); then
if (($(echo "$total_memory < 2" | bc -l))); then
log "Your system has less than 2GB of RAM! Valheim might not run on your system."
else
log "Total memory: ${total_memory} GB"
Expand Down Expand Up @@ -212,7 +211,7 @@ if [[ "$AUTO_BACKUP" -eq 1 || "$AUTO_UPDATE" -eq 1 || "$SCHEDULED_RESTART" -eq 1
if [[ -d "$CRON_LOCATION" && $(ls -A "$CRON_LOCATION") ]]; then
touch /tmp/master-cron
for file in "$CRON_LOCATION"/*; do
cat "$file" >> /tmp/master-cron
cat "$file" >>/tmp/master-cron
done
crontab /tmp/master-cron
rm -f /tmp/master-cron
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/scheduled_restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ log() {
PREFIX="[Valheim][steam]"
printf "%-16s: %s\n" "${PREFIX}" "$1"
}
line () {
line() {
log "###########################################################################"
}

Expand Down
50 changes: 25 additions & 25 deletions src/scripts/start_valheim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,31 +150,31 @@ export TYPE="${TYPE,,}"
export GAME_LOCATION="${GAME_LOCATION:="/home/steam/valheim"}"

case "${TYPE}" in
"vanilla")
if [ -n "${MODS:=""}" ]; then
log "Mods supplied but you are running with Vanilla!!!"
log "Mods will NOT be installed!."
fi
;;
"valheimplus")
if [ ! -d "${GAME_LOCATION}/BepInEx" ] || [ ! -f "${GAME_LOCATION}/BepInEx/plugins/ValheimPlus.dll" ] || [ "${UPDATE_ON_STARTUP:-0}" -eq 1 ] || [ "${FORCE_INSTALL:-0}" -eq 1 ]; then
install_valheim_plus
fi
;;
"bepinex")
if [ ! -d "${GAME_LOCATION}/BepInEx" ] || [ ! -f "${GAME_LOCATION}/BepInEx/core/BepInEx.dll" ] || [ "${UPDATE_ON_STARTUP:-0}" -eq 1 ] || [ "${FORCE_INSTALL:-0}" -eq 1 ]; then
install_bepinex
fi
;;
"bepinexfull")
if [ ! -d "${GAME_LOCATION}/BepInEx" ] || [ ! -f "${GAME_LOCATION}/BepInEx/core/BepInEx.dll" ] || [ "${UPDATE_ON_STARTUP:-0}" -eq 1 ] || [ "${FORCE_INSTALL:-0}" -eq 1 ]; then
install_bepinex_full
fi
;;
*)
log "Unknown type: ${TYPE}"
exit 1
;;
"vanilla")
if [ -n "${MODS:=""}" ]; then
log "Mods supplied but you are running with Vanilla!!!"
log "Mods will NOT be installed!."
fi
;;
"valheimplus")
if [ ! -d "${GAME_LOCATION}/BepInEx" ] || [ ! -f "${GAME_LOCATION}/BepInEx/plugins/ValheimPlus.dll" ] || [ "${UPDATE_ON_STARTUP:-0}" -eq 1 ] || [ "${FORCE_INSTALL:-0}" -eq 1 ]; then
install_valheim_plus
fi
;;
"bepinex")
if [ ! -d "${GAME_LOCATION}/BepInEx" ] || [ ! -f "${GAME_LOCATION}/BepInEx/core/BepInEx.dll" ] || [ "${UPDATE_ON_STARTUP:-0}" -eq 1 ] || [ "${FORCE_INSTALL:-0}" -eq 1 ]; then
install_bepinex
fi
;;
"bepinexfull")
if [ ! -d "${GAME_LOCATION}/BepInEx" ] || [ ! -f "${GAME_LOCATION}/BepInEx/core/BepInEx.dll" ] || [ "${UPDATE_ON_STARTUP:-0}" -eq 1 ] || [ "${FORCE_INSTALL:-0}" -eq 1 ]; then
install_bepinex_full
fi
;;
*)
log "Unknown type: ${TYPE}"
exit 1
;;
esac

# Install additional mods if not running vanilla
Expand Down
24 changes: 12 additions & 12 deletions src/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ log() {
# Parse arguments
while [ "$#" -gt 0 ]; do
case "$1" in
-p|--prefix)
prefix="$2"
shift 2
;;
-l|--level)
level="$2"
shift 2
;;
*)
line="$1"
shift 1
;;
-p | --prefix)
prefix="$2"
shift 2
;;
-l | --level)
level="$2"
shift 2
;;
*)
line="$1"
shift 1
;;
esac
done

Expand Down

0 comments on commit 6f6ccd4

Please sign in to comment.