1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nextcloud_ynh.git synced 2024-09-03 19:55:57 +02:00

Update to nextcloud 12 (closes #36 and #38) (#37)

* Update to nextcloud 12
* Add correct rights
* Fix temp directory rights on upgrade
* Add server tuning
* Update php-fpm.conf
* Add new helper for fpm config
* [fix] Opcache
* [fix] nginx SAMEORIGIN
This commit is contained in:
Rafi59 2017-08-03 17:26:39 +02:00 committed by JimboJoe
parent 2ab89810c6
commit 5d81287933
10 changed files with 118 additions and 10 deletions

View file

@ -5,9 +5,9 @@ Nextcloud for YunoHost
own data. A personal cloud which run on your own server. With Nextcloud
you can synchronize your files over your devices.
**Shipped version:** 11.0.3
**Shipped version:** 12.0.0
[![Install Nextcloud with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=nextcloud)
![Install Nextcloud with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=nextcloud)
![](https://github.com/nextcloud/screenshots/blob/master/files/filelist.png)

View file

@ -15,7 +15,6 @@ location ^~ #LOCATION# {
# Add headers to serve security related headers
add_header Strict-Transport-Security "max-age=15768000;";
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
@ -77,7 +76,6 @@ location ^~ #LOCATION# {
# Add headers to serve security related headers
add_header Strict-Transport-Security "max-age=15768000;";
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;

7
conf/php-fpm.ini Normal file
View file

@ -0,0 +1,7 @@
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1

View file

@ -8,7 +8,7 @@
},
"url": "https://nextcloud.com",
"license": "AGPL-3",
"version": "11.0.3",
"version": "12.0.0",
"maintainer": {
"name": "-",
"email": "-"

View file

@ -190,4 +190,85 @@ ynh_remove_logrotate () {
if [ -e "/etc/logrotate.d/$app" ]; then
sudo rm "/etc/logrotate.d/$app"
fi
}
}
# Calculate and store a file checksum into the app settings
#
# $app should be defined when calling this helper
#
# usage: ynh_store_file_checksum file
# | arg: file - The file on which the checksum will performed, then stored.
ynh_store_file_checksum () {
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_set $app $checksum_setting_name $(sudo md5sum "$1" | cut -d' ' -f1)
}
# Verify the checksum and backup the file if it's different
# This helper is primarily meant to allow to easily backup personalised/manually
# modified config files.
#
# $app should be defined when calling this helper
#
# usage: ynh_backup_if_checksum_is_different file [compress]
# | arg: file - The file on which the checksum test will be perfomed.
# | arg: compress - 1 to compress the backup instead of a simple copy
# A compression is needed for a file which will be analyzed even if its name is different.
#
# | ret: Return the name a the backup file, or nothing
ynh_backup_if_checksum_is_different () {
local file=$1
local compress_backup=${2:-0} # If $2 is empty, compress_backup will set at 0
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
local checksum_value=$(ynh_app_setting_get $app $checksum_setting_name)
if [ -n "$checksum_value" ]
then # Proceed only if a value was stored into the app settings
if ! echo "$checksum_value $file" | sudo md5sum -c --status
then # If the checksum is now different
backup_file="$file.backup.$(date '+%d.%m.%y_%Hh%M,%Ss')"
if [ $compress_backup -eq 1 ]
then
sudo tar --create --gzip --file "$backup_file.tar.gz" "$file" # Backup the current file and compress
backup_file="$backup_file.tar.gz"
else
sudo cp -a "$file" "$backup_file" # Backup the current file
fi
echo "File $file has been manually modified since the installation or last upgrade. So it has been duplicated in $backup_file" >&2
echo "$backup_file" # Return the name of the backup file
fi
fi
}
# Create a dedicated php-fpm config
final_path=$1
# usage: ynh_add_fpm_config
ynh_add_fpm_config () {
finalphpconf="/etc/php5/fpm/pool.d/$app.conf"
ynh_backup_if_checksum_is_different "$finalphpconf" 1
sudo cp ../conf/php-fpm.conf "$finalphpconf"
ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf"
ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf"
ynh_replace_string "__USER__" "$app" "$finalphpconf"
sudo chown root: "$finalphpconf"
ynh_store_file_checksum "$finalphpconf"
if [ -e "../conf/php-fpm.ini" ]
then
finalphpini="/etc/php5/fpm/conf.d/20-$app.ini"
ynh_backup_if_checksum_is_different "$finalphpini" 1
sudo cp ../conf/php-fpm.ini "$finalphpini"
sudo chown root: "$finalphpini"
ynh_store_file_checksum "$finalphpini"
fi
sudo systemctl reload php5-fpm
}
# Remove the dedicated php-fpm config
#
# usage: ynh_remove_fpm_config
ynh_remove_fpm_config () {
ynh_secure_remove "/etc/php5/fpm/pool.d/$app.conf"
ynh_secure_remove "/etc/php5/fpm/conf.d/20-$app.ini" 2>&1
sudo systemctl reload php5-fpm
}

View file

@ -94,6 +94,7 @@ sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
sudo chown root: $phpfpm_conf
sudo chmod 644 $phpfpm_conf
ynh_add_fpm_config
# occ helper for the current installation
_exec_occ() {
@ -188,4 +189,4 @@ sudo chmod 644 "$cron_path"
_exec_occ background:cron
# Setup log rotation
ynh_use_logrotate "/home/yunohost.app/nextcloud/data/nextcloud.log"
ynh_use_logrotate "/home/yunohost.app/nextcloud/data/nextcloud.log"

View file

@ -127,6 +127,7 @@ sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
sudo chown root: $phpfpm_conf
sudo chmod 644 $phpfpm_conf
ynh_add_fpm_config
# Set system group in hooks
sed -i "s@#GROUP#@${app}@g" ../hooks/post_user_create

18
scripts/upgrade.d/upgrade.11.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash
# Version cible de la mise à jour de Nextcloud
VERSION="12.0.0"
# Nextcloud tarball checksum
NEXTCLOUD_SOURCE_SHA256="1b9d9cf05e657cd564a552b418fbf42d669ca51e0fd1f1f118fe44cbf93a243f"
# Load common variables and helpers
source ./_common.sh
# Source app helpers
source /usr/share/yunohost/helpers
# Load common upgrade function
source ./upgrade.d/upgrade.generic.sh
COMMON_UPGRADE # Met à jour Nextcloud vers la version suivante

View file

@ -17,9 +17,11 @@ COMMON_UPGRADE () {
# Retrieve new Nextcloud sources in a temporary directory
TMPDIR=$(mktemp -d)
# Set temp folder ownership
sudo chown -R $app: "$TMPDIR"
extract_nextcloud "$TMPDIR" "$app" # Télécharge nextcloud, vérifie sa somme de contrôle et le décompresse.
# Copy Nextcloud configuration file
sed -i "s@#DOMAIN#@${domain}@g" ../conf/config.json
sed -i "s@#DATADIR#@${DATADIR}@g" ../conf/config.json

View file

@ -1,10 +1,10 @@
#!/bin/bash
# Version cible de la mise à jour de Nextcloud
VERSION=11.0.3
VERSION=12.0.0
# Nextcloud tarball checksum sha256
NEXTCLOUD_SOURCE_SHA256=28d5ee39f31c6be20f037ad2eb300272ad9bb72a7d428eb0152c7a3fde87d545
NEXTCLOUD_SOURCE_SHA256=1b9d9cf05e657cd564a552b418fbf42d669ca51e0fd1f1f118fe44cbf93a243f
# Load common variables and helpers
source ./_common.sh