feat: bootstrap coinhunter cli package

This commit is contained in:
2026-04-15 16:40:56 +08:00
commit 7586685d5f
17 changed files with 2894 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#!/usr/bin/env python3
"""Rotate external gate log using the user's logrotate config/state."""
import subprocess
from pathlib import Path
BASE_DIR = Path.home() / ".coinhunter"
STATE_DIR = BASE_DIR / "state"
LOGROTATE_STATUS = STATE_DIR / "logrotate_external_gate.status"
LOGROTATE_CONF = BASE_DIR / "logrotate_external_gate.conf"
LOGS_DIR = BASE_DIR / "logs"
def main():
STATE_DIR.mkdir(parents=True, exist_ok=True)
LOGS_DIR.mkdir(parents=True, exist_ok=True)
cmd = ["/usr/sbin/logrotate", "-s", str(LOGROTATE_STATUS), str(LOGROTATE_CONF)]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.stdout.strip():
print(result.stdout.strip())
if result.stderr.strip():
print(result.stderr.strip())
return result.returncode
if __name__ == "__main__":
raise SystemExit(main())