#!/bin/bash set -euo pipefail cd "$(dirname "$0")/.." REPO_ROOT="$(pwd)" echo "==> Installing uv..." curl -LsSf https://astral.sh/uv/install.sh | sh export PATH="$HOME/.local/bin:$PATH" echo "==> Installing Python 3.11..." uv python install 3.11 echo "==> Installing nvm + Node LTS..." if [[ ! -d "$HOME/.nvm" ]]; then curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash fi export NVM_DIR="$HOME/.nvm" # shellcheck source=/dev/null [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" nvm install --lts echo "==> Cloning gnexus-ui-kit..." if [[ ! -d "$HOME/gnexus-ui-kit" ]]; then git clone https://git.gnexus.space/git/root/gnexus-ui-kit.git "$HOME/gnexus-ui-kit" fi echo "==> Building gnexus-ui-kit..." cd "$HOME/gnexus-ui-kit" npm install npm run build echo "==> Installing server dependencies..." cd "$REPO_ROOT/server" uv venv --python 3.11 uv pip install -e ".[dev]" echo "==> Building UI..." cd "$REPO_ROOT/ui" npm install npm run build echo "==> Installing systemd user units..." mkdir -p "$HOME/.config/systemd/user" cp "$REPO_ROOT/systemd/gnexus-book-backend.service" "$HOME/.config/systemd/user/" cp "$REPO_ROOT/systemd/gnexus-book-frontend.service" "$HOME/.config/systemd/user/" echo "==> Enabling lingering for boot autostart..." loginctl enable-linger "$(whoami)" systemctl --user daemon-reload systemctl --user enable gnexus-book-backend.service gnexus-book-frontend.service systemctl --user start gnexus-book-backend.service sleep 3 systemctl --user start gnexus-book-frontend.service echo "==> Done. Services:" systemctl --user status gnexus-book-backend.service --no-pager systemctl --user status gnexus-book-frontend.service --no-pager