packaging: fix issues in pre/postremove scripts (#12147)
Fixes several issues with the pre/postremove scripts for both rpm and deb packages. Specifically: For postremove: - the postremove script now functions correctly (i.e. restarts consul after a package upgrade) on rpm-based systems (where $1 is numeric rather than `purge` or `upgrade`) - `systemctl daemon-reload` is called on package removal (rather than only on upgrade) - calls `systemctl try-restart` instead of `systemctl restart`, which will only (re)start consul if it was already running when the upgrade happened. For preremove: - if the package is being completely uninstalled (rather than upgraded), stop consul before removing the package
This commit is contained in:
parent
01437e81ea
commit
da1072da80
|
@ -3,7 +3,7 @@ name: build
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
# Sequence of patterns matched against refs/heads
|
# Sequence of patterns matched against refs/heads
|
||||||
branches: [
|
branches: [
|
||||||
"main"
|
"main"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -145,6 +145,7 @@ jobs:
|
||||||
config_dir: ".release/linux/package"
|
config_dir: ".release/linux/package"
|
||||||
preinstall: ".release/linux/preinstall"
|
preinstall: ".release/linux/preinstall"
|
||||||
postinstall: ".release/linux/postinstall"
|
postinstall: ".release/linux/postinstall"
|
||||||
|
preremove: ".release/linux/preremove"
|
||||||
postremove: ".release/linux/postremove"
|
postremove: ".release/linux/postremove"
|
||||||
|
|
||||||
- name: Set Package Names
|
- name: Set Package Names
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ "$1" = "purge" ]
|
if [ -d "/run/systemd/system" ]; then
|
||||||
then
|
systemctl --system daemon-reload >/dev/null || :
|
||||||
userdel consul
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" == "upgrade" ] && [ -d /run/systemd/system ]; then
|
case "$1" in
|
||||||
systemctl --system daemon-reload >/dev/null || true
|
purge | 0)
|
||||||
systemctl restart consul >/dev/null || true
|
userdel consul
|
||||||
fi
|
;;
|
||||||
|
|
||||||
|
upgrade | [1-9]*)
|
||||||
|
if [ -d "/run/systemd/system" ]; then
|
||||||
|
systemctl try-restart consul.service >/dev/null || :
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
case "$1" in
|
||||||
|
remove | 0)
|
||||||
|
if [ -d "/run/systemd/system" ]; then
|
||||||
|
systemctl --no-reload disable consul.service > /dev/null || :
|
||||||
|
systemctl stop consul.service > /dev/null || :
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue