diff --git a/src/freedombone-notification b/src/freedombone-notification index 774559ce2d35cc7ab38fe54898fee39cfad83b59..76cb79cf2788db04d9273d8249984d9a1d99b9d1 100755 --- a/src/freedombone-notification +++ b/src/freedombone-notification @@ -33,6 +33,16 @@ SUBJECT= MESSAGE= COMPLETION_FILE=/root/${PROJECT_NAME}-completed.txt +function kill_xsend_process { + # Sometimes the process can get stuck, so ensure that + # it gets killed if necessary + # shellcheck disable=SC2009 + xsend_pid=$(ps ax | grep /tmp/xsend | grep -v grep | awk -F ' ' '{print $1}') + if [ "$xsend_pid" ]; then + kill -9 "$xsend_pid" + fi +} + while [ $# -gt 1 ] do key="$1" @@ -139,9 +149,12 @@ if [ -d /etc/prosody ]; then MESSAGE="$SUBJECT" fi + kill_xsend_process echo "$MESSAGE" | python2 /tmp/xsend "$ADMIN_EMAIL_ADDRESS" systemctl restart prosody rm /tmp/xsend + kill_xsend_process + fi prosodyctl deluser "notification@$HOSTNAME" fi