Current File : //usr/bin/mpmram |
#!/usr/bin/bash
StartServers=$1
ServerLimit=$2
MinSpareServers=$3
MaxSpareServers=$4
MaxRequestsPerChild=$5
MaxRequestWorkers=$6
TimeOut=$7
fin=`cat /proc/meminfo | grep MemTotal | awk '{print $2/1048576}'`
ram=`printf '%.*f\n' 0 $fin`
bc=`whereis bc | awk '{print $2}'`
if [ "$StartServers" == "" ]; then
StartServers=`echo "$((1 * $ram))"`
fi
if [ "$ServerLimit" == "" ]; then
ServerLimit=`echo "$((250 * $ram))"`
fi
t=`(echo 2.5*$ram | $bc)`
if [ "$MinSpareServers" == "" ]; then
MinSpareServers=`printf '%.*f\n' 0 $t`
fi
if [ "$MaxSpareServers" == "" ]; then
MaxSpareServers=`echo "$((5 * $ram))"`
fi
if [ "$MaxRequestWorkers" == "" ]; then
MaxRequestWorkers=`echo "$((200 * $ram))"`
fi
if [ "$MaxRequestsPerChild" == "" ]; then
MaxRequestsPerChild=`echo "$((0 * $ram))"`
fi
if [ "$TimeOut" == "" ]; then
TimeOut=300
fi
`sed -i "s/^StartServers.*/StartServers $StartServers/" /etc/httpd/conf.modules.d/00-mpm.conf`
`sed -i "s/^ServerLimit.*/ServerLimit $ServerLimit/" /etc/httpd/conf.modules.d/00-mpm.conf`
`sed -i "s/^MinSpareServers.*/MinSpareServers $MinSpareServers/" /etc/httpd/conf.modules.d/00-mpm.conf`
`sed -i "s/^MaxSpareServers.*/MaxSpareServers $MaxSpareServers/" /etc/httpd/conf.modules.d/00-mpm.conf`
`sed -i "s/^MaxRequestWorkers.*/MaxRequestWorkers $MaxRequestWorkers/" /etc/httpd/conf.modules.d/00-mpm.conf`
`sed -i "s/^MaxRequestsPerChild.*/MaxRequestsPerChild $MaxRequestsPerChild/" /etc/httpd/conf.modules.d/00-mpm.conf`
`sed -i "s/^TimeOut.*/TimeOut $TimeOut/" /etc/httpd/conf.modules.d/00-mpm.conf`
FILE=/etc/sentora/panel/cnf/.apache_set.txt
if [ ! -f "$FILE" ]; then
touch $FILE
`chown apache:apache $FILE`
echo "StartServers "$StartServers > $FILE
echo "ServerLimit" $ServerLimit >> $FILE
echo "MinSpareServers" $MinSpareServers >> $FILE
echo "MaxSpareServers" $MaxSpareServers >> $FILE
echo "MaxRequestsPerChild" $MaxRequestsPerChild >> $FILE
echo "MaxRequestWorkers" $MaxRequestWorkers >> $FILE
echo "TimeOut" $TimeOut >> $FILE
else
Check_StartServers=`grep "StartServers" $FILE`
Check_ServerLimit=`grep "ServerLimit" $FILE`
Check_MinSpareServers=`grep "MinSpareServers" $FILE`
Check_MaxSpareServers=`grep "MaxSpareServers" $FILE`
Check_MaxRequestsPerChild=`grep "MaxRequestsPerChild" $FILE`
Check_MaxRequestWorkers=`grep "MaxRequestWorkers" $FILE`
Check_TimeOut=`grep "TimeOut" $FILE`
if [ "$Check_StartServers" == "" ] || [ "$Check_ServerLimit" == "" ] || [ "$Check_MinSpareServers" == "" ] || [ "$Check_MaxSpareServers" == "" ] || [ "$Check_MaxRequestsPerChild" == "" ] || [ "$Check_MaxRequestWorkers" == "" ] || [ "$Check_TimeOut" == "" ]; then
echo "StartServers "$StartServers > $FILE
echo "ServerLimit" $ServerLimit >> $FILE
echo "MinSpareServers" $MinSpareServers >> $FILE
echo "MaxSpareServers" $MaxSpareServers >> $FILE
echo "MaxRequestsPerChild" $MaxRequestsPerChild >> $FILE
echo "MaxRequestWorkers" $MaxRequestWorkers >> $FILE
echo "TimeOut" $TimeOut >> $FILE
else
`sed -i "s/^StartServers.*/StartServers $StartServers/" /etc/sentora/panel/cnf/.apache_set.txt`
`sed -i "s/^ServerLimit.*/ServerLimit $ServerLimit/" /etc/sentora/panel/cnf/.apache_set.txt`
`sed -i "s/^MinSpareServers.*/MinSpareServers $MinSpareServers/" /etc/sentora/panel/cnf/.apache_set.txt`
`sed -i "s/^MaxSpareServers.*/MaxSpareServers $MaxSpareServers/" /etc/sentora/panel/cnf/.apache_set.txt`
`sed -i "s/^MaxRequestWorkers.*/MaxRequestWorkers $MaxRequestWorkers/" /etc/sentora/panel/cnf/.apache_set.txt`
`sed -i "s/^MaxRequestsPerChild.*/MaxRequestsPerChild $MaxRequestsPerChild/" /etc/sentora/panel/cnf/.apache_set.txt`
`sed -i "s/^TimeOut.*/TimeOut $TimeOut/" /etc/sentora/panel/cnf/.apache_set.txt`
fi
fi