summaryrefslogtreecommitdiff
path: root/roles/apps/nextcloud/base
diff options
context:
space:
mode:
Diffstat (limited to 'roles/apps/nextcloud/base')
-rwxr-xr-xroles/apps/nextcloud/base/templates/nextcloud-cron.j22
-rwxr-xr-xroles/apps/nextcloud/base/templates/nextcloud-occ.j22
-rwxr-xr-xroles/apps/nextcloud/base/templates/nextcloud-upgrade.j221
3 files changed, 13 insertions, 12 deletions
diff --git a/roles/apps/nextcloud/base/templates/nextcloud-cron.j2 b/roles/apps/nextcloud/base/templates/nextcloud-cron.j2
index 355ae2c3..cf1d9715 100755
--- a/roles/apps/nextcloud/base/templates/nextcloud-cron.j2
+++ b/roles/apps/nextcloud/base/templates/nextcloud-cron.j2
@@ -16,4 +16,4 @@ if [ -z "$pod_id" ]; then echo "Pod not found"; exit 1; fi
container_id=$(crictl ps -q --name '^nextcloud$' -p "$pod_id")
if [ -z "$container_id" ]; then echo "Container not found"; exit 1; fi
-exec crictl exec "$container_id" php -f /var/www/html/cron.php
+exec crictl exec "$container_id" bash -c 'php -f /var/www/html/occ status -e; if [ $? -eq 0 ]; then php -f /var/www/html/cron.php; else echo "not running cron script when in maintenance mode"; fi'
diff --git a/roles/apps/nextcloud/base/templates/nextcloud-occ.j2 b/roles/apps/nextcloud/base/templates/nextcloud-occ.j2
index f12f1259..01383c95 100755
--- a/roles/apps/nextcloud/base/templates/nextcloud-occ.j2
+++ b/roles/apps/nextcloud/base/templates/nextcloud-occ.j2
@@ -16,4 +16,4 @@ if [ -z "$pod_id" ]; then echo "Pod not found"; exit 1; fi
container_id=$(crictl ps -q --name '^nextcloud$' -p "$pod_id")
if [ -z "$container_id" ]; then echo "Container not found"; exit 1; fi
-exec crictl exec -it "$container_id" php /var/www/html/occ $@
+exec crictl exec -it "$container_id" php -f /var/www/html/occ $@
diff --git a/roles/apps/nextcloud/base/templates/nextcloud-upgrade.j2 b/roles/apps/nextcloud/base/templates/nextcloud-upgrade.j2
index ffa912e8..f6edcb44 100755
--- a/roles/apps/nextcloud/base/templates/nextcloud-upgrade.j2
+++ b/roles/apps/nextcloud/base/templates/nextcloud-upgrade.j2
@@ -9,6 +9,13 @@ fi
set -eu
+CURRENT_VERSION=$(nextcloud-occ "$INST_NAME" status -n --no-warnings --output plain | tr -d '\r' | awk -F : '/versionstring/ { print($2) }' | tr -d ' ')
+if [ "$CURRENT_VERSION" = "$VERSION" ]; then
+ echo "The current running version of nextcloud is already $CURRENT_VERSION, nothing to do here."
+ exit 0
+fi
+echo "will upgrade nextcloud instance $INST_NAME from '$CURRENT_VERSION' to '$VERSION'"
+
K8S_CONFIG_HASH_D="/etc/kubernetes/config-hashes/"
K8S_CONFIG_HASH_FILE="$K8S_CONFIG_HASH_D/nextcloud-$INST_NAME.yml"
K8S_MANIFEST_D="/etc/kubernetes/manifests/"
@@ -41,16 +48,8 @@ else
echo ""
fi
-STORAGE_TYPE=$(findmnt -no fstype -T "$IMAGE_BUILD_D")
-if [ $STORAGE_TYPE == "zfs" ]; then
- echo "*** creating ZFS snapshot"
- echo ""
-
- IMAGE_NAME_ESCAPED=${IMAGE_NAME/\//\\/}
- CURRENT_VERSION=$(cat "$K8S_MANIFEST_FILE" | awk '/image: "'"$IMAGE_NAME_ESCAPED"':.*"/ { print($2) }' | tr -d '"' | cut -d ':' -f 2)
- ZFS_VOLUME=$(findmnt -no source -T "$IMAGE_BUILD_D")
- zfs snapshot "$ZFS_VOLUME@upgrade_$CURRENT_VERSION-to-$VERSION""_$(date '+%Y-%m-%m_%H:%M:%S')"
-fi
+INSTANCE_BASE_D=$(dirname "$IMAGE_BUILD_D")
+"$INSTANCE_BASE_D/upgrade.sh" prepare "$CURRENT_VERSION" "$VERSION"
echo "*** Rebuilding config-hash file"
echo ""
@@ -70,4 +69,6 @@ cat "$TMP_D/config-hash.yml" > "$K8S_CONFIG_HASH_FILE"
cat "$TMP_D/manifest.yml" > "$K8S_MANIFEST_FILE"
echo ""
+"$INSTANCE_BASE_D/upgrade.sh" finalize "$CURRENT_VERSION" "$VERSION"
+
exit 0