mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
56 lines
2 KiB
Python
56 lines
2 KiB
Python
#!/usr/bin/env python
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
from yunohost.diagnosis import Diagnoser
|
|
from yunohost.regenconf import manually_modified_files, manually_modified_files_compared_to_debian_default
|
|
|
|
|
|
class RegenconfDiagnoser(Diagnoser):
|
|
|
|
id_ = os.path.splitext(os.path.basename(__file__))[0].split("-")[1]
|
|
cache_duration = 300
|
|
dependencies = []
|
|
|
|
def run(self):
|
|
|
|
# nginx -t
|
|
p = subprocess.Popen("nginx -t".split(),
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.STDOUT)
|
|
out, _ = p.communicate()
|
|
|
|
if p.returncode != 0:
|
|
yield dict(meta={"test": "nginx-t"},
|
|
status="ERROR",
|
|
summary=("diagnosis_regenconf_nginx_conf_broken", {}),
|
|
details=[(out, ())]
|
|
)
|
|
|
|
regenconf_modified_files = manually_modified_files()
|
|
debian_modified_files = manually_modified_files_compared_to_debian_default(ignore_handled_by_regenconf=True)
|
|
|
|
if regenconf_modified_files == []:
|
|
yield dict(meta={"test": "regenconf"},
|
|
status="SUCCESS",
|
|
summary=("diagnosis_regenconf_allgood", {})
|
|
)
|
|
else:
|
|
for f in regenconf_modified_files:
|
|
yield dict(meta={"test": "regenconf", "file": f},
|
|
status="WARNING",
|
|
summary=("diagnosis_regenconf_manually_modified", {"file": f}),
|
|
details=[("diagnosis_regenconf_manually_modified_details", {})]
|
|
)
|
|
|
|
for f in debian_modified_files:
|
|
yield dict(meta={"test": "debian", "file": f},
|
|
status="WARNING",
|
|
summary=("diagnosis_regenconf_manually_modified_debian", {"file": f}),
|
|
details=[("diagnosis_regenconf_manually_modified_debian_details", {})]
|
|
)
|
|
|
|
|
|
def main(args, env, loggers):
|
|
return RegenconfDiagnoser(args, env, loggers).diagnose()
|