#!/bin/sh
# Control the agent service through systemd (native sigma_agent.service) when
# the host runs systemd, else the SysV init script. One place so the postinst,
# %post, and sigma-agent-setup all do the right thing on every distro.
#   Usage: sigma-agent-svc <start|stop|restart|enable|status>
a="${1:-restart}"
if [ -d /run/systemd/system ] && command -v systemctl >/dev/null 2>&1; then
    case "$a" in
        enable) systemctl enable sigma_agent >/dev/null 2>&1 || true ;;
        *)      systemctl "$a" sigma_agent ;;
    esac
elif [ -x /etc/init.d/sigma_agent ]; then
    case "$a" in
        enable) : ;;   # handled by update-rc.d/chkconfig at install time
        *)      /etc/init.d/sigma_agent "$a" ;;
    esac
fi
