From b16548cabf0d9872d096f8356f6d4f2614e807a6 Mon Sep 17 00:00:00 2001 From: phil Date: Wed, 18 Aug 2021 21:08:44 +0200 Subject: [PATCH] +Update-Skript --- defaults/main.yml | 3 ++- tasks/common.yml | 6 ++++++ templates/nextcloud-updater.j2 | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 templates/nextcloud-updater.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 388f934..ffe5c95 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,7 +6,8 @@ nextcloud_admin_user: systemausfall.org nextcloud_admin_pw: admin nextcloud_db_password: "{{ lookup('password', '/tmp/{{ instance.domain }}_db_pwd length=42 chars=ascii_letters,digits') }}" nextcloud_dl_url: https://download.nextcloud.com/server/releases -nextcloud_install_path: "/data/nextcloud/{{ instance.domain }}" +nextcloud_root: /data/nextcloud +nextcloud_install_path: "{{ nextcloud_root }}/{{ instance.domain }}" nextcloud_config_file: "{{ nextcloud_install_path }}/config/config.php" nextcloud_php_memory_limit: 512M nextcloud_php_upload_limit: 512M diff --git a/tasks/common.yml b/tasks/common.yml index 768d3c8..1ae5799 100644 --- a/tasks/common.yml +++ b/tasks/common.yml @@ -25,3 +25,9 @@ copy: src: roles/nextcloud/files/30-sao.ini dest: "/etc/php/{{ php_version }}/cli/conf.d/30-sao.ini" + +- name: "common: Kopiere Update-Skript" + template: + src: /roles/nextcloud/templates/nextcloud-updater.j2 + dest: "{{ local_scripts_dir }}/nextcloud-updater" + mode: 0755 diff --git a/templates/nextcloud-updater.j2 b/templates/nextcloud-updater.j2 new file mode 100644 index 0000000..0861aa3 --- /dev/null +++ b/templates/nextcloud-updater.j2 @@ -0,0 +1,33 @@ +#!/bin/bash + +set -e + +NEXTCLOUD_ROOT="{{ nextcloud_root }}" +UPDATER="updater/updater.phar" + +update_db() { + for j in `find "$NEXTCLOUD_ROOT" -maxdepth 1 -mindepth 1 -type d` + do + USER=$(stat -c %U "$j") + echo "Aktualisiere $j..." + sudo -u "$USER" php "$j"/occ db:convert-filecache-bigint --no-interaction + sudo -u "$USER" php "$j"/occ db:add-missing-indices --no-interaction + done +} + +case "$1" in + core-update) + for i in `find "$NEXTCLOUD_ROOT" -maxdepth 1 -mindepth 1 -type d` + do + USER=$(stat -c %U "$i") + echo "Aktualisiere $i..." + sudo -u "$USER" php "$i"/"$UPDATER" --no-interaction + done + ;; + db-update) + update_db + ;; + *) + echo "Usage: nextcloud-updater {core-update|db-update}" + exit 1 +esac