2020-11-04 23:05:21 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import json
|
|
|
|
|
2020-12-16 19:44:10 +01:00
|
|
|
def main():
|
|
|
|
ret = {"data": []}
|
|
|
|
output = subprocess.run("""
|
|
|
|
systemctl list-unit-files | grep -E '\.service\s+(generated|enabled)' | awk -F'.service ' '{print $1}'
|
|
|
|
""",
|
|
|
|
shell=True,
|
|
|
|
capture_output=True).stdout
|
2020-11-04 23:05:21 +01:00
|
|
|
|
2020-12-16 19:44:10 +01:00
|
|
|
for line in output.splitlines():
|
|
|
|
ret["data"].append({"{#SERVICE}": line.decode("utf-8")})
|
2020-11-04 23:05:21 +01:00
|
|
|
|
2020-12-16 19:44:10 +01:00
|
|
|
return json.dumps(ret)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
res = main()
|
|
|
|
print(res)
|