2019-05-08 12:58:41 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2019-11-05 14:18:03 +00:00
|
|
|
|
2022-07-08 07:47:47 +00:00
|
|
|
sys.path.append(os.environ['AIL_BIN'])
|
|
|
|
##################################
|
|
|
|
# Import Project packages
|
|
|
|
##################################
|
2024-07-01 12:54:19 +00:00
|
|
|
from lib import ail_users
|
2019-05-08 12:58:41 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
2019-06-20 12:47:59 +00:00
|
|
|
# create role_list
|
2024-07-01 12:54:19 +00:00
|
|
|
ail_users._create_roles_list()
|
2022-07-08 07:47:47 +00:00
|
|
|
|
|
|
|
user_id = 'admin@admin.test'
|
2024-07-01 12:54:19 +00:00
|
|
|
password = ail_users.gen_password()
|
2022-07-08 07:47:47 +00:00
|
|
|
|
2024-07-01 12:54:19 +00: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 12:58:41 +00:00
|
|
|
|
2019-06-06 19:27:13 +00: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 07:47:47 +00:00
|
|
|
to_write_str = f'{to_write_str}{password}\nAPI_Key={token}\n'
|
2019-06-06 19:27:13 +00:00
|
|
|
with open(default_passwd_file, 'w') as f:
|
|
|
|
f.write(to_write_str)
|
|
|
|
|
2024-07-01 12:54:19 +00:00
|
|
|
print(f'new user created: {user_id}')
|
|
|
|
print(f'password: {password}')
|
|
|
|
print(f'token: {token}')
|