Files
airship-autopilot/build.sh
Stian 4cd2573f56 Airship autopilot: role-based wget installer for server
Mirrors the live CC autopilot (computer 0) and cockpit (computer 4) from the
Modda wii world. install.lua fetches each role's manifest over HTTP so the
system installs on any server regardless of computer id.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 12:53:41 +02:00

40 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# build.sh -- mirror the live CC autopilot from the singleplayer world into this
# repo and regenerate the per-role manifests that install.lua consumes.
#
# Run this whenever you change the Lua locally and want the server installer to
# pick it up: ./build.sh && git commit -am "sync" && git push
set -euo pipefail
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SRC_DEFAULT="/home/stian/.local/share/ModrinthApp/profiles/Modda wii/saves/New World/computercraft/computer"
SRC="${1:-$SRC_DEFAULT}"
# role name -> source computer id in the world
declare -A ROLE_SRC=(
[autopilot]=0 # maskinrom: startup -> stabilizeV2 -> autopilot/main
[cockpit]=4 # pilot-hus: startup -> cockpit
)
if [ ! -d "$SRC" ]; then
echo "error: world computer dir not found: $SRC" >&2
echo "pass the path as arg 1 if the world moved." >&2
exit 1
fi
for role in "${!ROLE_SRC[@]}"; do
id="${ROLE_SRC[$role]}"
dst="$REPO/files/$role"
if [ ! -d "$SRC/$id" ]; then
echo "warn: computer $id (role $role) missing in world, skipping" >&2
continue
fi
rm -rf "$dst"
cp -r "$SRC/$id" "$dst"
# Manifest = newline-separated relative paths, sorted, excluding the manifest itself.
( cd "$dst" && find . -type f ! -name manifest | sed 's|^\./||' | sort ) > "$dst/manifest"
echo "role '$role' <- computer $id : $(wc -l < "$dst/manifest") files"
done
echo "done. files/ and manifests regenerated."