mirror of
https://github.com/zulip/docker-zulip.git
synced 2025-11-15 11:21:34 +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 && \
|
cp -rf /root/custom_zulip/* /root/zulip && \
|
||||||
rm -rf /root/custom_zulip && \
|
rm -rf /root/custom_zulip && \
|
||||||
PUPPET_CLASSES="zulip::dockervoyager" DEPLOYMENT_TYPE="dockervoyager" \
|
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 && \
|
/root/zulip/scripts/setup/install && \
|
||||||
cp -a /root/zulip/zproject/prod_settings_template.py /etc/zulip/settings.py && \
|
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 && \
|
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_EMAIL_HOST_USER: "noreply@example.com"
|
||||||
SETTING_ALLOWED_HOSTS: "[ '*', '127.0.0.2' ]"
|
SETTING_ALLOWED_HOSTS: "[ '*', '127.0.0.2' ]"
|
||||||
ZULIP_AUTH_BACKENDS: "EmailAuthBackend"
|
ZULIP_AUTH_BACKENDS: "EmailAuthBackend"
|
||||||
|
ZULIP_USER_CREATION_ENABLED: "True"
|
||||||
ZULIP_USER_EMAIL: "example@example.com"
|
ZULIP_USER_EMAIL: "example@example.com"
|
||||||
ZULIP_USER_PASS: "zulip"
|
ZULIP_USER_PASS: "zulip"
|
||||||
ZULIP_USER_DOMAIN: "example.com"
|
ZULIP_USER_DOMAIN: "example.com"
|
||||||
|
ZULIP_USER_FULLNAME: "Zulip Example User"
|
||||||
volumes:
|
volumes:
|
||||||
- "/opt/docker/zulip/zulip:/data:rw"
|
- "/opt/docker/zulip/zulip:/data:rw"
|
||||||
|
|||||||
@@ -1,30 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/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."
|
echo "No zulip user configuration given."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
set +e
|
set +e
|
||||||
# Doing everything in python, even I never coded in python #YOLO
|
# Doing everything in python, even I never coded in python #YOLO
|
||||||
su -c "/home/zulip/deployments/current/manage.py shell" zulip <<EOF
|
sudo su zulip <<BASH
|
||||||
from django.core.management.base import CommandError
|
/home/zulip/deployments/current/manage.py create_realm --string_id="$ZULIP_USER_DOMAIN" --name="$ZULIP_USER_DOMAIN" -d "$ZULIP_USER_DOMAIN"
|
||||||
from zerver.lib.create_user import create_user
|
/home/zulip/deployments/current/manage.py create_user --this-user-has-accepted-the-tos --realm "$ZULIP_USER_DOMAIN" "$ZULIP_USER_EMAIL" "$ZULIP_USER_FULLNAME"
|
||||||
from zerver.lib.actions import do_change_is_admin
|
/usr/bin/expect <<EOF
|
||||||
from zerver.models import Realm, get_realm, email_to_username
|
spawn /home/zulip/deployments/current/manage.py changepassword "$ZULIP_USER_EMAIL"
|
||||||
from zerver.decorator import get_user_profile_by_email
|
expect -re 'Password:.*'
|
||||||
|
send "$ZULIP_USER_PASS";
|
||||||
try:
|
expect -re 'Password (again).*'
|
||||||
realm = get_realm('$ZULIP_USER_DOMAIN')
|
send "$ZULIP_USER_PASS
|
||||||
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()
|
|
||||||
EOF
|
EOF
|
||||||
|
/home/zulip/deployments/current/manage.py changepassword "$ZULIP_USER_EMAIL"
|
||||||
|
BASH
|
||||||
|
|||||||
Reference in New Issue
Block a user