Skip to content
Snippets Groups Projects

Resolve "Pin nextcloud onlyoffice plugin version"

Merged Maarten de Waard requested to merge 1013-pin-nextcloud-onlyoffice-plugin-version into main
All threads resolved!
3 files
+ 28
29
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -31,11 +31,14 @@ data:
#
# This script gets executed by a post-install,post-upgrade helm hook, which
#
# * Persists and loads the onlyoffice-config.json config file
# * Runs upgrade routines after installation of a new release.
# * Updates all applications
# * Installs all apps declared in the `apps` helm values array
# * Installs all apps
# * Updates pinned apps if their pinned version has changed
# * Always updates unpinned apps to their newest version
# * Runs upgrade routines after installation of a new release or new
# pinned apps.
# * Configures single-sign-on
# * Persists and loads the onlyoffice-config.json config file
# * Updates database indices, columns, keys, etc needed after NC upgrade
set -ev
@@ -49,6 +52,7 @@ data:
# Enable app store so we can run `install` and `enable` commands
php $occ config:system:set appstoreenabled --type boolean --value true
app_versions=$(php occ app:list --output json)
# Install all apps declared in the `apps` helm values array
{{- range .Values.apps }}
@@ -56,35 +60,27 @@ data:
# Apps with a pinned version number are downloaded from GitHub so we can
# update the pin with Renovatebot
# Get currently installed app version without using jq. Empty string if
# nothing is installed
# This counts on pipefail being off!
current_version=$(php occ app:list --output json | grep -o '"{{ .name }}":"[0-9]\+.[0-9]\+.[0-9]\+"' | grep -o '[0-9]\+.[0-9]\+.[0-9]\+' | cat)
if [ "$current_version" != "{{ .version }}" ]
if [[ $app_versions =~ '"{{ .name }}":"{{ .version }}"' ]]
then
echo "Upgrading app {{ .github_repository }} from '$current_version' to '{{ .version }}'"
echo "App {{ .name }} is up-to-date at version {{ .version }}"
else
echo "No match in ${app_versions} for \"{{ .name }}\":\"{{ .version }}\","
echo "Installing app {{ .github_repository }} version '{{ .version }}'"
# Where to install the app
target_directory="/var/www/html/custom_apps/{{ .name }}"
tmpdir=$(mktemp --directory)
cd $tmpdir
target_directory="/var/www/html/custom_apps"
# We need to edit $ to be able to use `tpl` inside a `range`,
# see https://github.com/helm/helm/issues/5979#issuecomment-518231758
# allows us to use version variable in the release_filename
{{- $_ := set $ "version" .version}}
curl "https://github.com/{{ .github_repository }}/releases/download/v{{ .version }}/{{ tpl .release_filename $ }}" -Lo {{ .name }}.tar.gz
tar -xf {{ .name }}.tar.gz
curl "https://github.com/{{ .github_repository }}/releases/download/v{{ .version }}/{{ tpl .release_filename $ }}" -Lo "{{ .name }}.tar.gz"
# Remove old version of the app
if [[ -d $target_directory ]]
if [[ -d "$target_directory/{{ .name }}" ]]
then
rm -r $target_directory
rm -r "$target_directory/{{ .name }}"
fi
# Move app directory into target directory
mv {{ .name }} $target_directory
cd -
rm -r $tmpdir
else
echo "App {{ .name }} is up-to-date"
# Extract app into target directory. The app tars usually contain a folder
# named after the app name
tar -xf "{{ .name }}.tar.gz" -C "$target_directory"
fi
{{- else }}
# Unpinned app
@@ -92,0+88,0 @@
php $occ app:install {{ .name }} --keep-disabled --no-interaction
else
# Update the app to its latest version
php $occ app:update --all --no-interaction
php $occ app:update {{ .name }} --no-interaction
fi
{{ end }}
{{ end }} # end if and .github_repository .version
{{- if .enabled }}
# Enable {{ .name }} app
php $occ app:enable {{ .name }}
{{ end }} # -- end {{ .name }}
{{ end }} # end range {{ .Values.apps }}
{{ end }} # end if .enabled
{{ end }} # end range .Values.apps
# Some of the manually installed apps might need to run upgrade scripts, run
# them now
Loading