Skip to content

Commit

Permalink
nc-limits: fix error when specifying units
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Sep 13, 2018
1 parent ee370f1 commit ed96a0c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions etc/ncp-config.d/nc-limits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,21 @@ configure()
# MAX PHP MEMORY
local CONF=/var/www/nextcloud/.user.ini
local CURRENT_PHP_MEM="$( grep "^memory_limit" "$CONF" | sed 's|.*=||' )"
[[ $MEMORYLIMIT_ -eq 0 ]] && MEMORYLIMIT_=$AUTOMEM && echo "Using ${AUTOMEM}B for PHP"
[[ "$MEMORYLIMIT_" == "0" ]] && MEMORYLIMIT_=$AUTOMEM && echo "Using ${AUTOMEM}B for PHP"
sed -i "s/post_max_size=.*/post_max_size=$MAXFILESIZE_/" "$CONF"
sed -i "s/upload_max_filesize=.*/upload_max_filesize=$MAXFILESIZE_/" "$CONF"
sed -i "s/memory_limit=.*/memory_limit=$MEMORYLIMIT_/" "$CONF"

# MAX PHP THREADS
local CONF=/etc/php/7.0/fpm/pool.d/www.conf
local CURRENT_THREADS=$( grep "^pm.max_children" "$CONF" | awk '{ print $3 }' )
local PHPTHREADS=0
[[ $PHPTHREADS_ -eq 0 ]] && PHPTHREADS_=$( nproc ) && echo "Using $PHPTHREADS_ PHP threads"
[[ "$PHPTHREADS_" == "0" ]] && PHPTHREADS_=$( nproc ) && echo "Using $PHPTHREADS_ PHP threads"
sed -i "s|pm.max_children =.*|pm.max_children = $PHPTHREADS_|" "$CONF"
sed -i "s|pm.max_spare_servers =.*|pm.max_spare_servers = $PHPTHREADS_|" "$CONF"
sed -i "s|pm.start_servers =.*|pm.start_servers = $PHPTHREADS_|" "$CONF"

# RESTART PHP
[[ $PHPTHREADS -ne $CURRENT_THREADS ]] || \
[[ "$PHPTHREADS_" != "$CURRENT_THREADS" ]] || \
[[ "$MEMORYLIMIT" != "$CURRENT_PHP_MEM" ]] || \
[[ "$MAXFILESIZE_" != "$CURRENT_FILE_SIZE" ]] && {
bash -c " sleep 3
Expand All @@ -60,7 +59,7 @@ configure()
# redis max memory
local CONF=/etc/redis/redis.conf
local CURRENT_REDIS_MEM=$( grep "^maxmemory" "$CONF" | awk '{ print $2 }' )
[[ $REDISMEM_ -eq 0 ]] && REDISMEM_=$AUTOMEM && echo "Using ${AUTOMEM}B for Redis"
[[ "$REDISMEM_" == "0" ]] && REDISMEM_=$AUTOMEM && echo "Using ${AUTOMEM}B for Redis"
[[ "$REDISMEM_" != "$CURRENT_REDIS_MEM" ]] && {
sed -i "s|maxmemory .*|maxmemory $REDISMEM_|" "$CONF"
service redis restart
Expand Down

0 comments on commit ed96a0c

Please sign in to comment.