feat: bootstrap coinhunter cli package
This commit is contained in:
26
src/coinhunter/rotate_external_gate_log.py
Executable file
26
src/coinhunter/rotate_external_gate_log.py
Executable 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())
|
||||
Reference in New Issue
Block a user