1#!/usr/bin/env python3
2"""Create the server log directory in the sandbox workspace, owned by the service."""
3import json
4import os
5from pathlib import Path
6import sys
7
8uid = json.load(sys.stdin)["uid"]
9work = Path("/srv/work")
10if not os.path.ismount(work):
11 raise ValueError("The work SSD is not mounted; refusing to create the log directory on the root disk.")
12logs = work / "snowcord-server/logs"
13if not logs.parent.is_dir():
14 raise ValueError(f"{logs.parent} does not exist; create the sandbox workspace first.")
15logs.mkdir(mode=0o755, exist_ok=True)
16os.chown(logs, uid, uid)
17logs.chmod(0o755)