diff options
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/daemon.py')
| -rw-r--r-- | packages/meshbay-node/src/meshbay_node/daemon.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/daemon.py b/packages/meshbay-node/src/meshbay_node/daemon.py index b5a249d..37a2472 100644 --- a/packages/meshbay-node/src/meshbay_node/daemon.py +++ b/packages/meshbay-node/src/meshbay_node/daemon.py @@ -1634,9 +1634,15 @@ def _systemctl_user(verb: str, unit: str, *, not_running_hint: str, def main() -> None: import argparse - from meshbay_node.platform import configure_event_loop, force_utf8_stdio + from meshbay_node.platform import (configure_event_loop, force_utf8_stdio, + load_node_env) force_utf8_stdio() configure_event_loop() + # Before anything reads the environment. On Linux systemd has usually loaded + # the same file already via EnvironmentFile=; this is what makes a Windows + # run (Startup-folder .vbs, no systemd) and a bare `meshbay-node` behave the + # same. Already-set variables are left alone, so it cannot undo either. + load_node_env(config_dir()) parser = argparse.ArgumentParser(description="MeshBay Node daemon") parser.add_argument("command", nargs="?", @@ -1698,8 +1704,13 @@ def main() -> None: if args.command == "init": cfg_path = args.config or DEFAULT_CONFIG_PATH - config_dir = cfg_path.parent - config_dir.mkdir(parents=True, exist_ok=True) + cfg_dir = cfg_path.parent + cfg_dir.mkdir(parents=True, exist_ok=True) + + from meshbay_node.platform import install_node_env + env_written = install_node_env(cfg_dir) + if env_written: + print(f"Wrote {env_written} (packaged defaults).") hub_url = args.hub_url username = args.username @@ -1731,7 +1742,7 @@ def main() -> None: else: print(f"Config already exists: {cfg_path}") else: - unlock_file = config_dir / "unlock.key" + unlock_file = cfg_dir / "unlock.key" toml_lines = [ "[hub]", f'url = "{hub_url}"', @@ -1752,7 +1763,7 @@ def main() -> None: chmod_private(cfg_path) print(f"Config written to {cfg_path}") - unlock_file = config_dir / "unlock.key" + unlock_file = cfg_dir / "unlock.key" if not unlock_file.exists(): import secrets key = secrets.token_urlsafe(32) |