From 427cbc7af8c679b11b54eba947bb77c6b5567cc3 Mon Sep 17 00:00:00 2001 From: Hanjo Meinhardt Date: Sat, 27 Jan 2018 13:53:50 +0100 Subject: [PATCH] add secrets for username and password --- sendxmpp.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sendxmpp.sh b/sendxmpp.sh index 925caaa..2992e4e 100644 --- a/sendxmpp.sh +++ b/sendxmpp.sh @@ -1,11 +1,14 @@ #!/bin/sh -: ${PLUGIN_USERNAME?"missing username"} -: ${PLUGIN_JSERVER?"missing jserver"} -: ${PLUGIN_PASSWORD?"missing password"} -: ${PLUGIN_RECIPIENT?"missing recipient"} +# set username from secret if not supplied +[ -z $PLUGIN_USERNAME ] && [ -n $SENDXMPP_USERNAME ] && PLUGIN_USERNAME="${SENDXMPP_USERNAME}" +[ -z $PLUGIN_PASSWORD ] && [ -n $SENDXMPP_PASSWORD ] && PLUGIN_PASSWORD="${SENDXMPP_PASSWORD}" -env | grep DRONE +# check if all required fields are set +[ -z "$PLUGIN_USERNAME" ] && echo "missing username or sendxmpp_username secret" && exit 1 +[ -z "$PLUGIN_PASSWORD" ] && echo "missing password or sendxmpp_password secret" && exit 1 +[ -z "$PLUGIN_JSERVER" ] && echo "missing jserver" && exit 1 +[ -z "$PLUGIN_RECIPIENT" ] && echo "missing recipient" && exit 1 MSG="drone ist da"