mirror of
				https://github.com/zulip/docker-zulip.git
				synced 2025-11-04 05:53:19 +00:00 
			
		
		
		
	Fixed the createZulipAdmin.sh script
This commit is contained in:
		@@ -14,7 +14,7 @@ RUN apt-get -q update && \
 | 
			
		||||
    cp -rf /root/custom_zulip/* /root/zulip && \
 | 
			
		||||
    rm -rf /root/custom_zulip && \
 | 
			
		||||
    PUPPET_CLASSES="zulip::dockervoyager" DEPLOYMENT_TYPE="dockervoyager" \
 | 
			
		||||
    ADDITIONAL_PACKAGES="python-dev python-six python-pbs" VIRTUALENV_NEEDED="yes" \
 | 
			
		||||
    ADDITIONAL_PACKAGES="python-dev python-six python-pbs expect" VIRTUALENV_NEEDED="yes" \
 | 
			
		||||
    /root/zulip/scripts/setup/install && \
 | 
			
		||||
    cp -a /root/zulip/zproject/prod_settings_template.py /etc/zulip/settings.py && \
 | 
			
		||||
    ln -nsf /etc/zulip/settings.py /root/zulip/zproject/prod_settings.py && \
 | 
			
		||||
 
 | 
			
		||||
@@ -47,8 +47,10 @@ services:
 | 
			
		||||
      SETTING_EMAIL_HOST_USER: "noreply@example.com"
 | 
			
		||||
      SETTING_ALLOWED_HOSTS: "[ '*', '127.0.0.2' ]"
 | 
			
		||||
      ZULIP_AUTH_BACKENDS: "EmailAuthBackend"
 | 
			
		||||
      ZULIP_USER_CREATION_ENABLED: "True"
 | 
			
		||||
      ZULIP_USER_EMAIL: "example@example.com"
 | 
			
		||||
      ZULIP_USER_PASS: "zulip"
 | 
			
		||||
      ZULIP_USER_DOMAIN: "example.com"
 | 
			
		||||
      ZULIP_USER_FULLNAME: "Zulip Example User"
 | 
			
		||||
    volumes:
 | 
			
		||||
      - "/opt/docker/zulip/zulip:/data:rw"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,30 +1,20 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
if [ ! -z "$ZULIP_USER_CREATION_ENABLED" ] && ([ -z "$ZULIP_USER_DOMAIN" ] || [ -z "$ZULIP_USER_EMAIL" ]); then
 | 
			
		||||
if ([ "$ZULIP_USER_CREATION_ENABLED" == "True" ] && [ "$ZULIP_USER_CREATION_ENABLED" == "true" ]) && ([ -z "$ZULIP_USER_DOMAIN" ] || [ -z "$ZULIP_USER_EMAIL" ] || [ -z "$ZULIP_USER_FULLNAME" ]); then
 | 
			
		||||
    echo "No zulip user configuration given."
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
set +e
 | 
			
		||||
# Doing everything in python, even I never coded in python #YOLO
 | 
			
		||||
su -c "/home/zulip/deployments/current/manage.py shell" zulip <<EOF
 | 
			
		||||
from django.core.management.base import CommandError
 | 
			
		||||
from zerver.lib.create_user import create_user
 | 
			
		||||
from zerver.lib.actions import do_change_is_admin
 | 
			
		||||
from zerver.models import Realm, get_realm, email_to_username
 | 
			
		||||
from zerver.decorator import get_user_profile_by_email
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    realm = get_realm('$ZULIP_USER_DOMAIN')
 | 
			
		||||
except Realm.DoesNotExist:
 | 
			
		||||
    raise CommandError("Realm/Domain does not exist.")
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    create_user('$ZULIP_USER_EMAIL', '$ZULIP_USER_PASS', realm, '$ZULIP_USER_FULLNAME', email_to_username('$ZULIP_USER_EMAIL'))
 | 
			
		||||
except:
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
User = get_user_profile_by_email(email='$ZULIP_USER_EMAIL')
 | 
			
		||||
do_change_is_admin(User, True, 'administer')
 | 
			
		||||
User.save()
 | 
			
		||||
quit()
 | 
			
		||||
sudo su zulip <<BASH
 | 
			
		||||
/home/zulip/deployments/current/manage.py create_realm --string_id="$ZULIP_USER_DOMAIN" --name="$ZULIP_USER_DOMAIN" -d "$ZULIP_USER_DOMAIN"
 | 
			
		||||
/home/zulip/deployments/current/manage.py create_user --this-user-has-accepted-the-tos --realm "$ZULIP_USER_DOMAIN" "$ZULIP_USER_EMAIL" "$ZULIP_USER_FULLNAME"
 | 
			
		||||
/usr/bin/expect <<EOF
 | 
			
		||||
spawn /home/zulip/deployments/current/manage.py changepassword "$ZULIP_USER_EMAIL"
 | 
			
		||||
expect -re 'Password:.*'
 | 
			
		||||
send "$ZULIP_USER_PASS";
 | 
			
		||||
expect -re 'Password (again).*'
 | 
			
		||||
send "$ZULIP_USER_PASS
 | 
			
		||||
EOF
 | 
			
		||||
/home/zulip/deployments/current/manage.py changepassword "$ZULIP_USER_EMAIL"
 | 
			
		||||
BASH
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user