Skip to content
Snippets Groups Projects
Commit b066b8a9 authored by Bob Mottram's avatar Bob Mottram
Browse files

Different xmpp sending method

parent e6025939
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment