From ff74a2f3b5b2ea97f5d1f148910515e26b376c48 Mon Sep 17 00:00:00 2001 From: James Hogarth Date: Mar 01 2017 00:49:06 +0000 Subject: Update to 10.0.4 This also includes: - a few php7+ bug fixes - systemd based cron for background tasks - migration steps from owncloud --- diff --git a/nextcloud-10.0.3-dont-check-php-version.patch b/nextcloud-10.0.3-dont-check-php-version.patch index a0dbb17..77bd1ef 100644 --- a/nextcloud-10.0.3-dont-check-php-version.patch +++ b/nextcloud-10.0.3-dont-check-php-version.patch @@ -25,6 +25,31 @@ index b2724db..149c265 100644 function exceptionHandler($exception) { echo "An unhandled exception has been thrown:" . PHP_EOL; echo $exception; +diff --git a/cron.php b/cron.php +index 4473dba..7a4e1a6 100644 +--- a/cron.php ++++ b/cron.php +@@ -30,20 +30,6 @@ + * + */ + +-// Show warning if a PHP version below 5.4.0 is used +-if (version_compare(PHP_VERSION, '5.4.0') === -1) { +- echo 'This version of Nextcloud requires at least PHP 5.4.0
'; +- echo 'You are currently running ' . PHP_VERSION . '. Please update your PHP version.'; +- return; +-} +- +-// Show warning if PHP 7.1 is used as Nextcloud is not compatible with PHP 7.1 for now +-// @see https://github.com/nextcloud/docker-ci/issues/10 +-if (version_compare(PHP_VERSION, '7.1.0') !== -1) { +- echo 'This version of Nextcloud is not compatible with PHP 7.1.
'; +- echo 'You are currently running ' . PHP_VERSION . '.'; +- return; +-} + + try { + diff --git a/index.php b/index.php index e72d38c..29920d7 100644 --- a/index.php diff --git a/nextcloud-10.0.4-correct-cli-upgrade.patch b/nextcloud-10.0.4-correct-cli-upgrade.patch new file mode 100644 index 0000000..3a52aaa --- /dev/null +++ b/nextcloud-10.0.4-correct-cli-upgrade.patch @@ -0,0 +1,43 @@ +diff --git a/core/templates/update.admin.php b/core/templates/update.admin.php +index 87f9396..368a533 100644 +--- a/core/templates/update.admin.php ++++ b/core/templates/update.admin.php +@@ -37,7 +37,7 @@ + +
+ t('To avoid timeouts with larger installations, you can instead run the following command from your installation directory:')) ?> +-
./occ upgrade
++
sudo -u apache php /usr/share/nextcloud/occ upgrade
+
+ + +diff --git a/core/templates/update.use-cli.php b/core/templates/update.use-cli.php +index 52d40cd..945d4d9 100644 +--- a/core/templates/update.use-cli.php ++++ b/core/templates/update.use-cli.php +@@ -7,8 +7,10 @@ + } else { + p($l->t('Please use the command line updater because automatic updating is disabled in the config.php.')); + } ?>

+- t('For help, see the documentation.', [link_to_docs('admin-cli-upgrade')])); ?>

++ ++sudo -u apache php /usr/share/nextcloud/occ upgrade ++ ++

