Skip to content

Commit

Permalink
Fixes the setupZulipUser.sh script #26
Browse files Browse the repository at this point in the history
  • Loading branch information
galexrt committed Oct 22, 2015
1 parent 59fb721 commit 347d819
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions zulip-puppet/files/setupZulipUser.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
#!/bin/bash

/home/zulip/deployments/current/manage.py create_user --this-user-has-accepted-the-tos "$ZULIP_USER_EMAIL" "$ZULIP_USER_FULLNAME" --domain "$ZULIP_USER_DOMAIN" || :
/home/zulip/deployments/current/manage.py knight "$ZULIP_USER_EMAIL" -f || :
# Doing everything in python, even I never coded in python #YOLO
/home/zulip/deployments/current/manage.py shell <<EOF
from zerver.decorator import get_user_profile_by_email
User = get_user_profile_by_email('$ZULIP_USER_EMAIL')
User.set_password('$ZULIP_USER_PASS')
from zerver.lib.actions import do_create_user, do_change_is_admin
from zerver.lib.initial_password import initial_password
from zerver.models import Realm, get_realm, UserProfile, email_to_username
from django.db import transaction, IntegrityError
from django.core.management.base import CommandError
try:
realm = get_realm('$ZULIP_USER_DOMAIN')
except Realm.DoesNotExist:
raise CommandError("Realm/Domain does not exist.")
try:
do_create_user('$ZULIP_USER_EMAIL', '$ZULIP_USER_PASS', realm, '$ZULIP_USER_FULLNAME', email_to_username('$ZULIP_USER_EMAIL'))
except:
pass
email = '$ZULIP_USER_EMAIL'
User = UserProfile.objects.get(email=email)
do_change_is_admin(User, True, 'administer')
User.save()
quit()
EOF
exit 200

0 comments on commit 347d819

Please sign in to comment.