Fixing nextcloud

This commit is contained in:
Bob Mottram 2017-05-08 21:30:19 +01:00
parent 177acbf2a2
commit b309b6d953
1 changed files with 67 additions and 25 deletions

View File

@ -177,8 +177,8 @@ function upgrade_nextcloud {
function_check set_repo_commit
set_repo_commit /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs "nextcloud commit" "$NEXTCLOUD_COMMIT" $NEXTCLOUD_REPO
chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs/config
chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs/data
chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/data
cd /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
sudo -u www-data ./occ maintenance:repair
sudo -u www-data ./occ files:cleanup
@ -192,15 +192,19 @@ function backup_local_nextcloud {
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
fi
source_directory=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
source_directory=/var/www/${NEXTCLOUD_DOMAIN_NAME}/data
if [ -d $source_directory ]; then
dest_directory=nextcloud
function_check suspend_site
suspend_site ${NEXTCLOUD_DOMAIN_NAME}
dest_directory=nextcloudfiles
function_check backup_directory_to_usb
backup_directory_to_usb $source_directory $dest_directory
source_directory=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config
dest_directory=nextcloudconfig
backup_directory_to_usb $source_directory $dest_directory
function_check backup_database_to_usb
backup_database_to_usb nextcloud
@ -215,17 +219,36 @@ function restore_local_nextcloud {
fi
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
if [ $NEXTCLOUD_DOMAIN_NAME ]; then
temp_restore_dir=/root/tempnextcloud
nextcloud_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
temp_restore_dir=/root/tempnextcloud
function_check nextcloud_create_database
nextcloud_create_database
restore_database nextcloud ${NEXTCLOUD_DOMAIN_NAME}
if [ -d $temp_restore_dir ]; then
rm -rf $temp_restore_dir
fi
temp_restore_dir=/root/tempnextcloudfiles
restore_directory_from_usb $temp_restore_dir nextcloudfiles
temp_source_dir=$(find ${temp_restore_dir} -name data)
cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/
if [ ! "$?" = "0" ]; then
set_user_permissions
backup_unmount_drive
exit 346723
fi
rm -rf ${temp_restore_dir}
temp_restore_dir=/root/tempnextcloudconfig
restore_directory_from_usb $temp_restore_dir nextcloudconfig
temp_source_dir=$(find ${temp_restore_dir} -name config)
cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/
if [ ! "$?" = "0" ]; then
set_user_permissions
backup_unmount_drive
exit 3467343
fi
rm -rf ${temp_restore_dir}
chown -R www-data:www-data /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
chown -R www-data:www-data /var/www/${NEXTCLOUD_DOMAIN_NAME}/data
cd $nextcloud_dir
sudo -u www-data ./occ maintenance:repair
sudo -u www-data ./occ files:cleanup
@ -236,7 +259,7 @@ function restore_local_nextcloud {
function backup_remote_nextcloud {
if grep -q "nextcloud domain" $COMPLETION_FILE; then
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
temp_backup_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
temp_backup_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/data
if [ -d $temp_backup_dir ]; then
function_check suspend_site
suspend_site ${NEXTCLOUD_DOMAIN_NAME}
@ -244,10 +267,11 @@ function backup_remote_nextcloud {
function_check backup_database_to_friend
backup_database_to_friend nextcloud
echo $"Backing up GNU social installation"
function_check backup_directory_to_friend
backup_directory_to_friend $temp_backup_dir nextcloud
backup_directory_to_friend $temp_backup_dir nextclouddata
temp_backup_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config
backup_directory_to_friend $temp_backup_dir nextcloudconfig
function_check restart_site
restart_site
@ -261,7 +285,6 @@ function restore_remote_nextcloud {
if grep -q "nextcloud domain" $COMPLETION_FILE; then
echo $"Restoring nextcloud"
NEXTCLOUD_DOMAIN_NAME=$(get_completion_param "nextcloud domain")
nextcloud_dir=/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
function_check nextcloud_create_database
nextcloud_create_database
@ -272,7 +295,27 @@ function restore_remote_nextcloud {
rm -rf /root/tempnextcloud
fi
cd $nextcloud_dir
temp_restore_dir=/root/tempnextcloudfiles
restore_directory_from_friend $temp_restore_dir nextcloudfiles
temp_source_dir=$(find ${temp_restore_dir} -name data)
cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/
if [ ! "$?" = "0" ]; then
exit 768254
fi
rm -rf ${temp_restore_dir}
temp_restore_dir=/root/tempnextcloudconfig
restore_directory_from_friend $temp_restore_dir nextcloudconfig
temp_source_dir=$(find ${temp_restore_dir} -name config)
cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/
if [ ! "$?" = "0" ]; then
exit 573427
fi
rm -rf ${temp_restore_dir}
chown -R www-data:www-data /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
chown -R www-data:www-data /var/www/${NEXTCLOUD_DOMAIN_NAME}/data
cd /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
sudo -u www-data ./occ maintenance:repair
sudo -u www-data ./occ files:cleanup
sudo -u www-data ./occ files:scan --all
@ -363,11 +406,6 @@ function install_nextcloud_main {
git checkout $NEXTCLOUD_COMMIT -b $NEXTCLOUD_COMMIT
set_completion_param "nextcloud commit" "$NEXTCLOUD_COMMIT"
# some extra apps
git clone https://github.com/nextcloud/gallery /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs/apps/gallery
git clone https://github.com/nextcloud/spreed /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs/apps/spreed
git clone https://github.com/nextcloud/calendar /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs/apps/calendar
chmod g+w /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
chown -R www-data:www-data /var/www/$NEXTCLOUD_DOMAIN_NAME/htdocs
@ -502,6 +540,9 @@ function install_nextcloud_main {
sed -i 's| DENY;| SAMEORIGIN;|g' $nextcloud_nginx_site
# NextCloud doesn't like content-security-policy at all
sed -i '/Content-Security-Policy/d' $nextcloud_nginx_site
function_check configure_php
configure_php
@ -557,20 +598,21 @@ function install_nextcloud_main {
./occ status
./occ app:list
./occ app:enable encryption
./occ app:enable gallery
./occ app:enable calendar
./occ app:enable spreed
./occ config:system:set defaultapp --value=gallery
./occ config:system:set appstoreenabled --value=false
./occ config:system:set trusted_domains 1 --value=$NEXTCLOUD_DOMAIN_NAME
chmod g+w /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/config.php
chown -R www-data:www-data /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
chmod 0644 .htaccess
chmod 0750 data
chown -R www-data:www-data /var/www/${NEXTCLOUD_DOMAIN_NAME}/data
sudo -u www-data ./occ files:cleanup
sudo -u www-data ./occ files:scan --all
sudo -u www-data ./occ maintenance:repair
# move the data directory
mv /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/data /var/www/${NEXTCLOUD_DOMAIN_NAME}/
sed -i "s|'datadirectory'.*|'datadirectory' => '/var/www/$NEXTCLOUD_DOMAIN_NAME/data',|g" /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/config.php
set_completion_param "nextcloud domain" "$NEXTCLOUD_DOMAIN_NAME"
install_completed nextcloud_main