#!@l_prefix@/bin/openpkg rc
##
##  rc.ices -- Run-Commands
##

%config
    ices_enable="$openpkg_rc_def"

%common
    ices_cfgfile="@l_prefix@/etc/ices/ices.conf"
    ices_pidfile="@l_prefix@/var/ices/ices.pid"
    ices_signal () {
        [ -f $ices_pidfile ] && kill -$1 `cat $ices_pidfile`
    }

%status -u @l_nusr@ -o
    ices_usable="unknown"
    ices_active="no"
    rcService ices enable yes && \
        ices_signal 0 && ices_active="yes"
    echo "ices_enable=\"$ices_enable\""
    echo "ices_usable=\"$ices_usable\""
    echo "ices_active=\"$ices_active\""

%start -u @l_nusr@
    rcService ices enable yes || exit 0
    rcService ices active yes && exit 0
    @l_prefix@/bin/ices -B -c $ices_cfgfile

%stop -u @l_nusr@
    rcService ices enable yes || exit 0
    rcService ices active no  && exit 0
    ices_signal TERM
    sleep 2
    rm -f $ices_pidfile >/dev/null 2>&1 || true

%restart -u @l_nusr@
    rcService ices enable yes || exit 0
    rcService ices active no  && exit 0
    rc ices stop start

