- server/run_server.sh: checks Godot is 4.7+, imports a fresh copy once (the class cache in .godot/ isn't in git), then starts the server - The dedicated server refuses to start, with a clear reason, on Godot older than 4.7 or when the game's scripts failed to load, instead of claiming to listen - tests/run_all.sh imports a fresh copy first - Setup doc: 4.7+ (not 4.3+), importing a fresh copy, running a server
45 lines
1.8 KiB
Bash
Executable File
45 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
# Starts a dedicated Valheimlike server (no window, no local player).
|
|
#
|
|
# server/run_server.sh defaults from server.json
|
|
# server/run_server.sh --port 24242 --server-name "Paul's island" --password secret
|
|
#
|
|
# Any flags are passed to the server (see docs/MULTIPLAYER_PLAN.md §2).
|
|
# Set GODOT=/path/to/godot to use a particular Godot. Stop it with Ctrl+C.
|
|
#
|
|
# Before starting it checks that Godot is 4.7 or newer, and imports a fresh
|
|
# copy of the project once (Godot's class cache lives in .godot/, which isn't
|
|
# in git, so a new clone can't run headless until it has been imported).
|
|
|
|
cd "$(dirname "$0")/.." || exit 1
|
|
|
|
GODOT="${GODOT:-godot}"
|
|
if ! command -v "$GODOT" >/dev/null 2>&1; then
|
|
# macOS: use the app bundle if `godot` isn't on the PATH.
|
|
if [ -x /Applications/Godot.app/Contents/MacOS/Godot ]; then
|
|
GODOT=/Applications/Godot.app/Contents/MacOS/Godot
|
|
else
|
|
echo "Can't find Godot. Install 4.7.2 from https://godotengine.org/download, or set GODOT=/path/to/godot" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
version=$("$GODOT" --version 2>/dev/null | tail -n 1)
|
|
major=$(echo "$version" | cut -d. -f1)
|
|
minor=$(echo "$version" | cut -d. -f2)
|
|
if [ -z "$major" ] || [ "$major" -lt 4 ] || { [ "$major" -eq 4 ] && [ "$minor" -lt 7 ]; }; then
|
|
echo "This game needs Godot 4.7 or newer, but $GODOT is ${version:-unknown}." >&2
|
|
echo "Download 4.7.2 from https://godotengine.org/download (or set GODOT=/path/to/a/newer/godot)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -f .godot/global_script_class_cache.cfg ]; then
|
|
echo "First run on this copy: importing the project (a few seconds)..."
|
|
if ! "$GODOT" --headless --path . --import >/dev/null 2>&1 || [ ! -f .godot/global_script_class_cache.cfg ]; then
|
|
echo "Import failed. Try: $GODOT --headless --path . --import" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
exec "$GODOT" --headless --path . -- --server "$@"
|