From 2a32f59c055f76b3420726930a08a0a95474cc2c Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Thu, 22 Feb 2018 03:47:37 +0100 Subject: Simplify and add uid to /etc/passwd on startup to keep getpwuid() happy --- adei/scripts/run-apache.sh | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'adei/scripts/run-apache.sh') diff --git a/adei/scripts/run-apache.sh b/adei/scripts/run-apache.sh index e7d894b..159a265 100755 --- a/adei/scripts/run-apache.sh +++ b/adei/scripts/run-apache.sh @@ -1,13 +1,6 @@ #! /bin/bash LOCK_FILE=.lock -( - flock -x 10 - if [ ! -d /adei/ovr/apache2 ]; then - cp -ar /opt/apache2 /adei/ovr/ - fi -) 10> /adei/ovr/$LOCK_FILE - ( flock -x 10 if [ ! -f /adei/cfg/apache.conf ]; then @@ -15,8 +8,22 @@ LOCK_FILE=.lock fi ) 10> /adei/cfg/$LOCK_FILE + +function ised { +#Creates temporary file in the file folder +# sed -i'' "$@" + + tmp=$(mktemp) + fn="${@: -1}" + echo $fn + sed "$@" > "$tmp" + cat "$tmp" > "$fn" + + rm -f "$tmp" +} + #Keep 80 & 443 -#sed -i'' -re '/Listen/ { /(80|443)/!d }' /etc/apache2/listen.conf +#ised -re '/Listen/ { /(80|443)/!d }' /etc/apache2/listen.conf #if [ -n "$ADEI_PORTS" ]; then # for port in $ADEI_PORTS; do # [ $port -eq 80 ] && continue @@ -49,10 +56,10 @@ if [ -n "$APACHE_SERVERS" -a "$APACHE_SERVERS" -ne 0 ]; then 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 + [ $start -eq 0 ] || ised -re "s/StartServers(.*)/StartServers $start/" /etc/apache2/server-tuning.conf + [ $limit -eq 0 ] || isedt -re "s/MaxClients(.*)/MaxClients $limit/" /etc/apache2/server-tuning.conf + [ $min_spare -eq 0 ] || ised -re "s/MinSpareServers(.*)/MinSpareServers $min_spare/" /etc/apache2/server-tuning.conf + [ $max_spare -eq 0 ] || ised -re "s/MaxSpareServers(.*)/MaxSpareServers $max_spare/" /etc/apache2/server-tuning.conf fi rm -f /tmp/httpd.pid -- cgit v1.2.1