Files
NexusOS/bin/restore.sh
T

93 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
NEXUS_ROOT="$HOME/nexus-core"
SRC="router:/tmp/mnt/Wingdrive2/nexus-core/"
mode="$1"
# Shared exclude list — used by the real restore AND the -c/--claude dry-run, so
# the check accurately previews what a real restore would do.
EXCLUDES=(
--exclude='.git/'
--exclude='Promethean/'
--exclude='models/blobs/'
--exclude='ollama/'
--exclude='interface/web/node_modules/'
--exclude='interface/web/dist/'
--exclude='runtime/'
--exclude='__pycache__/'
--exclude='*.pyc'
)
detect_requirements() {
if command -v nvidia-smi &>/dev/null || lspci 2>/dev/null | grep -qi nvidia; then
echo "requirements-nvidia.txt"
else
echo "requirements-amd.txt"
fi
}
# Check mode (-c|--claude|check): content-level dry-run. Lists exactly what a
# real restore would pull from the router and delete locally — nothing changes
# and the env/theme rebuild is skipped. --checksum compares by content (not
# size/mtime), so only genuine differences show. Meant for deciding whether a
# real restore is actually needed before paying for the rebuild.
if [ "$mode" = "-c" ] || [ "$mode" = "--claude" ] || [ "$mode" = "check" ]; then
echo "Checking restore diff vs router (dry-run, content-level, no changes)..."
rsync -rlni --checksum --delete "${EXCLUDES[@]}" -e ssh "$SRC" "$NEXUS_ROOT/"
echo ""
echo "(dry-run only — nothing changed. Apply with: restore -f)"
exit 0
fi
if [ "$mode" = "full" ] || [ "$mode" = "-f" ]; then
echo "Restoring full Nexus backup from router..."
else
echo "Restoring Nexus from router..."
fi
rsync -avz --no-owner --no-group --delete "${EXCLUDES[@]}" -e ssh "$SRC" "$NEXUS_ROOT/"
echo ""
echo "Rebuilding Python environment..."
req=$(detect_requirements)
if [ -f "$NEXUS_ROOT/$req" ]; then
"$NEXUS_ROOT/Promethean/bin/pip" install -r "$NEXUS_ROOT/$req"
else
echo "Warning: $req not found — skipping pip install."
fi
echo ""
echo "Rebuilding frontend dependencies..."
cd "$NEXUS_ROOT/interface/web" && npm install
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
echo ""
echo "Restore complete. Nexus is ready to start."