server/nextcloud: Add extract_app_list helper script
parent
10dab39328
commit
f2c5aedc52
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import getpass
|
||||
import subprocess
|
||||
import json
|
||||
import sys
|
||||
|
||||
NC_USER = """{{ system_user }}"""
|
||||
NC_INSTALL_DIR = """{{ nextcloud_installation_directory }}"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
args_list = [
|
||||
"/usr/bin/env",
|
||||
"php",
|
||||
"occ",
|
||||
"app:list",
|
||||
"--output=json"
|
||||
]
|
||||
if getpass.getuser() != NC_USER:
|
||||
args_list = [
|
||||
"sudo",
|
||||
"-u", NC_USER,
|
||||
] + args_list
|
||||
try:
|
||||
proc = subprocess.run(args_list, capture_output=True, check=True, cwd=NC_INSTALL_DIR, text=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(e.stderr, file=sys.stderr)
|
||||
raise e
|
||||
apps_nc = json.loads(proc.stdout)
|
||||
for name, apps in reversed(sorted(apps_nc.items())):
|
||||
print(f"{name}_apps_list:")
|
||||
for app_name in apps:
|
||||
print(f" - {app_name}")
|
Loading…
Reference in New Issue