+ + + +diff --git a/updater/index.php b/updater/index.php +index 017ca70..085c250 100644 +--- a/updater/index.php ++++ b/updater/index.php +@@ -1830,7 +1830,7 @@ if(strpos($updaterUrl, 'index.php') === false) { + var el = document.getElementById('step-maintenance-mode') + .getElementsByClassName('output')[0]; + if (keepActive) { +- el.innerHTML = 'Maintenance mode will kept active.
Now trigger the migration via command line: ./occ upgrade
'; ++ el.innerHTML = 'Maintenance mode will kept active.
Now trigger the migration via command line: sudo -u apache php /usr/share/nextcloud/occ upgrade
'; + successStep('step-maintenance-mode'); + currentStep('step-done'); + performStep(11, performStepCallbacks[11]); diff --git a/nextcloud-MIGRATION.fedora b/nextcloud-MIGRATION.fedora index e3c1e11..454ed69 100644 --- a/nextcloud-MIGRATION.fedora +++ b/nextcloud-MIGRATION.fedora @@ -1,47 +1,165 @@ -Migration from owncloud -======================= +# Migration from owncloud + +When migrating from an existing owncloud install it's possible to use the same database, +or to rename the database to reduce confusion. + +Before carrying out the migration it is important to prevent anyone from changing things. + +Of course it's advised to carry out a backup of the database and files before any migration. ### Prevent people using owncloud sudo -u apache php /usr/share/owncloud/occ maintenance:mode --on +### Migration whilst keeping owncloud data intact + +This is the safest option as it is nondestructive to owncloud, but it will require +double the data storage during the migration. -### If enough disk space for temporary double data usage -## Copy data over from one location to the other +#### Copy data over from one location to the other +The data layout is identical, it's just the location that differs. +``` rsync -aPh /var/lib/owncloud/ /var/lib/nextcloud/ +``` -## If wanting to rename the database +## Renaming the database +This is optional but might serve to confuse less, and prevents any changes to the owncloud +database in case there are issues requiring a fallback. Naturally use better credentials and +use the correct database names for your setup! + +##### MySQL +``` mysql -e 'create database nextclouddb;' mysql -e "grant all on nextclouddb.* to 'nextcloud_user'@'localhost' identified by 'nextcloud_pass';" mysqldump -v ownclouddb | mysql -D nextclouddb +``` + +##### PostgreSQL +``` +sudo -u postgres psql < pg_backend_pid(); + /* CLONE DATABASE TO NEW ONE(nextclouddb) */ + CREATE DATABASE nextclouddb WITH TEMPLATE ownclouddb OWNER nextcloud_user; -### If not enough space for temporary double data -## Copy data over from one location to the other + GRANT ALL PRIVILEGES ON DATABASE nextclouddb TO nextcloud_user; + +/* The tables need to be transferred in owner as well */ +\c nextclouddb; +REASSIGN OWNED BY owncloud_user TO nextcloud_user; + EOF + +``` +Don't forget to update pg_hba.conf to allow access to the new database as the new user! + +``` +host nextclouddb nextcloud_user ::1/128 password +host nextclouddb nextcloud_user 127.0.0.1/32 password +``` + +### Migration in place without preserving owncloud data + +If there is not sufficient disk then data can be moved, this will break owncloud in the process +and there won't be a fallback option if things go wrong beyond restiring data/backups. + +#### Copy data over from one location to the other +``` mv /var/lib/owncloud/* /var/lib/nextcloud/ +``` + +#### Renaming the database +This is even more optional since the old database will be destroyed in the process, but it may serve +to lessen confusion later on for future maintenance. Again replace with the desired credentials and +database names for your environment. -## If wanting to rename the database -mysql -e 'create database nextclouddb' +Note that since the database sizes are small it's more reliable and safer for the data stores to follow +the steps to duplicate the database laid out above. + +##### MySQL +``` +mysql -e 'create database nextclouddb;' mysql -e "grant all on nextclouddb.* to 'nextcloud_user'@'localhost' identified by 'nextcloud_pass';" mysql ownclouddb -sNe 'show tables' | while read table; do mysql -sNe "rename table ownclouddb.$table to nextclouddb.$table;"; done +``` + +##### PostgreSQL +``` +sudo -u postgres psql < pg_backend_pid(); + + /* ALTER DATABASE to rename it */ + ALTER DATABASE ownclouddb RENAME TO nextclouddb; + ALTER DATABASE nextclouddb OWNER TO nextcloud_user; + + GRANT ALL PRIVILEGES ON DATABASE nextclouddb TO nextcloud_user; + +/* The tables need to be transferred in owner as well */ +\c nextclouddb; +REASSIGN OWNED BY owncloud_user TO nextcloud_user; +EOF +``` +Again remember to update pg_hba.conf so the new database and user can be used. ### Bring over the old configuration and update paths +The config can be copied as-is which will preserve most settings. This is a coarse rename of everything +from owncloud to nextcloud, but if the database isn't renamed then this too much. Verify the database +credentials and name in the config file are correct before moving on to the next step. +``` cp /etc/owncloud/config.php /etc/nextcloud/config.php sed -i '/owncloud/nextcloud/g' /etc/nextcloud/config.php - +``` ### Enable the nextcloud interface on httpd +If using httpd then enable the interface the same way as the README describes for a fresh install +``` ln -s /etc/httpd/conf.d/nextcloud-access.conf.avail /etc/httpd/conf.d/z-nextcloud-access.conf +``` ### Carry out any migration required -sudo -u apache php /usr/share/nextcloud/occ upgrade +A migration step for database schemas etc needs to be carried out to ensure everything is correct. +Although the WebUI will be prompting the standard "click here to update" it is best for this major +migration to carry it out at the command line. +``` +sudo -u apache php /usr/share/nextcloud/occ upgrade +``` -### Enable allow people to use nextcloud +### Verify that everything looks right +It's best at this stage to enter as an admin and have the instance in single user mode only +``` +sudo -u apache php /usr/share/nextcloud/occ maintenance:singleuser --on sudo -u apache php /usr/share/nextcloud/occ maintenance:mode --off +``` +__NOTE__ It is usual for things like webdav to be disabled during singleuser which may prevent seeing +files, however just use this to verify the admin screens. On testing apps needed to be disabled +and then enabled again for nextcloud to correctly pick them up. - -### Clean up the owncloud stuff after testing +### Enable allow people to use nextcloud +If things are looking good then open the floodgates to everyone else. +``` +sudo -u apache php /usr/share/nextcloud/occ maintenance:singleuser --off +``` + +### Clean up the owncloud stuff +Finally clean up the old owncloud install, replace with the database and user for your own setup. +``` dnf remove -y owncloud\* -rm -rf /var/lib/owncloud /etc/owncloud -mysql -e 'drop database ownclouddb;' +rm -rf /var/lib/owncloud /etc/owncloud /etc/httpd/conf.d/*owncloud* +# mysql +mysql -e "drop database ownclouddb; drop user owncloud_user@'localhost';" +# postgres +sudo -u postgres psql < + + php_value upload_max_filesize 10G + php_value post_max_size 10G + php_value memory_limit 512M + php_value mbstring.func_overload 0 + php_value always_populate_raw_post_data -1 + php_value default_charset 'UTF-8' + php_value output_buffering off + + SetEnv htaccessWorking true + + + # The rewrites for legacy caldav and carddav URLs are omitted here # because they do not work with Fedora's ownCloud directory layout. # See https://github.com/nextcloud/core/issues/243#issuecomment-75426453 diff --git a/nextcloud-systemd-timer.service b/nextcloud-systemd-timer.service new file mode 100644 index 0000000..ccff38f --- /dev/null +++ b/nextcloud-systemd-timer.service @@ -0,0 +1,8 @@ +[Unit] +Description=Cron for nextcloud background jobs + +[Service] +Type=oneshot +ExecStart=/usr/bin/php -f /usr/share/nextcloud/cron.php +User=apache + diff --git a/nextcloud-systemd-timer.timer b/nextcloud-systemd-timer.timer new file mode 100644 index 0000000..cfaf4b7 --- /dev/null +++ b/nextcloud-systemd-timer.timer @@ -0,0 +1,10 @@ +[Unit] +Description=This triggers the nextcloud cron service + +[Timer] +OnBootSec=5min +OnUnitInactiveSec=15min + +[Install] +WantedBy=timers.target + diff --git a/nextcloud.spec b/nextcloud.spec index da80b1b..fe499bf 100644 --- a/nextcloud.spec +++ b/nextcloud.spec @@ -1,5 +1,5 @@ Name: nextcloud -Version: 10.0.3 +Version: 10.0.4 Release: 1%{?dist} Summary: Private file sync and share server @@ -25,6 +25,7 @@ Source103: %{name}-defaults.inc Source3: %{name}-README.fedora Source4: %{name}-mysql.txt Source5: %{name}-postgresql.txt +Source6: %{name}-MIGRATION.fedora # config.php containing just settings we want to specify, nextcloud's # initial setup will fill out other settings appropriately Source7: %{name}-config.php @@ -32,6 +33,10 @@ Source7: %{name}-config.php # Our autoloader for core Source8: %{name}-fedora-autoloader.php +# Systemd timer for background jobs +Source10: %{name}-systemd-timer.service +Source11: %{name}-systemd-timer.timer + # Stop OC from trying to do stuff to .htaccess files. Just calm down, OC. # Distributors are on the case. Patch1: %{name}-9.1.0-dont_update_htacess.patch @@ -53,8 +58,14 @@ Patch6: %{name}-463e2ea-php71-backport.patch Patch7: %{name}-b129d5d-php71-backport.patch Patch8: %{name}-10.0.3-dont-check-php-version.patch +# Direct the admin to the correct cli command for upgrades +Patch9: %{name}-10.0.4-correct-cli-upgrade.patch + BuildArch: noarch +# For the systemd macros +%{?systemd_requires} +BuildRequires: systemd # expand pear macros on install BuildRequires: php-pear @@ -467,6 +478,7 @@ find . -name .github -type d -prune -exec rm -r {} \; -print cp %{SOURCE3} README.fedora cp %{SOURCE4} README.mysql cp %{SOURCE5} README.postgresql +cp %{SOURCE6} MIGRATION.fedora mv 3rdparty/composer.json 3rdparty_composer.json mv apps/files_external/3rdparty/composer.json files_external_composer.json @@ -720,6 +732,9 @@ install -Dpm 644 %{SOURCE202} \ %{buildroot}%{_sysconfdir}/php-fpm.d/%{name}.conf %endif +# Install the systemd timer +install -Dpm 644 %{SOURCE10} %{buildroot}%{_unitdir}/nextcloud-cron.service +install -Dpm 644 %{SOURCE11} %{buildroot}%{_unitdir}/nextcloud-cron.timer %post httpd /usr/bin/systemctl reload httpd.service > /dev/null 2>&1 || : @@ -765,7 +780,7 @@ semanage fcontext -d -t httpd_sys_rw_content_t '%{_localstatedir}/lib/%{name}(/. fi %files -%doc AUTHORS README.fedora config/config.sample.php +%doc AUTHORS README.fedora MIGRATION.fedora config/config.sample.php %doc *_composer.json %license *-LICENSE @@ -782,6 +797,8 @@ fi %dir %attr(0750,apache,apache) %{_localstatedir}/lib/%{name}/data %attr(-,apache,apache) %{_localstatedir}/lib/%{name}/apps +%{_unitdir}/nextcloud-cron.service +%{_unitdir}/nextcloud-cron.timer %files httpd %config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf @@ -801,6 +818,11 @@ fi %changelog +* Tue Feb 28 2017 James Hogarth - 10.0.4-1 +- update to 10.0.4 +- Add migration from owncloud documentation +- Add systemd timer for background jobs + * Wed Feb 08 2017 James Hogarth - 10.0.3-1 - update to 10.0.3