Skip to content

Instantly share code, notes, and snippets.

@flesser
Created December 10, 2015 14:42
Show Gist options
  • Save flesser/060d796f24d269005081 to your computer and use it in GitHub Desktop.
Save flesser/060d796f24d269005081 to your computer and use it in GitHub Desktop.
Since v8.2 OwnCloud stays in maintenance mode after upgrading via `apt-get upgrade`. This script "manually" runs the `occ upgrade` command if required.
#!/bin/bash
#
# ----------------------------------------------------------------------------------------------------
#
# Since v8.2 OwnCloud stays in maintenance mode after upgrading via `apt-get upgrade`.
# This script "manually" runs the `occ upgrade` command if required.
#
# USAGE
# =====
# On a Debian-based system, create a file `/etc/apt/apt.conf.d/90owncloud` with the following content:
# ```
# DPkg::Post-Invoke { "/path/to/owncloud_fix_apt-get_upgrade.sh"; };
# ```
# This tells APT to run this script after **each** dpkg call, regardless of the installed package.
# (As far as I know, there's no way to run it for specific packages only)
# This script therefore runs on each normal system update, even if the owncloud package was not
# touched at all. It checks if owncloud currently is in maintenance mode, invokes `occ upgrade` and
# leaves maintenance mode that is the case.
#
# Adjust the configuration variables below to fit your installation.
#
# December 2015, Florian Eßer <[email protected]>
#
# ----------------------------------------------------------------------------------------------------
WEBSERVER_USER=www-data
OWNCLOUD_DIR=/var/www/owncloud/
# ----------------------------------------------------------------------------------------------------
# check if owncloud currently is in maintenance mode. If not, exit.
sudo -u $WEBSERVER_USER php $OWNCLOUD_DIR/occ maintenance:mode | grep "Maintenance mode is currently enabled" || exit 0
# perform upgrade
sudo -u $WEBSERVER_USER php $OWNCLOUD_DIR/occ upgrade
# turn maintenance mode off
sudo -u $WEBSERVER_USER php $OWNCLOUD_DIR/occ maintenance:mode --off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment