Manually upgrade owncloud from 10.3.2 to 10.4.0

จาก Wiki Opensource

ปรับปรุงล่าสุดเมื่อ 18-03-2563
โดย วิบูลย์

///// This is not shell script, you run one command at a time. 
///// php command line use php7.2

///// 10.3.2 to 10.4.0
///// Manual upgrade need root privileged
sudo su -

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

///// Check and download latest
mkdir mytmp
cd mytmp
wget https://download.owncloud.org/community/owncloud-10.4.0.tar.bz2
tar -xjf owncloud-10.4.0.tar.bz2 
cd ..

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

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

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

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

///// Disable Core Apps
sudo -u www-data php7.2 owncloud/occ app:disable activity
sudo -u www-data php7.2 owncloud/occ app:disable files_pdfviewer
sudo -u www-data php7.2 owncloud/occ app:disable files_texteditor
sudo -u www-data php7.2 owncloud/occ app:disable files_mediaviewer

///// Stop web server
service apache2 stop

///// Use latest owncloud directory
mv owncloud owncloud10.3.2
mv mytmp/owncloud .
cp owncloud10.3.2/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 php7.2 owncloud/occ upgrade

2020-03-18T07:09:20+00:00 Set log level to debug
2020-03-18T07:09:20+00:00 Repair step: Upgrade app code from the marketplace
2020-03-18T07:09:20+00:00 Repair info: Using market to update existing apps
2020-03-18T07:09:20+00:00 Repair info: Attempting to update the following missing apps from market: templateeditor, twofactor_totp
2020-03-18T07:09:20+00:00 Repair info: Fetching app from market: templateeditor
2020-03-18T07:09:35+00:00 Repair info: Fetching app from market: twofactor_totp
Waiting for a long time......
Note
The Market app — and other apps from the Marketplace — will not be updated when you upgrade ownCloud, if upgrade.automatic-app-update is set to true in config.php. In addition, if there are installed apps (whether compatible or incompatible with the next version, or missing source code) and the Market app is enabled but there is no available internet connection, these apps will need to be manually updated once the upgrade is finished.

///// Output update successful
2020-03-18T07:23:58+00:00 Starting code integrity check...
2020-03-18T07:24:03+00:00 Finished code integrity check
2020-03-18T07:24:03+00:00 Update successful
2020-03-18T07:24:03+00:00 Maintenance mode is kept active
2020-03-18T07:24:03+00:00 Reset log level


///// copy folder of Core Apps from old that disable before upgrade
cp -rp owncloud10.3.2/apps/activity/ owncloud/apps/
cp -rp owncloud10.3.2/apps/files_pdfviewer/ owncloud/apps/
cp -rp owncloud10.3.2/apps/files_texteditor/ owncloud/apps/
cp -rp owncloud10.3.2/apps/files_mediaviewer/ 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/files_mediaviewer/

///// do enable core apps activity, files_pdfviewer, files_texteditor and mediaviewer
sudo -u www-data php7.2 owncloud/occ app:enable activity
sudo -u www-data php7.2 owncloud/occ app:enable files_pdfviewer
sudo -u www-data php7.2 owncloud/occ app:enable files_texteditor
sudo -u www-data php7.2 owncloud/occ app:enable files_mediaviewer

///// Then, do 
sudo -u www-data php7.2 owncloud/occ maintenance:mode --off

///// HTTP APIs have been added with Server 10.3
-WebDAV Trash bin API.
-OCS API for public link share email notifications
-WebDAV endpoint for public links.
explicitly enable them using the new config.php option: 'dav.enable.tech_preview' ⇒ true,.

///// Testing via web interface, login as admin
https://servername.domain

///// If do disable core apps, 
review settings > apps > show disabled apps

///// If use cron, then start cron. (ownCloud 10.3+ use system:cron)
vi /etc/cron.d/owncloud-cron-dot-php
*/15  *  *  *  * www-data php7.2 -f /var/www/html/owncloud/occ system:cron

///// 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.
[OK]
Check that your other settings are correct.
[OK]
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 mediaviewer]
Re-enable your third-party apps if neccessary.
[OK none]

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

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

///// create a bash file named setting-strong-directory-permissions.sh
------------------------ Start script --------------
#!/bin/bash
ocpath='/var/www/html/owncloud'
ocdata='/var/www/html/owncloud/data'
htuser='www-data'
htgroup='www-data'
rootuser='root'

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 ]
 then
  chmod 0644 ${ocpath}/.htaccess
  chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocdata}/.htaccess ]
 then
  chmod 0644 ${ocdata}/.htaccess
  chown ${rootuser}:${htgroup} ${ocdata}/.htaccess
fi
------------------------ End script --------------

//// Run bash script
bash setting-strong-directory-permissions.sh

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