2019-05-08 12:58:41 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import secrets
|
|
|
|
|
2019-06-19 13:00:25 +00:00
|
|
|
sys.path.append(os.path.join(os.environ['AIL_BIN'], 'packages/'))
|
2019-05-08 12:58:41 +00:00
|
|
|
sys.path.append('./modules/')
|
|
|
|
|
2019-06-19 13:00:25 +00:00
|
|
|
from Role_Manager import create_user_db, get_default_admin_token
|
2019-06-06 19:27:13 +00:00
|
|
|
|
2019-05-08 12:58:41 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
username = 'admin@admin.test'
|
2019-06-06 19:27:13 +00:00
|
|
|
password = secrets.token_urlsafe()
|
|
|
|
create_user_db(username, password, role='admin', default=True)
|
2019-06-19 13:00:25 +00:00
|
|
|
token = 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='
|
|
|
|
to_write_str = to_write_str + password + '\nAPI_Key=' + token
|
|
|
|
with open(default_passwd_file, 'w') as f:
|
|
|
|
f.write(to_write_str)
|
|
|
|
|
2019-05-08 12:58:41 +00:00
|
|
|
print('new user created: {}'.format(username))
|
|
|
|
print('password: {}'.format(password))
|