From be678a126e29f1777c65e554ccccb6f0b9da8ef6 Mon Sep 17 00:00:00 2001 From: David Duque Date: Sun, 30 Oct 2022 18:39:25 +0000 Subject: [PATCH] Remove nextcloud config lock before upgrading Fixes #86 --- setup/nextcloud.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/setup/nextcloud.sh b/setup/nextcloud.sh index 67815b1..d8bc57f 100755 --- a/setup/nextcloud.sh +++ b/setup/nextcloud.sh @@ -168,10 +168,28 @@ InstallNextcloud() { # $STORAGE_ROOT/owncloud is kept together even during a backup. It is better to rely on config.php than # version.php since the restore procedure can leave the system in a state where you have a newer Nextcloud # application version than the database. - # If config.php exists, get version number, otherwise CURRENT_NEXTCLOUD_VER is empty. +# +# Config unlocking, power-mailinabox#86 +# If a configuration file already exists, remove the "readonly" tag before starting the upgrade. This is +# necessary (otherwise upgrades will fail). +# +# The lock will be re-applied further down the line when it's safe to do so. +CONFIG_TEMP=$(/bin/mktemp) if [ -f "$STORAGE_ROOT/owncloud/config.php" ]; then CURRENT_NEXTCLOUD_VER=$(php -r "include(\"$STORAGE_ROOT/owncloud/config.php\"); echo(\$CONFIG['version']);") + # Unlock configuration directory for upgrades + php < $CONFIG_TEMP && mv $CONFIG_TEMP $STORAGE_ROOT/owncloud/config.php; + +EOF else CURRENT_NEXTCLOUD_VER="" fi @@ -346,7 +364,6 @@ fi # the correct domain name if the domain is being change from the previous setup. # Use PHP to read the settings file, modify it, and write out the new settings array. TIMEZONE=$(cat /etc/timezone) -CONFIG_TEMP=$(/bin/mktemp) php < $CONFIG_TEMP && mv $CONFIG_TEMP $STORAGE_ROOT/owncloud/config.php;