#!/usr/bin/env bash # Update the bundle inside a NodeCG install created by install.sh: # pull, reinstall deps, rebuild, and restart the service if one is running. # # Usage: ./update.sh [install-dir] (default: the install this script is in, # falling back to ~/venue-gfx) set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BUNDLE=nodecg-venue-gfx UNIT_NAME=nodecg-venue-gfx.service # scripts/ lives at /bundles//scripts — walk up. candidate="$(cd "$SCRIPT_DIR/../../.." && pwd)" install_dir="${1:-$candidate}" [[ -f $install_dir/index.js ]] || install_dir="$HOME/venue-gfx" [[ -f $install_dir/index.js ]] || { echo "no NodeCG install found (tried $candidate and ~/venue-gfx)" >&2 exit 1 } bundle_dir="$install_dir/bundles/$BUNDLE" echo "Updating $bundle_dir…" git -C "$bundle_dir" pull --ff-only (cd "$bundle_dir" && npm ci --no-audit --no-fund && npm run build) if systemctl --user is-active --quiet "$UNIT_NAME" 2>/dev/null; then echo "Restarting $UNIT_NAME…" systemctl --user restart "$UNIT_NAME" else echo "Done. Restart NodeCG to load the new extension code." fi