summaryrefslogtreecommitdiffstats
path: root/adei/scripts/run-apache.sh
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2018-02-20 16:16:15 +0100
committerSuren A. Chilingaryan <csa@suren.me>2018-02-20 16:16:15 +0100
commit3d19ce5671e45b8e06a91cb09065d81e22f9d6fd (patch)
treee6221f12bdc4c48f5dc919874265633e3709559c /adei/scripts/run-apache.sh
downloadadei-3d19ce5671e45b8e06a91cb09065d81e22f9d6fd.tar.gz
adei-3d19ce5671e45b8e06a91cb09065d81e22f9d6fd.tar.bz2
adei-3d19ce5671e45b8e06a91cb09065d81e22f9d6fd.tar.xz
adei-3d19ce5671e45b8e06a91cb09065d81e22f9d6fd.zip
Initial import
Diffstat (limited to 'adei/scripts/run-apache.sh')
-rwxr-xr-xadei/scripts/run-apache.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/adei/scripts/run-apache.sh b/adei/scripts/run-apache.sh
new file mode 100755
index 0000000..3ad9d5f
--- /dev/null
+++ b/adei/scripts/run-apache.sh
@@ -0,0 +1,40 @@
+#! /bin/bash
+
+if [ ! -f /adei/cfg/apache.conf ]; then
+ cp -a /opt/configs/apache* /adei/cfg
+fi
+
+sed -i'' -re '/Listen/ { /(80|443)/!d }' /etc/apache2/listen.conf
+if [ -n "$ADEI_PORTS" ]; then
+ for port in $ADEI_PORTS; do
+ [ $port -eq 80 ] && continue
+ [ $port -eq 443 ] && continue
+
+ echo "Listen $port" >> /etc/apache2/listen.conf
+ done
+fi
+
+if [ -n "$APACHE_SERVERS" -a "$APACHE_SERVERS" -ne 0 ]; then
+ if [ $APACHE_SERVERS -eq 1 ]; then
+ start=1
+ limit=1
+ min_spare=1
+ max_spare=1
+ elif [ $APACHE_SERVERS -lt 10 ]; then
+ start=$(($APACHE_SERVERS / 2))
+ limit=$APACHE_SERVERS
+ min_spare=$start
+ max_spare=$limit
+ else
+ start=0
+ limit=$APACHE_SERVERS
+ min_spare=0
+ max_spare=0
+ fi
+ [ $start -eq 0 ] || sed -i'' -re "s/StartServers(.*)/StartServers $start/" /etc/apache2/server-tuning.conf
+ [ $limit -eq 0 ] || sed -i'' -re "s/MaxClients(.*)/MaxClients $limit/" /etc/apache2/server-tuning.conf
+ [ $min_spare -eq 0 ] || sed -i'' -re "s/MinSpareServers(.*)/MinSpareServers $min_spare/" /etc/apache2/server-tuning.conf
+ [ $max_spare -eq 0 ] || sed -i'' -re "s/MaxSpareServers(.*)/MaxSpareServers $max_spare/" /etc/apache2/server-tuning.conf
+fi
+
+/usr/sbin/apache2ctl start -D FOREGROUND