#!/bin/sh
##
##  ACMETool hook for live-updates
##

EVENT_NAME="$1"
shift

if [ ".$EVENT_NAME" = ".live-updated" ]; then
    #   standard case: reload Apache, if present
    if [ -x @l_prefix@/sbin/apache ]; then
        @l_prefix@/bin/sudo @l_prefix@/bin/openpkg rc apache reload
    fi

    #   standard case: reload NGINX, if present
    if [ -x @l_prefix@/sbin/nginx ]; then
        @l_prefix@/bin/sudo @l_prefix@/bin/openpkg rc nginx reload
    fi

    #   standard case: reload Dovecot, if present
    if [ -x @l_prefix@/sbin/dovecot ]; then
        @l_prefix@/bin/sudo @l_prefix@/bin/openpkg rc dovecot reload
    fi

    #   standard case: reload Postfix, if present
    if [ -x @l_prefix@/sbin/postfix ]; then
        @l_prefix@/bin/sudo @l_prefix@/bin/openpkg rc postfix reload
    fi

    #   special cases: via custom user script
    sh @l_prefix@/etc/acmetool/hook.sh "$EVENT_NAME"
fi

