diff --git a/src/freedombone-app-xmpp b/src/freedombone-app-xmpp index 32301d158f4683968635a9d3950dd6fc930e4c3e..fe549d5c4e8d58a2b0fd35e94cf854db83877881 100755 --- a/src/freedombone-app-xmpp +++ b/src/freedombone-app-xmpp @@ -1033,7 +1033,7 @@ function install_xmpp { $INSTALL_PACKAGES lua-sec lua-bitop lua5.1 liblua5.1-dev $INSTALL_PACKAGES libidn11-dev libssl-dev lua-dbi-sqlite3 - $INSTALL_PACKAGES mercurial curl + $INSTALL_PACKAGES mercurial curl python-xmpp $INSTALL_PACKAGES prosody if [ ! -f /usr/bin/hg ]; then @@ -1070,6 +1070,7 @@ function install_xmpp { if [ ! -f "/etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.pem" ]; then if [ ! -f /etc/ssl/certs/xmpp.crt ]; then "${PROJECT_NAME}-addcert" -h xmpp --dhkey "${DH_KEYLENGTH}" + # shellcheck disable=SC2034 CHECK_HOSTNAME=xmpp check_certificates xmpp if [ ! -f /etc/ssl/certs/xmpp.crt ]; then diff --git a/src/freedombone-notification b/src/freedombone-notification index 9aeb5cb4b277e4e7df13e6c2ae78e2a85db7fb66..15033f85dcb2af01d5a372c3a6a682fd03defd23 100755 --- a/src/freedombone-notification +++ b/src/freedombone-notification @@ -85,7 +85,28 @@ if [ -d /etc/prosody ]; then notification_user_password=$(openssl rand -base64 32 | tr -dc A-Za-z0-9 | head -c 30 ; echo -n '') prosodyctl deluser "notification@$HOSTNAME" 2> /dev/null if prosodyctl register "notification" "$HOSTNAME" "$notification_user_password" 2> /dev/null; then - curl http://localhost:5280/msg/user -u "notification@$HOSTNAME:$notification_user_password" -H "Content-Type: text/plain" -d "$MESSAGE" 2> /dev/null + { echo '#!/usr/bin/python2'; + echo 'import sys,os,xmpp,time'; + echo 'tojid = sys.argv[1]'; + echo 'data = sys.stdin.readlines()'; + echo "msg = ' '.join(data)"; + echo "username = 'notification@$HOSTNAME'"; + echo "password = '$notification_user_password'"; + echo 'jid=xmpp.protocol.JID(username)'; + echo 'cl=xmpp.Client(jid.getDomain(),debug=[])'; + echo 'con=cl.connect()'; + echo 'if not con:'; + echo ' sys.exit()'; + echo 'auth=cl.auth(jid.getNode(),password,resource=jid.getResource())'; + echo 'if not auth:'; + echo ' sys.exit()'; + echo 'id=cl.send(xmpp.protocol.Message(tojid, msg))'; + echo 'time.sleep(1)'; + echo 'cl.disconnect()'; } > /tmp/xsend + chmod +x /tmp/xsend + + echo "$MESSAGE" | /tmp/xsend "$ADMIN_EMAIL_ADDRESS" + rm /tmp/xsend prosodyctl deluser "notification@$HOSTNAME" 2> /dev/null fi fi