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 <noreply@anthropic.com>
This commit is contained in:
Scott Idem
2026-04-08 21:24:08 -04:00
parent f668826f79
commit 2629983452

View File

@@ -273,6 +273,27 @@ def setup_backup_timer(dry_run=False):
ok("restic found") 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"""\ svc_content = f"""\
[Unit] [Unit]
Description=Cortex home backup (restic) Description=Cortex home backup (restic)