-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdev_db_populate.py
More file actions
executable file
·28 lines (20 loc) · 1.17 KB
/
dev_db_populate.py
File metadata and controls
executable file
·28 lines (20 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
import sys, os
host = sys.argv[1]
messages_host = os.environ.get('MESSAGES_HOST', 'localhost')
print(f"""
USE yellow;
INSERT INTO admins (username, password) VALUES ('admin', '$argon2id$v=19$m=65536,t=20,p=1$Vmb9bCJSHUOJDiS+amdMkzxTljfkanX0JKsYecdBCkQ$slQjytnGeh4/ScqmXOJ6mjjfdmu/9eVSd6dV032nrm8');
INSERT INTO modules (name, connection_string) VALUES ('org.libersoft.messages', 'ws://{messages_host}:25001/');
#INSERT INTO modules (name, connection_string) VALUES ('org.libersoft.messages2', 'ws://localhost:25002/');
#INSERT INTO modules (name, connection_string) VALUES ('org.libersoft.dating2', 'ws://localhost:25003/');
INSERT INTO domains (name) VALUES ('{host}');
INSERT INTO domains (name) VALUES ('example.com');
""")
def users(host):
for base in ['forward_test_user', 'user']:
for i in range(1, 5):
username = f'{base}{i}'
print(f"""INSERT INTO users (username, id_domains, visible_name, password) VALUES ('{username}', (SELECT id FROM domains WHERE name = '{host}'), '{username}@{host}', '$argon2id$v=19$m=65536,t=20,p=1$Vmb9bCJSHUOJDiS+amdMkzxTljfkanX0JKsYecdBCkQ$slQjytnGeh4/ScqmXOJ6mjjfdmu/9eVSd6dV032nrm8');""")
users('example.com')
users(host)