#!/usr/bin/env bash # Install and enable the systemd user service for a NodeCG install created # by install.sh. # # Usage: ./install-service.sh [install-dir] (default: ~/venue-gfx) set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" UNIT_NAME=nodecg-venue-gfx.service TEMPLATE="$SCRIPT_DIR/../deploy/$UNIT_NAME" install_dir="${1:-$HOME/venue-gfx}" install_dir="$(cd "${install_dir/#\~/$HOME}" && pwd)" [[ -f $install_dir/index.js ]] || { echo "$install_dir does not look like a NodeCG install (no index.js)" >&2 exit 1 } mkdir -p "$HOME/.config/systemd/user" sed "s|__INSTALL_DIR__|$install_dir|" "$TEMPLATE" \ > "$HOME/.config/systemd/user/$UNIT_NAME" systemctl --user daemon-reload systemctl --user enable --now "$UNIT_NAME" systemctl --user status "$UNIT_NAME" --no-pager || true cat <