fix(deb): fix apt purge when emqx service was still running

This commit is contained in:
Ivan Dyachkov 2024-05-29 15:28:55 +02:00
parent 460081a22e
commit 38f49de6d9
2 changed files with 18 additions and 2 deletions

View File

@ -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
@ -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

View File

@ -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