Update to 10.0.4

This also includes:
 - a few php7+ bug fixes
 - systemd based cron for background tasks
 - migration steps from owncloud
This commit is contained in:
James Hogarth 2017-03-01 00:49:06 +00:00
parent 8d3b8566de
commit ff74a2f3b5
8 changed files with 265 additions and 18 deletions

View File

@ -25,6 +25,31 @@ index b2724db..149c265 100644
function exceptionHandler($exception) { function exceptionHandler($exception) {
echo "An unhandled exception has been thrown:" . PHP_EOL; echo "An unhandled exception has been thrown:" . PHP_EOL;
echo $exception; 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<br/>';
- 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.<br/>';
- echo 'You are currently running ' . PHP_VERSION . '.';
- return;
-}
try {
diff --git a/index.php b/index.php diff --git a/index.php b/index.php
index e72d38c..29920d7 100644 index e72d38c..29920d7 100644
--- a/index.php --- a/index.php

View File

@ -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 @@
<input class="updateButton" type="button" value="<?php p($l->t('Start update')) ?>">
<div class="infogroup">
<?php p($l->t('To avoid timeouts with larger installations, you can instead run the following command from your installation directory:')) ?>
- <pre>./occ upgrade</pre>
+ <pre>sudo -u apache php /usr/share/nextcloud/occ upgrade</pre>
</div>
</div>
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.'));
} ?><br><br>
- <?php
- print_unescaped($l->t('For help, see the <a target="_blank" rel="noreferrer" href="%s">documentation</a>.', [link_to_docs('admin-cli-upgrade')])); ?><br><br>
+ <code>
+sudo -u apache php /usr/share/nextcloud/occ upgrade
+</code>
+ <br><br>
</div>
</div>
</div>
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.<br>Now trigger the migration via command line: <code>./occ upgrade</code><br>';
+ el.innerHTML = 'Maintenance mode will kept active.<br>Now trigger the migration via command line: <code>sudo -u apache php /usr/share/nextcloud/occ upgrade</code><br>';
successStep('step-maintenance-mode');
currentStep('step-done');
performStep(11, performStepCallbacks[11]);

View File

@ -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 ### Prevent people using owncloud
sudo -u apache php /usr/share/owncloud/occ maintenance:mode --on sudo -u apache php /usr/share/owncloud/occ maintenance:mode --on
### Migration whilst keeping owncloud data intact
### If enough disk space for temporary double data usage This is the safest option as it is nondestructive to owncloud, but it will require
## Copy data over from one location to the other double the data storage during the migration.
#### 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/ 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 'create database nextclouddb;'
mysql -e "grant all on nextclouddb.* to 'nextcloud_user'@'localhost' identified by 'nextcloud_pass';" mysql -e "grant all on nextclouddb.* to 'nextcloud_user'@'localhost' identified by 'nextcloud_pass';"
mysqldump -v ownclouddb | mysql -D nextclouddb mysqldump -v ownclouddb | mysql -D nextclouddb
```
##### PostgreSQL
```
sudo -u postgres psql <<EOF
/* Create the user for nextcloud */
CREATE USER nextcloud_user WITH PASSWORD 'nextcloud_pass';
### If not enough space for temporary double data /* KILL ALL EXISTING CONNECTION FROM ORIGINAL DB (ownclouddb)*/
## Copy data over from one location to the other SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'ownclouddb' AND pid <> pg_backend_pid();
/* CLONE DATABASE TO NEW ONE(nextclouddb) */
CREATE DATABASE nextclouddb WITH TEMPLATE ownclouddb OWNER 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
```
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/ mv /var/lib/owncloud/* /var/lib/nextcloud/
```
## If wanting to rename the database #### Renaming the database
mysql -e 'create database nextclouddb' 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.
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 -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 mysql ownclouddb -sNe 'show tables' | while read table; do mysql -sNe "rename table ownclouddb.$table to nextclouddb.$table;"; done
```
##### PostgreSQL
```
sudo -u postgres psql <<EOF
/* Create the user for nextcloud */
CREATE USER nextcloud_user WITH PASSWORD 'nextcloud_pass';
/* KILL ALL EXISTING CONNECTION FROM ORIGINAL DB (ownclouddb)*/
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'ownclouddb' AND pid <> 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 ### 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 cp /etc/owncloud/config.php /etc/nextcloud/config.php
sed -i '/owncloud/nextcloud/g' /etc/nextcloud/config.php sed -i '/owncloud/nextcloud/g' /etc/nextcloud/config.php
```
### Enable the nextcloud interface on httpd ### 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 ln -s /etc/httpd/conf.d/nextcloud-access.conf.avail /etc/httpd/conf.d/z-nextcloud-access.conf
```
### Carry out any migration required ### 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
```
### 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.
### Enable allow people to use nextcloud ### Enable allow people to use nextcloud
sudo -u apache php /usr/share/nextcloud/occ maintenance:mode --off 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
### Clean up the owncloud stuff after testing Finally clean up the old owncloud install, replace with the database and user for your own setup.
```
dnf remove -y owncloud\* dnf remove -y owncloud\*
rm -rf /var/lib/owncloud /etc/owncloud rm -rf /var/lib/owncloud /etc/owncloud /etc/httpd/conf.d/*owncloud*
mysql -e 'drop database ownclouddb;' # mysql
mysql -e "drop database ownclouddb; drop user owncloud_user@'localhost';"
# postgres
sudo -u postgres psql <<EOF
DROP DATABASE ownclouddb;
DROP USER owncloud_user;
EOF
```

View File

@ -104,6 +104,14 @@ dnf install 'php-pecl(apcu)'
For further information see http://nextcloud.org/ and http://doc.nextcloud.org/ For further information see http://nextcloud.org/ and http://doc.nextcloud.org/
Scheduling Background Jobs
--------------------------
The default behaviour is to use the AJAX webcron, however this is fairly inefficient and does not scale very well.
It's recommended to set the option "Cron" to use the system scheduler and to enable the included systemd timer.
systemctl enable --now nextcloud-cron.timer
Migration from owncloud Migration from owncloud
----------------------- -----------------------

View File

@ -36,6 +36,19 @@ ErrorDocument 404 /nextcloud/core/templates/404.php
</IfModule> </IfModule>
</IfModule> </IfModule>
<IfModule mod_php7.c>
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
<IfModule mod_env.c>
SetEnv htaccessWorking true
</IfModule>
</IfModule>
# The rewrites for legacy caldav and carddav URLs are omitted here # The rewrites for legacy caldav and carddav URLs are omitted here
# because they do not work with Fedora's ownCloud directory layout. # because they do not work with Fedora's ownCloud directory layout.
# See https://github.com/nextcloud/core/issues/243#issuecomment-75426453 # See https://github.com/nextcloud/core/issues/243#issuecomment-75426453

View File

@ -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

View File

@ -0,0 +1,10 @@
[Unit]
Description=This triggers the nextcloud cron service
[Timer]
OnBootSec=5min
OnUnitInactiveSec=15min
[Install]
WantedBy=timers.target

View File

@ -1,5 +1,5 @@
Name: nextcloud Name: nextcloud
Version: 10.0.3 Version: 10.0.4
Release: 1%{?dist} Release: 1%{?dist}
Summary: Private file sync and share server Summary: Private file sync and share server
@ -25,6 +25,7 @@ Source103: %{name}-defaults.inc
Source3: %{name}-README.fedora Source3: %{name}-README.fedora
Source4: %{name}-mysql.txt Source4: %{name}-mysql.txt
Source5: %{name}-postgresql.txt Source5: %{name}-postgresql.txt
Source6: %{name}-MIGRATION.fedora
# config.php containing just settings we want to specify, nextcloud's # config.php containing just settings we want to specify, nextcloud's
# initial setup will fill out other settings appropriately # initial setup will fill out other settings appropriately
Source7: %{name}-config.php Source7: %{name}-config.php
@ -32,6 +33,10 @@ Source7: %{name}-config.php
# Our autoloader for core # Our autoloader for core
Source8: %{name}-fedora-autoloader.php 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. # Stop OC from trying to do stuff to .htaccess files. Just calm down, OC.
# Distributors are on the case. # Distributors are on the case.
Patch1: %{name}-9.1.0-dont_update_htacess.patch 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 Patch7: %{name}-b129d5d-php71-backport.patch
Patch8: %{name}-10.0.3-dont-check-php-version.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 BuildArch: noarch
# For the systemd macros
%{?systemd_requires}
BuildRequires: systemd
# expand pear macros on install # expand pear macros on install
BuildRequires: php-pear BuildRequires: php-pear
@ -467,6 +478,7 @@ find . -name .github -type d -prune -exec rm -r {} \; -print
cp %{SOURCE3} README.fedora cp %{SOURCE3} README.fedora
cp %{SOURCE4} README.mysql cp %{SOURCE4} README.mysql
cp %{SOURCE5} README.postgresql cp %{SOURCE5} README.postgresql
cp %{SOURCE6} MIGRATION.fedora
mv 3rdparty/composer.json 3rdparty_composer.json mv 3rdparty/composer.json 3rdparty_composer.json
mv apps/files_external/3rdparty/composer.json files_external_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 %{buildroot}%{_sysconfdir}/php-fpm.d/%{name}.conf
%endif %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 %post httpd
/usr/bin/systemctl reload httpd.service > /dev/null 2>&1 || : /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 fi
%files %files
%doc AUTHORS README.fedora config/config.sample.php %doc AUTHORS README.fedora MIGRATION.fedora config/config.sample.php
%doc *_composer.json %doc *_composer.json
%license *-LICENSE %license *-LICENSE
@ -782,6 +797,8 @@ fi
%dir %attr(0750,apache,apache) %{_localstatedir}/lib/%{name}/data %dir %attr(0750,apache,apache) %{_localstatedir}/lib/%{name}/data
%attr(-,apache,apache) %{_localstatedir}/lib/%{name}/apps %attr(-,apache,apache) %{_localstatedir}/lib/%{name}/apps
%{_unitdir}/nextcloud-cron.service
%{_unitdir}/nextcloud-cron.timer
%files httpd %files httpd
%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf %config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf
@ -801,6 +818,11 @@ fi
%changelog %changelog
* Tue Feb 28 2017 James Hogarth <james.hogarth@gmail.com> - 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 <james.hogarth@gmail.com> - 10.0.3-1 * Wed Feb 08 2017 James Hogarth <james.hogarth@gmail.com> - 10.0.3-1
- update to 10.0.3 - update to 10.0.3