121 lines
5.1 KiB
Bash
121 lines
5.1 KiB
Bash
#!/bin/bash
|
|
|
|
# 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:
|
|
#
|
|
# restore-linux.sh prep Before the rebuild: system packages the build needs.
|
|
# restore-linux.sh desktop After the rebuild: Ollama binary + desktop wiring.
|
|
#
|
|
# 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}"
|
|
cd "$NEXUS_ROOT" || { echo "No $NEXUS_ROOT"; exit 1; }
|
|
|
|
if [ "$stage" = "prep" ]; then
|
|
# Fresh machine: the system packages the desktop + build steps need. No-op once
|
|
# installed, so it's cheap on an in-place restore. Skipped without apt (non-Debian).
|
|
if command -v apt-get >/dev/null; then
|
|
echo "Installing system packages..."
|
|
sudo apt-get install -y --no-install-recommends \
|
|
git sqlite3 curl python3-venv python3-gi gir1.2-gtk-3.0 \
|
|
nodejs npm xfce4-genmon-plugin plank blueman \
|
|
|| echo "Warning: some system packages failed — install them manually."
|
|
fi
|
|
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."
|
|
fi
|
|
|
|
# Panel layout, wallpaper, compositing, keybindings and terminal profile all live
|
|
# in the xfconf channel XMLs — restore them by copying the files back. xfconfd
|
|
# caches channels in memory and rewrites them on exit, so it has to die first or
|
|
# 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
|
|
echo ""
|
|
echo "Restoring XFCE desktop settings (panel, wallpaper, effects)..."
|
|
mkdir -p "$xml_dst"
|
|
pkill -x xfconfd 2>/dev/null && sleep 1
|
|
cp -f "$xml_snap"/*.xml "$xml_dst/" 2>/dev/null
|
|
|
|
# Wallpaper props are keyed by monitor name, which differs per machine — point
|
|
# every backdrop this box actually has at the Nexus background.
|
|
bg="$NEXUS_ROOT/assets/background.png"
|
|
if [ -f "$bg" ] && [ -n "${DISPLAY:-}" ]; then
|
|
xfconf-query -c xfce4-desktop -l 2>/dev/null | grep 'last-image$' | while read -r p; do
|
|
xfconf-query -c xfce4-desktop -p "$p" -s "$bg" 2>/dev/null || true
|
|
done
|
|
fi
|
|
fi
|
|
|
|
# Multi-monitor primary-follow watcher (panel + Plank track the xrandr primary).
|
|
if [ -f "$NEXUS_ROOT/bin/panel/plank-primary-watch.sh" ]; then
|
|
mkdir -p "$HOME/.local/bin"
|
|
chmod +x "$NEXUS_ROOT/bin/panel/plank-primary-watch.sh"
|
|
ln -sf "$NEXUS_ROOT/bin/panel/plank-primary-watch.sh" "$HOME/.local/bin/plank-primary-watch.sh"
|
|
fi
|
|
plank_snap="$NEXUS_ROOT/assets/themes/restore-snapshot/plank"
|
|
if [ -d "$plank_snap" ]; then
|
|
mkdir -p "$HOME/.config/plank"
|
|
cp -rf "$plank_snap/." "$HOME/.config/plank/" # /. = contents, else it nests
|
|
fi
|
|
|
|
echo ""
|
|
echo "Restoring NexusOS desktop theme..."
|
|
theme_installer="$NEXUS_ROOT/assets/themes/install-theme.sh"
|
|
if [ -x "$theme_installer" ]; then
|
|
"$theme_installer"
|
|
elif [ -f "$theme_installer" ]; then
|
|
bash "$theme_installer"
|
|
else
|
|
echo "Warning: $theme_installer not found — skipping theme restore."
|
|
fi
|
|
|
|
echo ""
|
|
echo "Installing Promethean Terminal launcher..."
|
|
term_installer="$NEXUS_ROOT/bin/promethean/install.sh"
|
|
if [ -x "$term_installer" ]; then
|
|
"$term_installer"
|
|
else
|
|
echo "Warning: $term_installer not found — skipping."
|
|
fi
|
|
|
|
echo ""
|
|
echo "Installing panel applet..."
|
|
panel_installer="$NEXUS_ROOT/bin/panel/install.sh"
|
|
if [ -x "$panel_installer" ]; then
|
|
"$panel_installer"
|
|
else
|
|
echo "Warning: $panel_installer not found — skipping panel install."
|
|
fi
|
|
|
|
# Distro branding — the About dialog / neofetch read /etc/os-release.
|
|
if grep -q '^ID=linuxmint' /etc/os-release 2>/dev/null && ! grep -q 'NexusOS' /etc/os-release; then
|
|
echo ""
|
|
echo "Branding /etc/os-release as NexusOS..."
|
|
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
|