From e635b5e1326d1620d291aad4da02eeaa77eabcbe Mon Sep 17 00:00:00 2001 From: Michael Kroes Date: Mon, 25 Jul 2016 22:45:31 +0200 Subject: [PATCH 01/12] Install owncoud 9.1 and provide an upgrade path from 8.2. This also disables memcached and goes with apc. The upgrade fails with memcached. --- setup/owncloud.sh | 73 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index cc58a5caf..a3f42a002 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -16,10 +16,6 @@ apt_install \ apt-get purge -qq -y owncloud* -# Install ownCloud from source of this version: -owncloud_ver=8.2.3 -owncloud_hash=bfdf6166fbf6fc5438dc358600e7239d1c970613 - # Migrate <= v0.10 setups that stored the ownCloud config.php in /usr/local rather than # in STORAGE_ROOT. Move the file to STORAGE_ROOT. if [ ! -f $STORAGE_ROOT/owncloud/config.php ] \ @@ -32,16 +28,16 @@ if [ ! -f $STORAGE_ROOT/owncloud/config.php ] \ ln -sf $STORAGE_ROOT/owncloud/config.php /usr/local/lib/owncloud/config/config.php fi -# Check if ownCloud dir exist, and check if version matches owncloud_ver (if either doesn't - install/upgrade) -if [ ! -d /usr/local/lib/owncloud/ ] \ - || ! grep -q $owncloud_ver /usr/local/lib/owncloud/version.php; then +InstallOwncloud() { + version=$1 + hash=$2 # Download and verify - wget_verify https://download.owncloud.org/community/owncloud-$owncloud_ver.zip $owncloud_hash /tmp/owncloud.zip + wget_verify https://download.owncloud.org/community/owncloud-$version.zip $hash /tmp/owncloud.zip # Clear out the existing ownCloud. if [ -d /usr/local/lib/owncloud/ ]; then - echo "upgrading ownCloud to $owncloud_ver (backing up existing ownCloud directory to /tmp/owncloud-backup-$$)..." + echo "upgrading ownCloud to $version (backing up existing ownCloud directory to /tmp/owncloud-backup-$$)..." mv /usr/local/lib/owncloud /tmp/owncloud-backup-$$ fi @@ -49,11 +45,17 @@ if [ ! -d /usr/local/lib/owncloud/ ] \ unzip -u -o -q /tmp/owncloud.zip -d /usr/local/lib #either extracts new or replaces current files rm -f /tmp/owncloud.zip - # The two apps we actually want are not in ownCloud core. Clone them from + # The two apps we actually want are not in ownCloud core. Download the releases from # their github repositories. mkdir -p /usr/local/lib/owncloud/apps - git_clone https://github.com/owncloudarchive/contacts 9ba2e667ae8c7ea36d8c4a4c3413c374beb24b1b '' /usr/local/lib/owncloud/apps/contacts - git_clone https://github.com/owncloudarchive/calendar 2086e738a3b7b868ec59cd61f0f88b49c3f21dd1 '' /usr/local/lib/owncloud/apps/calendar + wget_verify https://github.com/owncloud/contacts/releases/download/v1.3.1.0/contacts.tar.gz 8603f05dad68d1306e72befe1e672ff06165d11e /tmp/contacts.tgz + tar xf /tmp/contacts.tgz -C /usr/local/lib/owncloud/apps/ + rm /tmp/contacts.tgz + + wget_verify https://github.com/owncloud/calendar/releases/download/v1.3.1/calendar.tar.gz 3b8aecd7c31a2b59721c826d9b2a2ebb619e25c6 /tmp/calendar.tgz + tar xf /tmp/calendar.tgz -C /usr/local/lib/owncloud/apps/ + rm /tmp/calendar.tgz + # Fix weird permissions. chmod 750 /usr/local/lib/owncloud/{apps,config} @@ -69,7 +71,7 @@ if [ ! -d /usr/local/lib/owncloud/ ] \ # If this isn't a new installation, immediately run the upgrade script. # Then check for success (0=ok and 3=no upgrade needed, both are success). - if [ -f $STORAGE_ROOT/owncloud/owncloud.db ]; then + if [ -e $STORAGE_ROOT/owncloud/owncloud.db ]; then # ownCloud 8.1.1 broke upgrades. It may fail on the first attempt, but # that can be OK. sudo -u www-data php /usr/local/lib/owncloud/occ upgrade @@ -81,6 +83,41 @@ if [ ! -d /usr/local/lib/owncloud/ ] \ echo "...which seemed to work." fi fi +} + +owncloud_ver=9.1.0 + +echo "Checking version" +# Check if ownCloud dir exist, and check if version matches owncloud_ver (if either doesn't - install/upgrade) +if [ ! -d /usr/local/lib/owncloud/ ] \ + || ! grep -q $owncloud_ver /usr/local/lib/owncloud/version.php; then + + # If we are upgrading from 8.2.3 we should go to 9.0 first + if grep -q 8.2.3 /usr/local/lib/owncloud/version.php; then + echo "We are running version 8.2.3, upgrading to 9.0.2 first" + + # We need to disable memcached and go with APC, the upgrade and install fails + # with memcached + CONFIG_TEMP=$(/bin/mktemp) + php < $CONFIG_TEMP && mv $CONFIG_TEMP $STORAGE_ROOT/owncloud/config.php; + +EOF + + chown www-data.www-data $STORAGE_ROOT/owncloud/config.php + + InstallOwncloud 9.0.2 72a3d15d09f58c06fa8bee48b9e60c9cd356f9c5 + fi + + echo "Upgrading to latest version" + InstallOwncloud $owncloud_ver 82aa7f038e2670b16e80aaf9a41260ab718a8348 fi # ### Configuring ownCloud @@ -111,10 +148,7 @@ if [ ! -f $STORAGE_ROOT/owncloud/owncloud.db ]; then 'arguments'=>array('{127.0.0.1:993/imap/ssl/novalidate-cert}') ) ), - 'memcache.local' => '\\OC\\Memcache\\Memcached', - "memcached_servers" => array ( - array('127.0.0.1', 11211), - ), + 'memcache.local' => '\OC\Memcache\APC', 'mail_smtpmode' => 'sendmail', 'mail_smtpsecure' => '', 'mail_smtpauthtype' => 'LOGIN', @@ -171,7 +205,7 @@ include("$STORAGE_ROOT/owncloud/config.php"); \$CONFIG['trusted_domains'] = array('$PRIMARY_HOSTNAME'); -\$CONFIG['memcache.local'] = '\\OC\\Memcache\\Memcached'; +\$CONFIG['memcache.local'] = '\OC\Memcache\APC'; \$CONFIG['overwrite.cli.url'] = '/cloud'; \$CONFIG['mail_from_address'] = 'administrator'; # just the local part, matches our master administrator address @@ -205,7 +239,8 @@ tools/editconf.py /etc/php5/fpm/php.ini -c ';' \ output_buffering=16384 \ memory_limit=512M \ max_execution_time=600 \ - short_open_tag=On + short_open_tag=On \ + apc.enable_cli=1 # Set up a cron job for owncloud. cat > /etc/cron.hourly/mailinabox-owncloud << EOF; From 2ac25b58d5fb57dd95826ba120e0259066ba68ea Mon Sep 17 00:00:00 2001 From: Michael Kroes Date: Wed, 27 Jul 2016 18:35:54 +0200 Subject: [PATCH 02/12] Remove php apc setting --- setup/owncloud.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index a3f42a002..dab3f8a34 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -239,8 +239,7 @@ tools/editconf.py /etc/php5/fpm/php.ini -c ';' \ output_buffering=16384 \ memory_limit=512M \ max_execution_time=600 \ - short_open_tag=On \ - apc.enable_cli=1 + short_open_tag=On # Set up a cron job for owncloud. cat > /etc/cron.hourly/mailinabox-owncloud << EOF; From fa5c4fb4e36c3d8c23d33840535c72ff7da64327 Mon Sep 17 00:00:00 2001 From: Michael Kroes Date: Wed, 27 Jul 2016 18:52:52 +0200 Subject: [PATCH 03/12] Add dav migrations for each user --- setup/owncloud.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index dab3f8a34..cb61a6e07 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -114,6 +114,15 @@ EOF chown www-data.www-data $STORAGE_ROOT/owncloud/config.php InstallOwncloud 9.0.2 72a3d15d09f58c06fa8bee48b9e60c9cd356f9c5 + + # The owncloud 9 migration doesn't migrate calendars and contacts + # The option to migrate these are removed in 9.1 + sudo -u www-data php /usr/local/lib/owncloud/occ dav:migrate-addressbooks + for directory in $STORAGE_ROOT/owncloud/*@*/ ; do + username=$(basename "${directory}") + sudo -u www-data php /usr/local/lib/owncloud/occ dav:migrate-calendar $username + done + sudo -u www-data php /usr/local/lib/owncloud/occ dav:sync-birthday-calendar fi echo "Upgrading to latest version" From f1ec1eb399ecc7daf4f80329cd2ec1c0cb57abb4 Mon Sep 17 00:00:00 2001 From: Michael Kroes Date: Wed, 27 Jul 2016 19:04:53 +0200 Subject: [PATCH 04/12] Add some comments to the code --- setup/owncloud.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index cb61a6e07..902b0cc6d 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -92,7 +92,7 @@ echo "Checking version" if [ ! -d /usr/local/lib/owncloud/ ] \ || ! grep -q $owncloud_ver /usr/local/lib/owncloud/version.php; then - # If we are upgrading from 8.2.3 we should go to 9.0 first + # If we are upgrading from 8.2.3 we should go to 9.0 first. Owncloud doesn't support skipping minor versions if grep -q 8.2.3 /usr/local/lib/owncloud/version.php; then echo "We are running version 8.2.3, upgrading to 9.0.2 first" @@ -110,14 +110,16 @@ if [ ! -d /usr/local/lib/owncloud/ ] \ echo ";"; ?> EOF - chown www-data.www-data $STORAGE_ROOT/owncloud/config.php + # We can now install owncloud 9.0.2 InstallOwncloud 9.0.2 72a3d15d09f58c06fa8bee48b9e60c9cd356f9c5 # The owncloud 9 migration doesn't migrate calendars and contacts # The option to migrate these are removed in 9.1 + # So the migrations should be done when we have 9.0 installed sudo -u www-data php /usr/local/lib/owncloud/occ dav:migrate-addressbooks + # The following migration has to be done for each owncloud user for directory in $STORAGE_ROOT/owncloud/*@*/ ; do username=$(basename "${directory}") sudo -u www-data php /usr/local/lib/owncloud/occ dav:migrate-calendar $username @@ -125,7 +127,6 @@ EOF sudo -u www-data php /usr/local/lib/owncloud/occ dav:sync-birthday-calendar fi - echo "Upgrading to latest version" InstallOwncloud $owncloud_ver 82aa7f038e2670b16e80aaf9a41260ab718a8348 fi From abe6bc743f4d784fb28ccfd8e8344f34b3be2ca9 Mon Sep 17 00:00:00 2001 From: Michael Kroes Date: Fri, 29 Jul 2016 17:46:33 +0200 Subject: [PATCH 05/12] When upgrading owncloud from 8.2.3 to 9.1.0 the backup of 8.2.3 was overwritten when going from 9.0 to 9.1 --- setup/owncloud.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index 902b0cc6d..ef84c6abe 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -32,15 +32,12 @@ InstallOwncloud() { version=$1 hash=$2 + # Remove the current owncloud + rm -rf /usr/local/lib/owncloud + # Download and verify wget_verify https://download.owncloud.org/community/owncloud-$version.zip $hash /tmp/owncloud.zip - # Clear out the existing ownCloud. - if [ -d /usr/local/lib/owncloud/ ]; then - echo "upgrading ownCloud to $version (backing up existing ownCloud directory to /tmp/owncloud-backup-$$)..." - mv /usr/local/lib/owncloud /tmp/owncloud-backup-$$ - fi - # Extract ownCloud unzip -u -o -q /tmp/owncloud.zip -d /usr/local/lib #either extracts new or replaces current files rm -f /tmp/owncloud.zip @@ -87,13 +84,19 @@ InstallOwncloud() { owncloud_ver=9.1.0 -echo "Checking version" # Check if ownCloud dir exist, and check if version matches owncloud_ver (if either doesn't - install/upgrade) if [ ! -d /usr/local/lib/owncloud/ ] \ || ! grep -q $owncloud_ver /usr/local/lib/owncloud/version.php; then - # If we are upgrading from 8.2.3 we should go to 9.0 first. Owncloud doesn't support skipping minor versions - if grep -q 8.2.3 /usr/local/lib/owncloud/version.php; then + # Backup the existing ownCloud. + if [ -d /usr/local/lib/owncloud/ ]; then + echo "upgrading ownCloud to $owncloud_ver (backing up existing ownCloud directory to /tmp/owncloud-backup-$$ and owncloud db to /tmp/owncloud.db)..." + cp -r /usr/local/lib/owncloud /tmp/owncloud-backup-$$ + cp /home/user-data/owncloud/owncloud.db /tmp + fi + + # If we are upgrading from 8.2.x we should go to 9.0 first. Owncloud doesn't support skipping minor versions + if grep -q "8.2.[0-9]" /usr/local/lib/owncloud/version.php; then echo "We are running version 8.2.3, upgrading to 9.0.2 first" # We need to disable memcached and go with APC, the upgrade and install fails From 3f65c7133f3b1bead9bbba3320bc79636d45111b Mon Sep 17 00:00:00 2001 From: Michael Kroes Date: Sat, 30 Jul 2016 07:11:31 +0200 Subject: [PATCH 06/12] Add upgrade path from 8.1.1. Only do an upgrade check if owncloud was previously installed. --- setup/owncloud.sh | 72 ++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index ef84c6abe..e693c44be 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -95,39 +95,47 @@ if [ ! -d /usr/local/lib/owncloud/ ] \ cp /home/user-data/owncloud/owncloud.db /tmp fi - # If we are upgrading from 8.2.x we should go to 9.0 first. Owncloud doesn't support skipping minor versions - if grep -q "8.2.[0-9]" /usr/local/lib/owncloud/version.php; then - echo "We are running version 8.2.3, upgrading to 9.0.2 first" - - # We need to disable memcached and go with APC, the upgrade and install fails - # with memcached - CONFIG_TEMP=$(/bin/mktemp) - php < $CONFIG_TEMP && mv $CONFIG_TEMP $STORAGE_ROOT/owncloud/config.php; - + # We only need to check if we do upgrades when owncloud was previously installed + if [ -e /usr/local/lib/owncloud/version.php ]; then + if grep -q "8.1.[0-9]" /usr/local/lib/owncloud/version.php; then + echo "We are running 8.1.x, upgrading to 8.2.3 first" + InstallOwncloud 8.2.3 bfdf6166fbf6fc5438dc358600e7239d1c970613 + fi + + # If we are upgrading from 8.2.x we should go to 9.0 first. Owncloud doesn't support skipping minor versions + if grep -q "8.2.[0-9]" /usr/local/lib/owncloud/version.php; then + echo "We are running version 8.2.x, upgrading to 9.0.2 first" + + # We need to disable memcached and go with APC, the upgrade and install fails + # with memcached + CONFIG_TEMP=$(/bin/mktemp) + php < $CONFIG_TEMP && mv $CONFIG_TEMP $STORAGE_ROOT/owncloud/config.php; + EOF - chown www-data.www-data $STORAGE_ROOT/owncloud/config.php - - # We can now install owncloud 9.0.2 - InstallOwncloud 9.0.2 72a3d15d09f58c06fa8bee48b9e60c9cd356f9c5 - - # The owncloud 9 migration doesn't migrate calendars and contacts - # The option to migrate these are removed in 9.1 - # So the migrations should be done when we have 9.0 installed - sudo -u www-data php /usr/local/lib/owncloud/occ dav:migrate-addressbooks - # The following migration has to be done for each owncloud user - for directory in $STORAGE_ROOT/owncloud/*@*/ ; do - username=$(basename "${directory}") - sudo -u www-data php /usr/local/lib/owncloud/occ dav:migrate-calendar $username - done - sudo -u www-data php /usr/local/lib/owncloud/occ dav:sync-birthday-calendar + chown www-data.www-data $STORAGE_ROOT/owncloud/config.php + + # We can now install owncloud 9.0.2 + InstallOwncloud 9.0.2 72a3d15d09f58c06fa8bee48b9e60c9cd356f9c5 + + # The owncloud 9 migration doesn't migrate calendars and contacts + # The option to migrate these are removed in 9.1 + # So the migrations should be done when we have 9.0 installed + sudo -u www-data php /usr/local/lib/owncloud/occ dav:migrate-addressbooks + # The following migration has to be done for each owncloud user + for directory in $STORAGE_ROOT/owncloud/*@*/ ; do + username=$(basename "${directory}") + sudo -u www-data php /usr/local/lib/owncloud/occ dav:migrate-calendar $username + done + sudo -u www-data php /usr/local/lib/owncloud/occ dav:sync-birthday-calendar + fi fi InstallOwncloud $owncloud_ver 82aa7f038e2670b16e80aaf9a41260ab718a8348 From 665d5fc06dd6e4cb6d091cd0248e987269eebc25 Mon Sep 17 00:00:00 2001 From: yodax Date: Sun, 31 Jul 2016 14:58:53 +0200 Subject: [PATCH 07/12] Stop php5-fpm before owncloud upgrade to prevent database locks --- setup/owncloud.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index e693c44be..cfa365353 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -88,6 +88,9 @@ owncloud_ver=9.1.0 if [ ! -d /usr/local/lib/owncloud/ ] \ || ! grep -q $owncloud_ver /usr/local/lib/owncloud/version.php; then + # Stop php-fpm + hide_output service php5-fpm stop + # Backup the existing ownCloud. if [ -d /usr/local/lib/owncloud/ ]; then echo "upgrading ownCloud to $owncloud_ver (backing up existing ownCloud directory to /tmp/owncloud-backup-$$ and owncloud db to /tmp/owncloud.db)..." From c5f7af811a593e213006f4c1a0948c8149d63326 Mon Sep 17 00:00:00 2001 From: yodax Date: Sun, 31 Jul 2016 16:33:57 +0200 Subject: [PATCH 08/12] Fix fail2ban tests for owncloud 9 --- tests/fail2ban.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/fail2ban.py b/tests/fail2ban.py index 0f2f1e9f2..e3d168244 100644 --- a/tests/fail2ban.py +++ b/tests/fail2ban.py @@ -10,11 +10,12 @@ # parse command line -if len(sys.argv) < 2: - print("Usage: tests/fail2ban.py user@hostname") +if len(sys.argv) < 3: + print("Usage: tests/fail2ban.py user@hostname owncloud_user") sys.exit(1) ssh_user, hostname = sys.argv[1].split("@", 1) +owncloud_user = sys.argv[2] # define some test types @@ -189,7 +190,7 @@ def run_test(testfunc, args, count, within_seconds, parallel): run_test(http_test, ["/admin/munin/", 401], 20, 30, 1) # ownCloud - run_test(http_test, ["/cloud/remote.php/webdav", 401, None, None, ["aa", "aa"]], 20, 120, 1) + run_test(http_test, ["/cloud/remote.php/webdav", 401, None, None, [owncloud_user, "aa"]], 20, 120, 1) # restart fail2ban so that this client machine is no longer blocked restart_fail2ban_service(final=True) From d6bd7f77950a77933151f2709f7185069220e977 Mon Sep 17 00:00:00 2001 From: yodax Date: Mon, 1 Aug 2016 14:36:55 +0200 Subject: [PATCH 09/12] When upgrading owncloud copy the database to the user-data/owncloud-backup directory --- setup/owncloud.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index 05abb0d8d..a3ab4f419 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -93,9 +93,10 @@ if [ ! -d /usr/local/lib/owncloud/ ] \ # Backup the existing ownCloud. if [ -d /usr/local/lib/owncloud/ ]; then - echo "upgrading ownCloud to $owncloud_ver (backing up existing ownCloud directory to /tmp/owncloud-backup-$$ and owncloud db to /tmp/owncloud.db)..." + echo "upgrading ownCloud to $owncloud_ver (backing up existing ownCloud directory to /tmp/owncloud-backup-$$ and owncloud db to $STORAGE_ROOT/owncloud-backup/owncloud.db-$$)..." cp -r /usr/local/lib/owncloud /tmp/owncloud-backup-$$ - cp /home/user-data/owncloud/owncloud.db /tmp + mkdir -p $STORAGE_ROOT/owncloud-backup + cp /home/user-data/owncloud/owncloud.db $STORAGE_ROOT/owncloud-backup/owncloud.db-$$ fi # We only need to check if we do upgrades when owncloud was previously installed From 7c0b4fa2849d5b83b60cefd931358285beae6663 Mon Sep 17 00:00:00 2001 From: yodax Date: Sat, 8 Oct 2016 07:24:34 +0200 Subject: [PATCH 10/12] Remove not need unzip directives during owncloud extraction. Directory is removed beforehand so a normal extraction is fine --- setup/owncloud.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index a3ab4f419..4ba579ea8 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -39,7 +39,7 @@ InstallOwncloud() { wget_verify https://download.owncloud.org/community/owncloud-$version.zip $hash /tmp/owncloud.zip # Extract ownCloud - unzip -u -o -q /tmp/owncloud.zip -d /usr/local/lib #either extracts new or replaces current files + unzip -q /tmp/owncloud.zip -d /usr/local/lib rm -f /tmp/owncloud.zip # The two apps we actually want are not in ownCloud core. Download the releases from From 1b637086ace05083ef96a1618a9839dae1a38ee6 Mon Sep 17 00:00:00 2001 From: yodax Date: Sun, 16 Oct 2016 21:04:07 +0200 Subject: [PATCH 11/12] Improve backup of owncloud installation and provide a post installation restore script. Update the owncloud version number to 9.1.1. Update the calendar and contacts apps to the latest versions --- setup/owncloud.sh | 26 +++++++++++++-------- tools/owncloud-restore.sh | 49 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 10 deletions(-) create mode 100755 tools/owncloud-restore.sh diff --git a/setup/owncloud.sh b/setup/owncloud.sh index 4ba579ea8..f0d6ba54c 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -45,15 +45,14 @@ InstallOwncloud() { # The two apps we actually want are not in ownCloud core. Download the releases from # their github repositories. mkdir -p /usr/local/lib/owncloud/apps - wget_verify https://github.com/owncloud/contacts/releases/download/v1.3.1.0/contacts.tar.gz 8603f05dad68d1306e72befe1e672ff06165d11e /tmp/contacts.tgz + wget_verify https://github.com/owncloud/contacts/releases/download/v1.4.0.0/contacts.tar.gz c1c22d29699456a45db447281682e8bc3f10e3e7 /tmp/contacts.tgz tar xf /tmp/contacts.tgz -C /usr/local/lib/owncloud/apps/ rm /tmp/contacts.tgz - wget_verify https://github.com/owncloud/calendar/releases/download/v1.3.1/calendar.tar.gz 3b8aecd7c31a2b59721c826d9b2a2ebb619e25c6 /tmp/calendar.tgz + wget_verify https://github.com/nextcloud/calendar/releases/download/v1.4.0/calendar.tar.gz c84f3170efca2a99ea6254de34b0af3cb0b3a821 /tmp/calendar.tgz tar xf /tmp/calendar.tgz -C /usr/local/lib/owncloud/apps/ rm /tmp/calendar.tgz - # Fix weird permissions. chmod 750 /usr/local/lib/owncloud/{apps,config} @@ -82,7 +81,7 @@ InstallOwncloud() { fi } -owncloud_ver=9.1.0 +owncloud_ver=9.1.1 # Check if ownCloud dir exist, and check if version matches owncloud_ver (if either doesn't - install/upgrade) if [ ! -d /usr/local/lib/owncloud/ ] \ @@ -92,11 +91,18 @@ if [ ! -d /usr/local/lib/owncloud/ ] \ hide_output service php5-fpm stop # Backup the existing ownCloud. + # Create a backup directory to store the current installation and database to + BACKUP_DIRECTORY=$STORAGE_ROOT/owncloud-backup/`date +"%Y-%m-%d-%T"` + mkdir -p "$BACKUP_DIRECTORY" if [ -d /usr/local/lib/owncloud/ ]; then - echo "upgrading ownCloud to $owncloud_ver (backing up existing ownCloud directory to /tmp/owncloud-backup-$$ and owncloud db to $STORAGE_ROOT/owncloud-backup/owncloud.db-$$)..." - cp -r /usr/local/lib/owncloud /tmp/owncloud-backup-$$ - mkdir -p $STORAGE_ROOT/owncloud-backup - cp /home/user-data/owncloud/owncloud.db $STORAGE_ROOT/owncloud-backup/owncloud.db-$$ + echo "upgrading ownCloud to $owncloud_ver (backing up existing ownCloud installation, configuration and database to directory to $BACKUP_DIRECTORY..." + cp -r /usr/local/lib/owncloud "$BACKUP_DIRECTORY/owncloud-install" + fi + if [ -e /home/user-data/owncloud/owncloud.db ]; then + cp /home/user-data/owncloud/owncloud.db $BACKUP_DIRECTORY + fi + if [ -e /home/user-data/owncloud/config.php ]; then + cp /home/user-data/owncloud/config.php $BACKUP_DIRECTORY fi # We only need to check if we do upgrades when owncloud was previously installed @@ -110,7 +116,7 @@ if [ ! -d /usr/local/lib/owncloud/ ] \ if grep -q "8.2.[0-9]" /usr/local/lib/owncloud/version.php; then echo "We are running version 8.2.x, upgrading to 9.0.2 first" - # We need to disable memcached and go with APC, the upgrade and install fails + # We need to disable memcached. The upgrade and install fails # with memcached CONFIG_TEMP=$(/bin/mktemp) php < $CONFIG_TEMP && mv $CONFIG_TEMP $STORAGE_ROOT/owncloud/config.php; @@ -142,7 +148,7 @@ EOF fi fi - InstallOwncloud $owncloud_ver 82aa7f038e2670b16e80aaf9a41260ab718a8348 + InstallOwncloud $owncloud_ver 72ed9812432f01b3a459c4afc33f5c76b71eec09 fi # ### Configuring ownCloud diff --git a/tools/owncloud-restore.sh b/tools/owncloud-restore.sh new file mode 100755 index 000000000..0e6a07563 --- /dev/null +++ b/tools/owncloud-restore.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# +# This script will restore the backup made during an installation +source /etc/mailinabox.conf # load global vars + +if [ -z "$1" ]; then + echo "Usage: owncloud-restore.sh " + echo + echo "WARNING: This will restore the database to the point of the installation!" + echo " This means that you will lose all changes made by users after that point" + echo + echo + echo "Backups are stored here: $STORAGE_ROOT/owncloud-backup/" + echo + echo "Available backups:" + echo + find $STORAGE_ROOT/owncloud-backup/* -maxdepth 0 -type d + echo + echo "Supply the directory that was created during the last installation as the only commandline argument" + exit +fi + +if [ ! -f $1/config.php ]; then + echo "This isn't a valid backup location" + exit +fi + +echo "Restoring backup from $1" +service php5-fpm stop + +# remove the current owncloud installation +rm -rf /usr/local/lib/owncloud/ +# restore the current owncloud application +cp -r "$1/owncloud-install" /usr/local/lib/owncloud + +# restore access rights +chmod 750 /usr/local/lib/owncloud/{apps,config} + +cp "$1/owncloud.db" $STORAGE_ROOT/owncloud/ +cp "$1/config.php" $STORAGE_ROOT/owncloud/ + +ln -sf $STORAGE_ROOT/owncloud/config.php /usr/local/lib/owncloud/config/config.php +chown -f -R www-data.www-data $STORAGE_ROOT/owncloud /usr/local/lib/owncloud +chown www-data.www-data $STORAGE_ROOT/owncloud/config.php + +sudo -u www-data php /usr/local/lib/owncloud/occ maintenance:mode --off + +service php5-fpm start +echo "Done" From 8bf42a633c193775840aa51a62300bb64be0ece0 Mon Sep 17 00:00:00 2001 From: yodax Date: Mon, 17 Oct 2016 06:56:55 +0200 Subject: [PATCH 12/12] Separate the ownCloud upgrades visually in the console output. --- setup/owncloud.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup/owncloud.sh b/setup/owncloud.sh index f0d6ba54c..deb46cb97 100755 --- a/setup/owncloud.sh +++ b/setup/owncloud.sh @@ -29,6 +29,10 @@ if [ ! -f $STORAGE_ROOT/owncloud/config.php ] \ fi InstallOwncloud() { + echo + echo "Upgrading to ownCloud version $1" + echo + version=$1 hash=$2