Set up FlavorPack config directory structure on this host.
Creates the trusted-keys directory and a default policy.json.
Safe to run multiple times β existing files are never overwritten.
Source code in flavor/commands/init.py
| @click.command("init")
@click.option(
"--global",
"global_",
is_flag=True,
default=False,
help="Set up system-wide config under /etc/flavor (requires root/sudo).",
)
def init_command(global_: bool) -> None:
"""Set up FlavorPack config directory structure on this host.
Creates the trusted-keys directory and a default policy.json.
Safe to run multiple times β existing files are never overwritten.
"""
config_root: Path = get_system_config_dir() if global_ else get_config_dir()
scope = "system" if global_ else "user"
log.debug("Initializing FlavorPack config", scope=scope, root=str(config_root))
# Create trusted-keys directory
trusted_keys_dir = config_root / "trusted-keys"
trusted_keys_dir.mkdir(parents=True, exist_ok=True)
pout(f"β {trusted_keys_dir}")
# Scaffold policy.json (never overwrite)
policy_file = config_root / "policy.json"
if not policy_file.exists():
policy_file.write_text(json.dumps(_POLICY_JSON_SCAFFOLD, indent=2) + "\n", encoding="utf-8")
pout(f"β {policy_file} (scaffolded)")
else:
pout(f" {policy_file} (already exists, not modified)")
pout(f"\nFlavorPack {scope} config initialised at {config_root}")
if not global_:
pout(" Add trusted keys with: flavor trust add <key.pub>")
pout(f" Edit policy: {policy_file}")
else:
pout(" Add trusted keys with: sudo flavor trust add <key.pub> --global")
pout(f" Edit policy: {policy_file}")
|