Files
chat_grid/deploy/scripts/install_service.sh

26 lines
800 B
Bash
Raw Normal View History

2026-02-20 08:16:43 -05:00
#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="${1:-/home/bestmidi/chgrid}"
UNIT_NAME="${2:-chat-grid.service}"
2026-02-20 08:16:43 -05:00
SRC_UNIT="$REPO_ROOT/deploy/systemd/$UNIT_NAME"
DST_UNIT="/etc/systemd/system/$UNIT_NAME"
DROPIN_FILE="/etc/systemd/system/$UNIT_NAME.d/env.conf"
2026-02-20 08:16:43 -05:00
if [[ ! -f "$SRC_UNIT" ]]; then
echo "error: unit file not found: $SRC_UNIT" >&2
exit 1
fi
sudo cp "$SRC_UNIT" "$DST_UNIT"
if [[ -f "$DROPIN_FILE" ]]; then
sudo rm -f "$DROPIN_FILE"
fi
sudo install -d -m 0755 -o bestmidi -g bestmidi "$REPO_ROOT/server/runtime"
sudo touch "$REPO_ROOT/server/runtime/server.log"
sudo chown bestmidi:bestmidi "$REPO_ROOT/server/runtime/server.log"
2026-02-20 08:16:43 -05:00
sudo systemctl daemon-reload
sudo systemctl enable --now "$UNIT_NAME"
sudo systemctl restart "$UNIT_NAME"
sudo systemctl status "$UNIT_NAME" --no-pager