Skip to content

Commit

Permalink
fix(deb): fix apt purge when emqx service was still running
Browse files Browse the repository at this point in the history
  • Loading branch information
id committed May 30, 2024
1 parent 460081a commit 38f49de
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions deploy/packages/deb/debian/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ set -e

case "$1" in
purge)
# force kill all processes owned by emqx, if any
pkill -9 -u emqx || true
rm -f /etc/default/emqx

if [ -d /var/lib/emqx ]; then
Expand All @@ -38,9 +40,8 @@ case "$1" in
if [ -e /etc/init.d/emqx ]; then
rm /etc/init.d/emqx
fi
# Remove User & Group, killing any process owned by them
# Remove User & Group
if getent passwd emqx >/dev/null; then
pkill -u emqx || true
deluser --quiet --system emqx
fi
if getent group emqx >/dev/null; then
Expand Down
15 changes: 15 additions & 0 deletions scripts/pkg-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ emqx_test(){
exit 1
fi

echo "try to install again and purge while the service is running"
dpkg -i "${PACKAGE_PATH}/${packagename}"
if [ "$(dpkg -l | grep ${EMQX_NAME} | awk '{print $1}')" != "ii" ]
then
echo "package install error"
exit 1
fi
if ! /usr/bin/emqx start
then
echo "ERROR: failed_to_start_emqx"
cat /var/log/emqx/erlang.log.1 || true
cat /var/log/emqx/emqx.log.1 || true
exit 1
fi
/usr/bin/emqx ping
dpkg -P "${EMQX_NAME}"
if dpkg -l |grep -q emqx
then
Expand Down

0 comments on commit 38f49de

Please sign in to comment.