Files
airship-autopilot/build.sh

40 lines
1.4 KiB
Bash
Raw Normal View History

#!/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."