if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ]; then
    if [ -x "/usr/bin/svctl" ]; then
        # states before any action: on upgrade restart the running units, a
        # unit that depends on a restarted oneshot of this package with it;
        # start the enabled units that do not run
        s6restart=""
        s6start=""
        if [ -n "$2" ]; then
            for unit in #RESTARTUNITS#; do
                if svctl is-active "$unit" >/dev/null 2>&1; then
                    s6restart="$s6restart $unit"
                fi
            done
        fi
        for unit in #UNITFILES#; do
            if ! svctl is-active "$unit" >/dev/null 2>&1 && svctl is-enabled "$unit" >/dev/null 2>&1; then
                s6start="$s6start $unit"
            fi
        done
        if [ -n "$s6restart" ]; then
            svctl restart $s6restart || true
        fi
        if [ -n "$s6start" ]; then
            svctl start $s6start || true
        fi
    fi
fi
