From 20d65a0b7a99ed880b5ecdd40801dc7ac53021cf Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 26 Oct 2015 17:25:59 +0000 Subject: [PATCH] Check return code --- src/freedombone-adduser | 5 +++++ src/freedombone-addxmpp | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/freedombone-adduser b/src/freedombone-adduser index 01587efe..c3109468 100755 --- a/src/freedombone-adduser +++ b/src/freedombone-adduser @@ -97,6 +97,11 @@ chmod 600 /home/$MY_USERNAME/README echo "Adding an XMPP account for $MY_USERNAME" freedombone-addxmpp -e "$MY_USERNAME@$HOSTNAME" -p "$NEW_USER_PASSWORD" +if [ ! "$?" = "0" ]; then + echo "XMPP account not created" + userdel -r $MY_USERNAME + exit 6 +fi clear echo "New user $MY_USERNAME was created" diff --git a/src/freedombone-addxmpp b/src/freedombone-addxmpp index c2c8de79..e3d9a6b7 100755 --- a/src/freedombone-addxmpp +++ b/src/freedombone-addxmpp @@ -64,11 +64,12 @@ done if [ ! -d /etc/prosody ]; then echo 'xmpp server is not installed' - exit 1 + exit 0 fi if [ ! $EMAIL_ADDRESS ]; then show_help + exit 1 fi if [ ! $NEW_USER_PASSWORD ]; then @@ -77,6 +78,9 @@ else USERNAME=$(echo $EMAIL_ADDRESS | awk -F '@' '{print $1}') DOMAIN_NAME=$(echo $EMAIL_ADDRESS | awk -F '@' '{print $2}') prosodyctl register $USERNAME $DOMAIN_NAME "$NEW_USER_PASSWORD" + if [ ! "$?" = "0" ]; then + exit 2 + fi fi exit 0