#!/usr/bin/execlineb -S1

# Disable the service if it exit(0), else wait 2 seconds before restarting it


# First check if the system-probe exists
if { s6-test -x "/opt/datadog-agent/embedded/bin/system-probe" }

ifthenelse
    { s6-test ${1} -eq 0 }
    {
        foreground { /initlog.sh "system-probe exited with code ${1}, disabling" }
        foreground { /bin/s6-svc -d /var/run/s6/services/sysprobe/ }
    }
    {
        foreground { /initlog.sh "system-probe exited with code ${1}, signal ${2}, restarting in 2 seconds" }
        foreground { s6-sleep 2 }
    }
