hy-app-monitor/scripts/install_systemd.sh

28 lines
680 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
# shellcheck disable=SC1091
source "$SCRIPT_DIR/common.sh"
UNIT_SRC="$ROOT_DIR/systemd/hy-app-monitor.service"
UNIT_DST="/etc/systemd/system/$SYSTEMD_SERVICE_NAME"
if [ ! -f "$UNIT_SRC" ]; then
echo "systemd unit missing: $UNIT_SRC" >&2
exit 1
fi
if [ ! -f "$ENV_FILE" ]; then
echo "env file missing: $ENV_FILE" >&2
exit 1
fi
install -m 0644 "$UNIT_SRC" "$UNIT_DST"
chmod +x "$ROOT_DIR"/scripts/*.sh
stop_legacy_process
systemctl daemon-reload
systemctl enable "$SYSTEMD_SERVICE_NAME"
systemctl restart "$SYSTEMD_SERVICE_NAME"
systemctl is-active "$SYSTEMD_SERVICE_NAME"