main
py 41 lines 1.25 KB
Raw
1 from helpers import dotenv, runtime, settings
2 import string
3 import random
4 import sys
5 from helpers.print_style import PrintStyle
6
7
8 def _retire_legacy_collabora_runtime() -> None:
9 if not any(arg.lower() == "--dockerized=true" for arg in sys.argv):
10 return
11
12 try:
13 from plugins._office import hooks as office_hooks
14
15 result = office_hooks.retire_collabora_web_runtime(force=True)
16 except Exception as exc:
17 PrintStyle.warning("Legacy Collabora runtime cleanup failed:", exc)
18 return
19
20 if result.get("errors"):
21 PrintStyle.warning("Legacy Collabora runtime cleanup reported errors:", result["errors"])
22 elif result.get("removed"):
23 PrintStyle.info("Legacy Collabora runtime retired:", result)
24
25
26 PrintStyle.standard("Preparing environment...")
27
28 try:
29
30 _retire_legacy_collabora_runtime()
31 runtime.initialize()
32
33 # generate random root password if not set (for SSH)
34 root_pass = dotenv.get_dotenv_value(dotenv.KEY_ROOT_PASSWORD)
35 if not root_pass:
36 root_pass = "".join(random.choices(string.ascii_letters + string.digits, k=32))
37 PrintStyle.standard("Changing root password...")
38 settings.set_root_password(root_pass)
39
40 except Exception as e:
41 PrintStyle.error(f"Error in preload: {e}")