#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
##
##  rc.imapd -- Run-Commands for IMAP Daemon
##

%config
    imapd_enable="yes"

%start -p 200 -u @l_musr@
    if opServiceEnabled imapd; then
        @l_prefix@/bin/master &
        echo $! > @l_prefix@/var/imapd/imapd.pid
    fi

%stop -p 200 -u @l_musr@
    if opServiceEnabled imapd; then
        if [ -f @l_prefix@/var/imapd/imapd.pid ]; then
            kill -TERM `cat @l_prefix@/var/imapd/imapd.pid`
            rm @l_prefix@/var/imapd/imapd.pid
        fi
    fi

%restart -u @l_musr@
    if opServiceEnabled imapd; then
        if [ -f @l_prefix@/var/imapd/imapd.pid ]; then
            kill -TERM `cat @l_prefix@/var/imapd/imapd.pid`
            sleep 2
        fi
        @l_prefix@/bin/master &
        echo $! > @l_prefix@/var/imapd/imapd.pid
    fi

%reload -u @l_musr@
    if opServiceEnabled imapd; then
        if [ -f @l_prefix@/var/imapd/imapd.pid ]; then
            kill -HUP `cat @l_prefix@/var/imapd/imapd.pid`
        fi
    fi

