Move resets before controller is instanciated.

This commit is contained in:
amcmanu3 2023-01-29 18:21:53 -05:00
parent 3f3595acb4
commit c8b8468030

19
main.py
View File

@ -140,6 +140,14 @@ if __name__ == "__main__":
installer.default_settings()
else:
Console.debug("Existing install detected")
Console.info("Checking for reset secret flag")
if helper.get_setting("reset_secrets_on_next_boot"):
Console.info("Found Reset")
management_helper.set_secret_api_key(str(helper.random_string_generator(64)))
management_helper.set_cookie_secret(str(helper.random_string_generator(32)))
helper.set_setting("reset_secrets_on_next_boot", False)
else:
Console.info("No flag found. Secrets are staying")
file_helper = FileHelpers(helper)
import_helper = ImportHelpers(helper, file_helper)
# now the tables are created, we can load the tasks_manager and server controller
@ -148,17 +156,6 @@ if __name__ == "__main__":
controller.get_config_diff()
Console.info("Remote change complete.")
Console.info("Checking for reset secret flag")
if helper.get_setting("reset_secrets_on_next_boot"):
Console.info("Found Reset")
controller.management.set_crafty_api_key(
str(helper.random_string_generator(64))
)
controller.management.set_cookie_secret(str(helper.random_string_generator(32)))
helper.set_setting("reset_secrets_on_next_boot", False)
else:
Console.info("No flag found. Secrets are staying")
import3 = Import3(helper, controller)
tasks_manager = TasksManager(helper, controller)
tasks_manager.start_webserver()