From 2629983452a1d721e941154c634ac25022e1a786 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Wed, 8 Apr 2026 21:24:08 -0400 Subject: [PATCH] fix: create cortex config dir and restic password file during install Previously the ~/.config/cortex/ directory and restic-password were only created on the first backup run. Now install.py creates them eagerly so the user can verify setup and back up the password immediately. Co-Authored-By: Claude Sonnet 4.6 --- install.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/install.py b/install.py index 5ecaa71..5650007 100755 --- a/install.py +++ b/install.py @@ -273,6 +273,27 @@ def setup_backup_timer(dry_run=False): ok("restic found") + # Create config dir and password file now so the user can back up the + # password immediately rather than waiting for the first scheduled run. + config_dir = Path.home() / ".config" / "cortex" + password_file = config_dir / "restic-password" + + if dry_run: + if password_file.exists(): + ok(f"Password file exists: {password_file}") + else: + warn(f"Password file missing — would create: {password_file}") + else: + config_dir.mkdir(mode=0o700, parents=True, exist_ok=True) + if not password_file.exists(): + import secrets + password_file.write_text(secrets.token_urlsafe(32) + "\n") + password_file.chmod(0o600) + ok(f"Password file created: {password_file}") + warn("Back this up somewhere safe — it's required to restore from backup") + else: + ok(f"Password file exists: {password_file}") + svc_content = f"""\ [Unit] Description=Cortex home backup (restic)