Moved the create user functions to an external script

It's dumb to create an user when the system isn't up yet..
This commit is contained in:
Alexander Trost
2015-10-18 19:36:32 +02:00
parent fb6888accf
commit adcbe1687a
4 changed files with 38 additions and 11 deletions

View File

@@ -7,7 +7,7 @@ fi
set -e
ZULIP_CURRENT_DEPLOY="$ZULIP_DIR/deployments/current"
MANAGE_PY="$ZULIP_CURRENT_DEPLOY/manage.py"
export MANAGE_PY="$ZULIP_CURRENT_DEPLOY/manage.py"
ZULIP_SETTINGS="/etc/zulip/settings.py"
ZULIP_ZPROJECT_SETTINGS="$ZULIP_CURRENT_DEPLOY/zproject/settings.py"
@@ -259,16 +259,6 @@ zulipCreateUser(){
echo "No zulip user full name given. Defaulting to \"Zulip Docker\""
export ZULIP_USER_FULLNAME="Zulip Docker"
fi
su zulip -c "$MANAGE_PY create_user --this-user-has-accepted-the-tos \"$ZULIP_USER_EMAIL\" \"$ZULIP_USER_FULLNAME\" --domain \"$ZULIP_USER_DOMAIN\"" || :
su zulip -c "$MANAGE_PY knight \"$ZULIP_USER_EMAIL\" -f"
cat | expect <<EOF
#!/usr/bin/expect
spawn su zulip -c "$MANAGE_PY changepassword $ZULIP_USER_EMAIL"
expect "Password:"
send_user "$ZULIP_USER_PASSWORD\n"
expect "Password (again):"
send_user "$ZULIP_USER_PASSWORD\n"
EOF
return 0
}

View File

@@ -0,0 +1,13 @@
#!/bin/bash
"$MANAGE_PY" create_user --this-user-has-accepted-the-tos "$ZULIP_USER_EMAIL" "$ZULIP_USER_FULLNAME" --domain "$ZULIP_USER_DOMAIN" || :
"$MANAGE_PY" knight "$ZULIP_USER_EMAIL" -f
cat | expect <<EOF
#!/usr/bin/expect
spawn "$MANAGE_PY" changepassword "$ZULIP_USER_EMAIL"
expect "Password:"
send_user "$ZULIP_USER_PASSWORD\n"
expect "Password (again):"
send_user "$ZULIP_USER_PASSWORD\n"
EOF
exit 0

View File

@@ -0,0 +1,9 @@
[program:zulippostsetup]
command=/usr/bin/bash -c "sleep 5 && /usr/local/bin/createZulipUser.sh"
priority=300 ; the relative start priority (default 999)
autostart=true ; start at supervisord start (default: true)
autorestart=false ; whether/when to restart (default: unexpected)
stopwaitsecs=30 ; max num secs to wait b4 SIGKILL (default 10)
user=zulip ; setuid to this UNIX account to run the program
redirect_stderr=true ; redirect proc stderr to stdout (default false)
stdout_logfile=/var/log/zulip/fts-updates.log ; stdout log path, NONE for none; default AUTO

View File

@@ -36,4 +36,19 @@ class zulip::voyager {
mode => 644,
source => "puppet:///modules/zulip/cron.d/restart-zulip",
}
file { "/etc/supervisor/conf.d/zulippostsetup.conf":
require => Package[supervisor],
ensure => file,
owner => "root",
group => "root",
mode => 644,
source => "puppet:///modules/zulip/supervisor/conf.d/nginx.conf",
}
file { "/usr/local/bin/createZulipUser.sh":
ensure => file,
owner => "root",
group => "root",
mode => 644,
source => "puppet:///modules/zulip/createZulipUser.sh",
}
}