# Arch install script for agentx-server (pacman .INSTALL)
# Same behaviour as the Debian postinst: enable system unit as root.

post_install() {
	if [ -d /run/systemd/system ]; then
		systemctl daemon-reload >/dev/null 2>&1 || true
		systemctl enable agentx.service >/dev/null 2>&1 || true
		systemctl start agentx.service >/dev/null 2>&1 || true
	fi
}

post_upgrade() {
	if [ -d /run/systemd/system ]; then
		systemctl daemon-reload >/dev/null 2>&1 || true
		systemctl enable agentx.service >/dev/null 2>&1 || true
		systemctl try-restart agentx.service >/dev/null 2>&1 || true
	fi
}

pre_remove() {
	if [ -d /run/systemd/system ]; then
		systemctl disable --now agentx.service >/dev/null 2>&1 || true
	fi
}
