1
0
mirror of https://github.com/jordansissel/fpm synced 2024-12-22 00:34:15 +01:00
fpm/templates/deb/prerm_upgrade.sh.erb
Andreas Ulm c795ed7ef4 implemented --deb-maintainerscripts-force-errorchecks (#1696)
Switched from always enabling errexit to fpm parameter as result of
discussion in #1696.

Signed-off-by: Andreas Ulm <andreas.ulm@root360.de>
2021-01-19 14:33:01 -08:00

48 lines
1.4 KiB
Plaintext

#!/bin/sh
<% if attributes[:deb_maintainerscripts_force_errorchecks?] -%>
set -e
<% end -%>
before_remove() {
<%# Making sure that at least one command is in the function -%>
<%# avoids a lot of potential errors, including the case that -%>
<%# the script is non-empty, but just whitespace and/or comments -%>
:
<% if script?(:before_remove) -%>
<%= script(:before_remove) %>
<% end -%>
<%# Stop and remove any systemd services that were installed-%>
<% if attributes[:deb_systemd].any? -%>
debsystemctl=$(command -v deb-systemd-invoke || echo systemctl)
<% attributes[:deb_systemd].each do |service| -%>
$debsystemctl stop <%= service %> >/dev/null || true
systemctl disable <%= service %> >/dev/null || true
<% end -%>
systemctl --system daemon-reload >/dev/null || true
<% end -%>
}
dummy() {
:
}
if [ "${1}" = "remove" -a -z "${2}" ]
then
# "before remove" goes here
before_remove
elif [ "${1}" = "upgrade" ]
then
# Executed before the old version is removed
# upon upgrade.
# We should generally not do anything here. The newly installed package
# should do the upgrade, not the uninstalled one, since it can't anticipate
# what new things it will have to do to upgrade for the new version.
dummy
elif echo "${1}" | grep -E -q "(fail|abort)"
then
echo "Failed to install before the pre-removal script was run." >&2
exit 1
fi