#!/bin/sh

livestatus_path="/var/run/icinga2/cmd/livestatus"

if [ ! -e $livestatus_path ];
then
    sudo icinga2 feature enable livestatus 1> /dev/null
    sudo service icinga2 restart 1> /dev/null
    sleep 1

    if [ ! -e $livestatus_path ];
    then
        echo "[FAIL] Icinga2 Livestatus socket not found ($livestatus_path)"
        exit 1
    fi
fi

echo "[OK] Icinga2 Livestatus socket found ($livestatus_path)"
exit 0
