Replace stale bin/install.sh with a wrapper over sync.py restore

bin/install.sh still rsynced --delete from a backup path retired in July, so
the documented Linux install both failed and could erase a working tree. Every
step it claimed to do already lives in bin/sync.py, shared with Windows.

Root ./install.sh is now a thin wrapper over `sync.py restore`, so deployment
stays one bash command. It also registers ncp/promethean in ~/.bashrc, which
was the only thing the old script uniquely did.

Split restore-linux.sh into runtime (Ollama binary, shell aliases) and desktop
(XFCE panel, theme, os-release). Only desktop writes outside the repo, it now
auto-skips off XFCE, and `--no-desktop` skips it explicitly. Two tests keep the
stage names in sync and the $HOME writes confined to the desktop stage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
jon
2026-07-22 08:46:46 -05:00
co-authored by Claude Opus 4.8
parent c75f17de6e
commit ee6e5bead7
7 changed files with 133 additions and 193 deletions
+65 -20
View File
@@ -3,17 +3,29 @@
# The Linux-only half of a restore: system packages, the bundled Ollama binary,
# and the XFCE desktop wiring (panel, wallpaper, theme, terminal, branding).
# None of it means anything on Windows, which is why it lives here instead of in
# bin/sync.py — sync.py owns the portable half and calls this in two stages:
# bin/sync.py — sync.py owns the portable half and calls this in three stages:
#
# restore-linux.sh prep Before the rebuild: system packages the build needs.
# restore-linux.sh desktop After the rebuild: Ollama binary + desktop wiring.
# restore-linux.sh runtime After: Ollama binary + shell wiring. Any Linux box
# needs these to actually run NexusOS.
# restore-linux.sh desktop After: the XFCE look (panel, wallpaper, theme,
# branding). Cosmetic, this box's setup, and the only
# stage that rewrites files outside the repo and $HOME.
# Skippable with `--no-desktop`; auto-skipped off XFCE.
#
# Not meant to be run by hand — use `ncp restore` (python bin/sync.py restore).
# Set by bin/sync.py to the repo it was invoked from, so a clone in a scratch dir
# operates on itself instead of reaching into the real ~/nexus-core.
NEXUS_ROOT="${NEXUS_ROOT:-$HOME/nexus-core}"
stage="${1:?usage: restore-linux.sh prep|desktop}"
stage="${1:?usage: restore-linux.sh prep|runtime|desktop}"
# sync.py calls these by name with check=False, so a stage renamed on one side
# and not the other would silently do nothing. Fail loudly instead; a test keeps
# this list and sync.py's call sites in agreement.
case "$stage" in
prep|runtime|desktop) ;;
*) echo "unknown stage: $stage (expected prep|runtime|desktop)" >&2; exit 2 ;;
esac
cd "$NEXUS_ROOT" || { echo "No $NEXUS_ROOT"; exit 1; }
if [ "$stage" = "prep" ]; then
@@ -29,14 +41,55 @@ if [ "$stage" = "prep" ]; then
exit 0
fi
echo ""
echo "Ensuring Ollama binary..."
# ollama/ is gitignored, so a fresh clone has no binary — fetch it. No-op if the
# machine already has one (e.g. an in-place restore).
if [ -x "$NEXUS_ROOT/bin/fetch-ollama.sh" ]; then
"$NEXUS_ROOT/bin/fetch-ollama.sh" "$NEXUS_ROOT" || echo "Warning: Ollama fetch failed — install it manually."
else
echo "Warning: bin/fetch-ollama.sh not found — skipping Ollama fetch."
if [ "$stage" = "runtime" ]; then
echo ""
echo "Ensuring Ollama binary..."
# ollama/ is gitignored, so a fresh clone has no binary — fetch it. No-op if the
# machine already has one (e.g. an in-place restore).
if [ -x "$NEXUS_ROOT/bin/fetch-ollama.sh" ]; then
"$NEXUS_ROOT/bin/fetch-ollama.sh" "$NEXUS_ROOT" || echo "Warning: Ollama fetch failed — install it manually."
else
echo "Warning: bin/fetch-ollama.sh not found — skipping Ollama fetch."
fi
# Shell wiring: the `ncp` function and the Promethean venv alias. This is the
# only place they get registered now that bin/install.sh is gone. Guarded by a
# grep so an in-place restore is a no-op and a scratch clone can't re-point an
# already-wired ~/.bashrc at itself.
if ! grep -q "management/nexus-cli.sh" "$HOME/.bashrc" 2>/dev/null; then
cat >> "$HOME/.bashrc" <<EOF
# Nexus
ncp() {
$NEXUS_ROOT/management/nexus-cli.sh "\$@"
}
EOF
echo "Registered ncp in ~/.bashrc."
fi
if ! grep -qF "alias promethean=" "$HOME/.bashrc" 2>/dev/null; then
printf "\n# Promethean\nalias promethean='source %s/.promethean_bashrc'\n" \
"$NEXUS_ROOT" >> "$HOME/.bashrc"
echo "Registered promethean in ~/.bashrc."
fi
# The AMD box runs CPU-only (Vega 20, 4GB VRAM thrashes). An NVIDIA box should not.
if command -v nvidia-smi >/dev/null && command -v sqlite3 >/dev/null && \
[ "$(sqlite3 "$NEXUS_ROOT/synapse/memory/memory.db" \
"select value from settings where key='memory_gpu_offload'" 2>/dev/null)" = "0" ]; then
echo "Note: memory_gpu_offload=0 came from the AMD box (4GB VRAM). This machine has an"
echo " NVIDIA GPU — raise it in Settings to actually use the card."
fi
exit 0
fi
# --- desktop stage: XFCE only, and it writes outside the repo -----------------
# Everything below reconfigures the logged-in user's desktop. On any other DE it
# would be actively wrong (copying XFCE channel XMLs onto a GNOME box does
# nothing good), so bail rather than make a mess of someone else's machine.
if ! command -v xfconf-query >/dev/null; then
echo "Not an XFCE session (no xfconf-query) — skipping desktop wiring."
exit 0
fi
# Panel layout, wallpaper, compositing, keybindings and terminal profile all live
@@ -45,7 +98,7 @@ fi
# it clobbers what we just copied; the next xfconf-query respawns it.
xml_snap="$NEXUS_ROOT/assets/themes/restore-snapshot/xfconf-xml"
xml_dst="$HOME/.config/xfce4/xfconf/xfce-perchannel-xml"
if [ -d "$xml_snap" ] && command -v xfconf-query >/dev/null; then
if [ -d "$xml_snap" ]; then
echo ""
echo "Restoring XFCE desktop settings (panel, wallpaper, effects)..."
mkdir -p "$xml_dst"
@@ -110,11 +163,3 @@ if grep -q '^ID=linuxmint' /etc/os-release 2>/dev/null && ! grep -q 'NexusOS' /e
sudo sed -i -e 's/^NAME=.*/NAME="NexusOS"/' -e 's/^PRETTY_NAME=.*/PRETTY_NAME="NexusOS 1.0"/' \
/etc/os-release || echo "Warning: os-release branding skipped."
fi
# The AMD box runs CPU-only (Vega 20, 4GB VRAM thrashes). An NVIDIA box should not.
if command -v nvidia-smi >/dev/null && \
[ "$(sqlite3 "$NEXUS_ROOT/synapse/memory/memory.db" \
"select value from settings where key='memory_gpu_offload'" 2>/dev/null)" = "0" ]; then
echo "Note: memory_gpu_offload=0 came from the AMD box (4GB VRAM). This machine has an"
echo " NVIDIA GPU — raise it in Settings to actually use the card."
fi