Repository navigation
#3: add a script to create users and run it automatically #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e37bc5c
c04f5bf
b53b67b
c7aabf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| """ | ||
| Create 3 users in the db: | ||
| * user: a regular user | ||
| * developer: a developer (triager) that signed the cla | ||
| * coordinator: a coordinator and committer that signed the cla | ||
|
|
||
| Most of the fields are the same as the username. | ||
| The password for all the users is 'pass'. | ||
| """ | ||
|
|
||
| import subprocess | ||
|
|
||
| rdadmin = ['/home/tracker/bin/roundup-admin', '-i', '/opt/tracker/python-dev'] | ||
|
|
||
| users = ['user', 'developer', 'coordinator'] | ||
| roles = [] | ||
|
|
||
| for user in users: | ||
| # listing the role is not enough -- all lower-level roles | ||
| # must be added too (e.g. Coordinator,Developer,User) | ||
| roles.append(user.capitalize()) | ||
| r = ','.join(roles) | ||
| ic = 1 if user == 'coordinator' else 0 # only coord is committer | ||
| args = ('create user username={u} address={u}@bugs.python.org ' | ||
| 'password=pass realname={u} github={u} roles={r} ' | ||
| 'iscommitter={ic}'.format(u=user, r=r, ic=ic)) | ||
| # developer and coordinator signed the cla | ||
| if user in {'developer', 'coordinator'}: | ||
| args += ' contrib_form=1 contrib_form_date=2017-03-22.00:00:00' | ||
|
|
||
| print('Creating user:', user) | ||
| print(' - user id:', end=' ', flush=True) | ||
| subprocess.run(rdadmin + args.split()) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,13 @@ function stop_all() { | |
|
|
||
| trap stop_all HUP INT QUIT KILL TERM | ||
|
|
||
|
|
||
| # initialize the db (pwd: admin) and create users | ||
| sleep 5 # wait for PG to start... | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not the best solution, but the other solutions I found (e.g. http://stackoverflow.com/questions/35069027/docker-wait-for-postgresql-to-be-running ) seem a bit overkill.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd still add a check if this is actually up after 5sec. so I'd go with this proposed solution: while ! curl http://$POSTGRES_PORT_5432_TCP_ADDR:$POSTGRES_PORT_5432_TCP_PORT/ 2>&1 | grep '52'
do
sleep 1
doneit's not big overkill and will give you confidence it's up at this point. |
||
| /home/tracker/bin/roundup-admin -i /opt/tracker/python-dev init admin | ||
| python3 /home/tracker/bin/createusers.py | ||
|
|
||
|
|
||
| if [ $# -eq 0 ]; then | ||
| /bin/bash | ||
| else | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't fill in github, it's not required, and might confuse. If one will be needing it, he can always set it.