2019-05-08 12:58:41 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2019-06-20 12:47:59 +00:00
|
|
|
import redis
|
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
|
|
|
|
##################################
|
|
|
|
from lib import Users
|
2019-05-08 12:58:41 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
2019-06-20 12:47:59 +00:00
|
|
|
# create role_list
|
2022-07-08 07:47:47 +00:00
|
|
|
Users._create_roles_list()
|
|
|
|
|
|
|
|
user_id = 'admin@admin.test'
|
|
|
|
password = Users.gen_password()
|
|
|
|
|
|
|
|
create_user(user_id, password=password, role='admin')
|
|
|
|
token = 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)
|
|
|
|
|
2022-07-08 07:47:47 +00:00
|
|
|
print('new user created: {}'.format(user_id))
|
2019-05-08 12:58:41 +00:00
|
|
|
print('password: {}'.format(password))
|
2019-07-05 13:20:47 +00:00
|
|
|
print('token: {}'.format(token))
|