2 Commits

Author SHA1 Message Date
cnbugs 3ef5926f75 add python3.6 2026-07-14 15:17:46 +08:00
cnbugs e022c6829e 更新 README.md 2026-07-14 14:56:27 +08:00
2 changed files with 22 additions and 2 deletions
+3
View File
@@ -133,6 +133,9 @@ cd dns-service
# 安装 Python 依赖
pip install -r requirements.txt
# 创建数据库目录
mkdir -p instance
# 初始化数据库(创建默认 admin/admin 账号)
python3 init_db.py
+19 -2
View File
@@ -110,18 +110,35 @@ def inject_globals():
# ════════════════════════════════════════════════════════════════════
# BIND helpers
# ════════════════════════════════════════════════════════════════════
# python3.7
#def run_cmd(cmd, timeout=10):
# """Run shell command, return (returncode, stdout, stderr)."""
# try:
# r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout)
# return r.returncode, r.stdout.strip(), r.stderr.strip()
# except subprocess.TimeoutExpired:
# return -1, "", "Command timed out"
# except Exception as e:
# return -1, "", str(e)
# python3.6
def run_cmd(cmd, timeout=10):
"""Run shell command, return (returncode, stdout, stderr)."""
try:
r = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout)
r = subprocess.run(
cmd,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
timeout=timeout
)
return r.returncode, r.stdout.strip(), r.stderr.strip()
except subprocess.TimeoutExpired:
return -1, "", "Command timed out"
except Exception as e:
return -1, "", str(e)
def bind_service_status():
rc, out, _ = run_cmd("systemctl is-active named 2>&1")
enabled_rc, _, _ = run_cmd("systemctl is-enabled named 2>&1")