Manually upgrade owncloud from 10.0.10 to 10.2.0

จาก Wiki Opensource

ปรับปรุงครั้งล่าสุดวันที่ 29-5-2562
เขียนโดย วิบูลย์

///// This is not shell script, you run one command at a time

///// 10.0.10 to 10.2.0
///// Manual upgrade need root priviledge
sudo su -

///// Working directory
cd /var/www/html

///// Inform user it is maintenance time
sudo -u www-data php owncloud/occ maintenance:mode --on

///// Check and download latest
mkdir mytmp
cd mytmp
tar xjf owncloud-10.2.0.tar.bz2 
cd ..

///// Backup first,
///// This example assumes Ubuntu Linux and MariaDB
mkdir -p /root/backupowncloud/
cp -rv /var/www/html/owncloud /root/backupowncloud/owncloud-10.0.10
mysqldump -u root -p your_db_name > /root/backupowncloud/backup-file-10.0.10.sql

///// If use cron.php, then stop cron.
vi /etc/cron.d/owncloud-cron-dot-php
#*/15  *  *  *  * www-data php -f /var/www/html/owncloud/cron.php

///// This command lists all apps by <app-id> and app version
sudo -u www-data php owncloud/occ app:list

///// Disable Core Apps
sudo -u www-data php owncloud/occ app:disable activity
sudo -u www-data php owncloud/occ app:disable files_pdfviewer
sudo -u www-data php owncloud/occ app:disable files_texteditor
sudo -u www-data php owncloud/occ app:disable gallery

///// Stop web server
service apache2 stop

///// Use latest owncloud directory
mv owncloud owncloud10.0.10
mv mytmp/owncloud .
cp owncloud10.0.10/config/config.php owncloud/config/

///// Because our owncloud data is soft link to /srv/data so I need to make a soft link
ln -s /srv/data/ owncloud/data

///// Need start apache2 before run upgrade command
service apache2 start
chown -R www-data:www-data owncloud
sudo -u www-data php owncloud/occ upgrade

///// Output update successful
2019-05-29T06:54:17+00:00 Finished code integrity check
2019-05-29T06:54:17+00:00 Update successful
2019-05-29T06:54:17+00:00 Maintenance mode is kept active
2019-05-29T06:54:17+00:00 Reset log level

///// copy folder of Core Apps from old that disable before upgrade
cp -rp owncloud10.0.10/apps/activity/ owncloud/apps/
cp -rp owncloud10.0.10/apps/files_pdfviewer/ owncloud/apps/
cp -rp owncloud10.0.10/apps/files_texteditor/ owncloud/apps/
cp -rp owncloud10.0.10/apps/gallery owncloud/apps/
chmod o+rx owncloud/apps/activity/
chmod o+rx owncloud/apps/files_pdfviewer/
chmod o+rx owncloud/apps/files_texteditor/
chmod o+rx owncloud/apps/gallery/

//// Then, do 
sudo -u www-data php owncloud/occ maintenance:mode --off

///// Testing via web interface, login as admin

///// If do disable core apps, review settings > apps > show disabled apps
do enable core apps activity, files_pdfviewer, files_texteditor and gallery

///// If use cron.php, then start cron.
vi /etc/cron.d/owncloud-cron-dot-php
*/15  *  *  *  * www-data php -f /var/www/html/owncloud/cron.php

///// Clean unwanted directories and files
rm -rf owncloud10.0.10
rm -rf mytmp

///// Finalize
With maintenance mode disabled, login and:
Check that the version number reflects the new installation. It’s visible at the bottom of your Admin page.
Check that your other settings are correct.
Go to the Apps page and review the core apps to make sure the right ones are enabled.
[OK apps activity, files_pdfviewer, files_texteditor and gallery]
Re-enable your third-party apps.
[OK none]
Apply strong permissions to your ownCloud directories.
[Setting strong directory permissions]

///// Setting strong directory permissions
///// make a directory to keep files
mkdir -p manage_owncloud
cd manage_owncloud/

///// create a bash file named
------------------------ Start script --------------

printf "Creating possible missing Directories\n"
mkdir -p $ocpath/updater

printf "chmod Files and Directories\n"
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750
find ${ocdata}/ -type f -print0 | xargs -0 chmod 0640
find ${ocdata}/ -type d -print0 | xargs -0 chmod 0750

printf "chown Directories\n"
chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocdata}/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/

chmod +x ${ocpath}/occ

printf "chmod/chown .htaccess\n"
if [ -f ${ocpath}/.htaccess ]
  chmod 0644 ${ocpath}/.htaccess
  chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
if [ -f ${ocdata}/.htaccess ]
  chmod 0644 ${ocdata}/.htaccess
  chown ${rootuser}:${htgroup} ${ocdata}/.htaccess
------------------------ End script --------------

//// Run bash script

//// output...
Creating possible missing Directories
chmod Files and Directories
chown Directories
chmod/chown .htaccess