summaryrefslogtreecommitdiffstats
path: root/satellit_installer/static_files
diff options
context:
space:
mode:
authorSimon Rettberg2018-04-15 12:50:51 +0200
committerSimon Rettberg2018-04-15 12:50:51 +0200
commit6e78abc5a7c936725d880e451565119b3a85d4b6 (patch)
tree08a5875f520cb9aed969d8d03edf579d456f2eef /satellit_installer/static_files
parentRevert "[SSUS] updater.template.sh: Check for major version (Deb.) accepts 9" (diff)
downloadsetup-scripts-6e78abc5a7c936725d880e451565119b3a85d4b6.tar.gz
setup-scripts-6e78abc5a7c936725d880e451565119b3a85d4b6.tar.xz
setup-scripts-6e78abc5a7c936725d880e451565119b3a85d4b6.zip
[SSPS] Use drop-in for adjusting php child count; more error checking
Diffstat (limited to 'satellit_installer/static_files')
-rwxr-xr-xsatellit_installer/static_files/patch_lighttpd_phpchildren22
1 files changed, 14 insertions, 8 deletions
diff --git a/satellit_installer/static_files/patch_lighttpd_phpchildren b/satellit_installer/static_files/patch_lighttpd_phpchildren
index 34c90bb..a8e44e5 100755
--- a/satellit_installer/static_files/patch_lighttpd_phpchildren
+++ b/satellit_installer/static_files/patch_lighttpd_phpchildren
@@ -1,16 +1,22 @@
-#!/bin/bash
+#!/bin/sh
# Could be written in one line, but for better editing when values change...
MEM=$(grep ^MemTotal /proc/meminfo | awk '{print $2}') # RAM in KB
-MEM=$(( $MEM / 1024 / 4 )) # to MB, and assess a fourth of RAM for PHP
-CHILDREN=$(( $MEM / 16 )) # assume 16 MB per child
-# min 16, no more than 128
-[ $CHILDREN -lt 16 ] && CHILDREN=16
-[ $CHILDREN -gt 128 ] && CHILDREN=128
+MEM=$(( MEM / 1024 / 4 )) # to MB, and assess a fourth of RAM for PHP
+CHILDREN=$(( MEM / 16 )) # assume 16 MB per child
+# min 16, no more than 128 (inverse logic to handle NaN)
+[ "$CHILDREN" -ge 16 ] || CHILDREN=16
+[ "$CHILDREN" -le 128 ] || CHILDREN=128
-if [ -f /etc/lighttpd/conf-enabled/15-fastcgi-php.conf ]; then
- sed -i "s/\"PHP_FCGI_CHILDREN.*$/\"PHP_FCGI_CHILDREN\" => \"$CHILDREN\",/" /etc/lighttpd/conf-enabled/15-fastcgi-php.conf
+## Use ?? in case the ordering changes one day
+file=$(echo /etc/lighttpd/conf-enabled/??-fastcgi-php.conf)
+if [ -f "$file" ]; then
+ sed -i 's/"PHP_FCGI_CHILDREN.*$/"PHP_FCGI_CHILDREN" => "'$CHILDREN'",/' "$file"
+ if ! grep -qF '"PHP_FCGI_CHILDREN" => "'$CHILDREN'"' "$file"; then
+ echo "WARNING: Cannot adjust php cgildren count for fastcgi -- line not found in $file" >&2
+ fi
else
+ echo "WARNING: Cannot adjust php children count for fastcgi -- file not found" >&2
exit 1
fi
exit 0