Skip to content

Commit

Permalink
nc-nextcloud: disable .user.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Mar 5, 2019
1 parent bf1fc1f commit 9c39606
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bin/ncp/CONFIG/nc-limits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ configure()
AUTOMEM=$(( TOTAL_MEM * 75 / 100 ))

# MAX FILESIZE
local CONF=/var/www/nextcloud/.user.ini
local CONF=/etc/php/${PHPVER}/fpm/conf.d/90-ncp.ini
local CURRENT_FILE_SIZE="$( grep "^upload_max_filesize" "$CONF" | sed 's|.*=||' )"
[[ "$MAXFILESIZE" == "0" ]] && MAXFILESIZE=10G

# MAX PHP MEMORY
local CONF=/var/www/nextcloud/.user.ini
local CONF=/etc/php/${PHPVER}/fpm/conf.d/90-ncp.ini
local CURRENT_PHP_MEM="$( grep "^memory_limit" "$CONF" | sed 's|.*=||' )"
[[ "$MEMORYLIMIT" == "0" ]] && MEMORYLIMIT=$AUTOMEM && echo "Using ${AUTOMEM}B for PHP"
sed -i "s/^post_max_size=.*/post_max_size=$MAXFILESIZE/" "$CONF"
Expand Down
24 changes: 17 additions & 7 deletions bin/ncp/CONFIG/nc-nextcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,23 @@ EOF
echo "Setting up system..."

## SET LIMITS
sed -i "s/post_max_size=.*/post_max_size=$MAXFILESIZE/" /var/www/nextcloud/.user.ini
sed -i "s/upload_max_filesize=.*/upload_max_filesize=$MAXFILESIZE/" /var/www/nextcloud/.user.ini
sed -i "s/memory_limit=.*/memory_limit=$MEMORYLIMIT/" /var/www/nextcloud/.user.ini

# slow transfers will be killed after this time
cat >> /var/www/nextcloud/.user.ini <<< "max_execution_time=$MAXTRANSFERTIME"
cat >> /var/www/nextcloud/.user.ini <<< "max_input_time=$MAXTRANSFERTIME"
cat > /etc/php/${PHPVER}/fpm/conf.d/90-ncp.ini <<EOF
; disable .user.ini files for performance and workaround NC update bugs
user_ini.filename =
; from Nextcloud .user.ini
upload_max_filesize=$MAXFILESIZE
post_max_size=$MAXFILESIZE
memory_limit=$MEMORYLIMIT
mbstring.func_overload=0
always_populate_raw_post_data=-1
default_charset='UTF-8'
output_buffering=0
; slow transfers will be killed after this time
max_execution_time=$MAXTRANSFERTIME
max_input_time=$MAXTRANSFERTIME
EOF

## SET CRON
echo "*/15 * * * * php -f /var/www/nextcloud/cron.php" > /tmp/crontab_http
Expand Down
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

[v1.8.2](https://github.com/nextcloud/nextcloudpi/commit/3315e2e) (2019-02-23) nc-limits: autocalculate database memory
[v1.8.3](https://github.com/nextcloud/nextcloudpi/commit/978fb73) (2019-02-23) nc-nextcloud: disable .user.ini

[v1.8.2](https://github.com/nextcloud/nextcloudpi/commit/1dfa11a) (2019-02-23) nc-limits: autocalculate database memory

[v1.8.1 ](https://github.com/nextcloud/nextcloudpi/commit/2a0dc38) (2019-02-22) lamp: adjust mariadb parameters

Expand Down
27 changes: 26 additions & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ cp -r ncp-app /var/www/
# fix LE update bug
[[ -d /etc/letsencrypt/archive ]] || {
sleep 3
cp -ravT /etc/letsencrypt-old/archive /etc/letsencrypt/archive || true
cp -ravT /etc/letsencrypt-old/archive /etc/letsencrypt/archive &>/dev/null || true
bash -c "sleep 2 && service apache2 reload" &>/dev/null &
}

Expand Down Expand Up @@ -207,6 +207,31 @@ EOF
ncc maintenance:mode --off
}

# disable .user.ini
PHPVER=7.2
[[ -f /etc/php/${PHPVER}/fpm/conf.d/90-ncp.ini ]] || {
MAXFILESIZE="$(grep upload_max_filesize /var/www/nextcloud/.user.ini | cut -d= -f2)"
MEMORYLIMIT="$(grep memory_limit /var/www/nextcloud/.user.ini | cut -d= -f2)"
cat > /etc/php/${PHPVER}/fpm/conf.d/90-ncp.ini <<EOF
; disable .user.ini files for performance and workaround NC update bugs
user_ini.filename =
; from Nextcloud .user.ini
upload_max_filesize=$MAXFILESIZE
post_max_size=$MAXFILESIZE
memory_limit=$MEMORYLIMIT
mbstring.func_overload=0
always_populate_raw_post_data=-1
default_charset='UTF-8'
output_buffering=0
; slow transfers will be killed after this time
max_execution_time=3600
max_input_time=3600
EOF
bash -c "sleep 3 && service php$PHPVER-fpm restart" &
}

# remove redundant opcache configuration. Leave until update bug is fixed -> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815968
# Bug #416 reappeared after we moved to php7.2 and debian buster packages. (keep last)
[[ "$( ls -l /etc/php/7.2/fpm/conf.d/*-opcache.ini | wc -l )" -gt 1 ]] && rm "$( ls /etc/php/7.2/fpm/conf.d/*-opcache.ini | tail -1 )"
Expand Down

0 comments on commit 9c39606

Please sign in to comment.