2026-09-05 09:41:44 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
"""Initialize new installs only. Existing keys and vault data are preserved."""
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
import secrets
|
|
|
|
|
|
|
|
|
|
path=Path('.env')
|
|
|
|
|
if path.exists():
|
|
|
|
|
print('.env already exists; existing credentials were preserved.')
|
|
|
|
|
else:
|
2026-09-09 16:59:32 +00:00
|
|
|
values={key:secrets.token_hex(32) for key in ('SANDBOX_SUPERVISOR_TOKEN','LAZYBOY_VAULT_KEY','POSTGRES_PASSWORD')}
|
2026-09-05 09:41:44 +00:00
|
|
|
text=Path('.env.example').read_text()
|
|
|
|
|
lines=[]
|
|
|
|
|
for line in text.splitlines():
|
|
|
|
|
key=line.split('=',1)[0]
|
|
|
|
|
if key in values:line=f'{key}={values[key]}'
|
|
|
|
|
elif key=='DATABASE_URL':line=f"DATABASE_URL=postgres://lazyboy:{values['POSTGRES_PASSWORD']}@127.0.0.1:5434/lazyboy"
|
|
|
|
|
lines.append(line)
|
|
|
|
|
with path.open('x') as out:
|
|
|
|
|
path.chmod(0o600)
|
|
|
|
|
out.write('\n'.join(lines)+'\n')
|
2026-09-09 16:59:32 +00:00
|
|
|
print('Created .env with independent supervisor, vault and database secrets.')
|
|
|
|
|
print('Sign-in is now a username and password: open the app and register the first account, then paste your model API key in 設定 → 模型.')
|