2019-05-08 14:58:41 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2019-11-05 15:18:03 +01:00
|
|
|
|
2022-07-08 09:47:47 +02:00
|
|
|
sys.path.append(os.environ['AIL_BIN'])
|
|
|
|
##################################
|
|
|
|
# Import Project packages
|
|
|
|
##################################
|
2024-07-01 14:54:19 +02:00
|
|
|
from lib import ail_users
|
2019-05-08 14:58:41 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
2019-06-20 14:47:59 +02:00
|
|
|
# create role_list
|
2024-07-01 14:54:19 +02:00
|
|
|
ail_users._create_roles_list()
|
2022-07-08 09:47:47 +02:00
|
|
|
|
|
|
|
user_id = 'admin@admin.test'
|
2024-07-01 14:54:19 +02:00
|
|
|
password = ail_users.gen_password()
|
2022-07-08 09:47:47 +02:00
|
|
|
|
2024-07-01 14:54:19 +02:00
|
|
|
ail_users.create_user(user_id, password=password, admin_id='admin@admin.test', role='admin')
|
|
|
|
token = ail_users.get_default_admin_token()
|
2019-05-08 14:58:41 +02:00
|
|
|
|
2019-06-06 21:27:13 +02:00
|
|
|
default_passwd_file = os.path.join(os.environ['AIL_HOME'], 'DEFAULT_PASSWORD')
|
|
|
|
to_write_str = '# Password Generated by default\n# This file is deleted after the first login\n#\nemail=admin@admin.test\npassword='
|
2022-07-08 09:47:47 +02:00
|
|
|
to_write_str = f'{to_write_str}{password}\nAPI_Key={token}\n'
|
2019-06-06 21:27:13 +02:00
|
|
|
with open(default_passwd_file, 'w') as f:
|
|
|
|
f.write(to_write_str)
|
|
|
|
|
2024-07-01 14:54:19 +02:00
|
|
|
print(f'new user created: {user_id}')
|
|
|
|
print(f'password: {password}')
|
|
|
|
print(f'token: {token}')
|