File size: 1,183 Bytes
34b54ad | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | """
Environment Setup & Validation Script
"""
import secrets
from pathlib import Path
def setup():
root = Path(__file__).resolve().parents[1]
env_file = root / ".env"
env_example = root / ".env.example"
print("=== Personal OS Setup ===")
# Create .env if not exists
if not env_file.exists() and env_example.exists():
print("[+] Creating .env from .env.example...")
with open(env_example, encoding="utf-8") as src:
content = src.read()
secret_key = secrets.token_hex(32)
content = content.replace(
"generate_a_secure_random_string_here_minimum_32_chars", secret_key
)
with open(env_file, "w", encoding="utf-8") as dst:
dst.write(content)
print("[+] .env generated with secure random SECRET_KEY.")
else:
print("[+] .env file already present.")
# Create data directories
data_dir = root / "data" / "artifacts"
data_dir.mkdir(parents=True, exist_ok=True)
print(f"[+] Artifact storage directory ready at: {data_dir}")
print("\nSetup complete! You can now run:\n powershell scripts/dev.ps1")
if __name__ == "__main__":
setup()
|