Push Tracker
ria-ran--sim-drop/scripts/init_db.py
A ashkan@beigi.net 0be02bd1f4 Harden: fix bare-filename db path crash, configurable APN
- Fix FileNotFoundError when database.path has no directory component
  (os.makedirs(os.path.dirname(path)) with path="subscribers.db" raised).
  Add ensure_parent_dir helper; use it in app.py and scripts/init_db.py.
- Open5GS/free5gc adapters now use profile.apn for the core session/DNN name
  instead of a hardcoded "internet"; apn is threaded through get_adapter.

Tests: +4 (ensure_parent_dir, adapter APN); 82 pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-01 06:13:26 +00:00

23 lines
557 B
Python

#!/usr/bin/env python3
"""Initialize the SQLite subscriber database."""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from server.database import init_db
from server.utils import ensure_parent_dir, load_config
def main():
config_path = os.environ.get("CONFIG_PATH", "config.yaml")
cfg = load_config(config_path)
db_path = cfg["database"]["path"]
ensure_parent_dir(db_path)
init_db(db_path)
print(f"Database initialized at {db_path}")
if __name__ == "__main__":
main()