summaryrefslogtreecommitdiffstats
path: root/satellit_installer
diff options
context:
space:
mode:
authorChristian Rößler2018-04-16 14:19:28 +0200
committerChristian Rößler2018-04-16 14:19:28 +0200
commit3b09644b52419aec98a711d8e3e0e28dab98f82c (patch)
treeadef8e3dde0b8de4cce3ed1b8d63e1d8d6c65375 /satellit_installer
parent[SPSS] dnbd3 server added (diff)
parent[SSUS] Update phpchild handling aswell (diff)
downloadsetup-scripts-3b09644b52419aec98a711d8e3e0e28dab98f82c.tar.gz
setup-scripts-3b09644b52419aec98a711d8e3e0e28dab98f82c.tar.xz
setup-scripts-3b09644b52419aec98a711d8e3e0e28dab98f82c.zip
Merge branch 'master' of git.openslx.org:bwlp/setup-scripts
Diffstat (limited to 'satellit_installer')
-rw-r--r--satellit_installer/includes/10-configurations.inc44
-rwxr-xr-xsatellit_installer/satellit_installer2
-rwxr-xr-xsatellit_installer/static_files/patch_lighttpd_phpchildren22
3 files changed, 33 insertions, 35 deletions
diff --git a/satellit_installer/includes/10-configurations.inc b/satellit_installer/includes/10-configurations.inc
index fdd9d61..0ab68f8 100644
--- a/satellit_installer/includes/10-configurations.inc
+++ b/satellit_installer/includes/10-configurations.inc
@@ -31,43 +31,35 @@ copy_tftpd-hpa_service() {
echo -n "# Copying tftpd-hpa service file... "
cp -p "$BASEDIR/static_files/tftpd-hpa.service" /etc/systemd/system && echo "ok." || perror "failed."
echo -n "# Linking tftpd-hpa service file into (/etc/systemd/system/)multi-user.target.wants... "
- ln -s /etc/systemd/system/tftpd-hpa.service /etc/systemd/system/multi-user.target.wants/tftpd-hpa.service \
+ ln -s ../tftpd-hpa.service /etc/systemd/system/multi-user.target.wants/tftpd-hpa.service \
&& echo "ok." || perror "Could not link tftpd-hpa service file into multiuser target!"
}
patch_lighttpd_config() {
+ local mod file
service lighttpd stop
- echo -n "# Patching lighttpd configuration..."
+ echo "# Customizing lighttpd config"
cp -p "$BASEDIR/static_files/lighttpd.conf" /etc/lighttpd/lighttpd.conf || perror "failed."
cp -p "$BASEDIR/static_files/lighttpd-auto-ssl.sh" /usr/share/lighttpd/auto-ssl.sh || perror "failed."
cp -p "$BASEDIR/static_files/lighttpd-include-conf-d.sh" /usr/share/lighttpd/include-conf-d.sh || perror "failed."
+ cp -a "$BASEDIR/static_files/patch_lighttpd_phpchildren" /usr/local/sbin/patch_lighttpd_phpchildren || perror "failed."
chmod +x /usr/share/lighttpd/auto-ssl.sh || perror "failed"
chmod +x /usr/share/lighttpd/include-conf-d.sh || perror "failed"
- echo "ok."
- cd /etc/lighttpd/conf-enabled || perror "Could not cd to conf-enabled."
- [ ! -h 10-fastcgi.conf ] && ln -s ../conf-available/10-fastcgi.conf
- [ ! -h 15-fastcgi-php.conf ] && ln -s ../conf-available/15-fastcgi-php.conf
+ chmod +x /usr/local/sbin/patch_lighttpd_phpchildren || perror "failed"
+ for mod in fastcgi fastcgi-php; do
+ file=$(echo /etc/lighttpd/conf-available/??-${mod}.conf) # expand ??
+ [ -f "$file" ] || perror "Could not find path for $mod"
+ file=$(basename "$file")
+ ln -sf "../conf-available/$file" "/etc/lighttpd/conf-enabled/$file" || perror "Could not enable module $mod"
+ done
- # Increase php threads
- echo -n "# Looking for lighttpd service file..."
- if [ -f /lib/systemd/system/lighttpd.service ]; then
- # service file found, patching dynamic php children value at system start via patchfile
- # see includes/50-copyscripts.inc for dropping patch file /usr/local/sbin/patch_lightdm_phpchildren
- if ! grep -q patch_lightdm_phpchildren /lib/systemd/system/lighttpd.service; then
- echo -n " patching service file ... "
- sed -i 's#\[Service\]#\[Service\]\nExecStartPre=\-/usr/local/sbin/patch_lighttpd_phpchildren#g' \
- /lib/systemd/system/lighttpd.service || perror "Could not patch service file!"
- cp -a "$BASEDIR/static_files/patch_lighttpd_phpchildren" /usr/local/sbin || \
- perror "Could not copy patch_lighttpd_phpchildren script!"
- chmod +x /usr/local/sbin/patch_lighttpd_phpchildren # Just to sleep better in dark nights.
- fi
- else
- # service file not found, going old static way
- echo -n " not found. Doing old, static way (PHP_FCGI_CHILDREN = 32). Please check... ".
- sed -i 's/"PHP_FCGI_CHILDREN.*$/"PHP_FCGI_CHILDREN" => "32",/' "15-fastcgi-php.conf"
- fi
- echo " done."
- mkdir -p "$1" || perror "Could not create $1."
+ # Increase php threads (set dynamically)
+ mkdir -p /etc/systemd/system/lighttpd.service.d || perror "Could not create /etc/systemd/system/lighttpd.service.d"
+ cat > "/etc/systemd/system/lighttpd.service.d/10-dynamic_php_children" <<-HDOC
+ [Service]
+ ExecStartPre=/usr/local/sbin/patch_lighttpd_phpchildren
+ HDOC
+ mkdir -p "$WWWDIR" || perror "Could not create www-dir ($WWWDIR)"
}
patch_php_config() {
diff --git a/satellit_installer/satellit_installer b/satellit_installer/satellit_installer
index 260ec4b..e506196 100755
--- a/satellit_installer/satellit_installer
+++ b/satellit_installer/satellit_installer
@@ -125,7 +125,7 @@ patch_mysql_config # adding utf8 entries to /etc/mysql/my.cnf
patch_tftpd-hpa_config
copy_tftpd-hpa_service
-patch_lighttpd_config "$WWWDIR" # $1: lighttpd http root
+patch_lighttpd_config
patch_php_config
write_tmate_config # here or elsewhere...
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