after_upgrade() {
<% if script?(:after_upgrade) -%>
<%=  script(:after_upgrade) %>
<% end -%>
}

after_install() {
<% if script?(:after_install) -%>
<%=  script(:after_install) %>
<% end -%>
}

if [ "${1}" = "configure" -a -z "${2}" ]
then
    # "after install" here
    after_install
elif [ "${1}" = "configure" -a -n "${2}" ]
then
    upgradeFromVersion="${2}"
    # "after upgrade" here
    # NOTE: This slot is also used when deb packages are removed,
    # but their config files aren't, but a newer version of the
    # package is installed later, called "Config-Files" state.
    # basically, that still looks a _lot_ like an upgrade to me.
    after_upgrade "${2}"
elif echo "${1}" | grep -E -q "(abort|fail)"
then
    echo "Failed to install before the post-installation script was run." >&2
    exit 1
fi

