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)