server/nextcloud: Add extract_app_list helper script

master
Felix Stupp 4 years ago
parent 10dab39328
commit f2c5aedc52
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -13,6 +13,7 @@ nextcloud_release_remote_signature: "{{ nextcloud_release_remote }}.asc"
user_directory: "{{ global_webservers_directory }}/{{ domain }}"
nextcloud_installation_directory: "{{ user_directory }}/nextcloud" # directory name of inside downloaded tar zip
nextcloud_data_directory: "{{ user_directory }}/data"
scripts_directory: "{{ user_directory }}/scripts"
nextcloud_keyring: "{{ user_directory }}/nextcloud.gpg"
nextcloud_release_file: "{{ user_directory }}/nextcloud.tar.bz2"

@ -91,6 +91,24 @@
tags:
- nextcloud_config
- name: Create scripts directories
file:
state: directory
path: "{{ scripts_directory }}"
owner: "{{ system_user }}"
group: "{{ system_user }}"
mode: "u=rwx,g=rx,o="
- name: Install helper scripts
template:
src: "scripts/{{ item }}"
dest: "{{ scripts_directory }}/{{ item }}"
owner: "{{ system_user }}"
group: "{{ system_user }}"
mode: "u=rwx,g=rx,o="
loop:
- extract_app_list.py
- name: Install Nextcloud apps
become_user: "{{ system_user }}"
command: >-

@ -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…
Cancel
Save