hy-app-monitor/scripts/install_systemd.sh
2026-04-23 13:13:04 +08:00

40 lines
789 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"
if [ ! -f "$ENV_FILE" ]; then
echo "env file missing: $ENV_FILE" >&2
exit 1
fi
install_unit() {
local name="$1"
local src
local dst
src="$ROOT_DIR/systemd/$(service_unit_name "$name")"
dst="/etc/systemd/system/$(service_unit_name "$name")"
if [ ! -f "$src" ]; then
echo "systemd unit missing: $src" >&2
exit 1
fi
install -m 0644 "$src" "$dst"
}
name=""
for name in $(suite_service_names); do
install_unit "$name"
done
chmod +x "$ROOT_DIR"/scripts/*.sh
stop_all_legacy_processes
systemctl daemon-reload
for name in $(suite_service_names); do
systemctl enable "$(service_unit_name "$name")"
done