Commit 13e0d121 authored by Franco Fichtner's avatar Franco Fichtner

rc: prune rc.php_ini_setup

* Avoid warnings for PDO and SimpleXML.
* APC and ioncube are dead.
parent 8172b037
#!/usr/local/bin/php -f #!/usr/local/bin/php -f
<?php <?php
ini_set('apc.enabled', '0');
/* $Id$ */
/* /*
rc.bootup rc.bootup
part of pfSense by Scott Ullrich part of pfSense by Scott Ullrich
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
# Set our operating platform # Set our operating platform
PLATFORM=`/bin/cat /etc/platform` PLATFORM=`/bin/cat /etc/platform`
MIN_REALMEM_FOR_APC=512
if [ -d /usr/local/lib/php/20131226 ]; then if [ -d /usr/local/lib/php/20131226 ]; then
# PHP 5.6 # PHP 5.6
...@@ -40,49 +39,6 @@ else ...@@ -40,49 +39,6 @@ else
exit 1 exit 1
fi fi
# Grab amount of memory that is detected
if [ -f /var/log/dmesg.boot ]; then
AVAILMEM=`/bin/cat /var/log/dmesg.boot |/usr/bin/awk '/avail memory/ { memory=($4 / 1048576); printf("%0.0f\n", memory); exit}'`
else
AVAILMEM=`/sbin/dmesg -a |/usr/bin/awk '/avail memory/ { memory=($4 / 1048576); printf("%0.0f\n", memory); exit}'`
fi
if [ -z "$AVAILMEM" ]; then
MEM=`/sbin/sysctl hw.physmem | cut -d':' -f2`
AVAILMEM=`/bin/expr $MEM / 1048576`
fi
# Get amount of ram installed on this system
REALMEM=`/sbin/sysctl hw.realmem | /usr/bin/awk '{print $2/1048576}' | /usr/bin/awk -F '.' '{print $1}'`
export REALMEM
export LOWMEM
if [ ${REALMEM} -lt $MIN_REALMEM_FOR_APC ]; then
LOWMEM="TRUE"
echo ">>> Under $MIN_REALMEM_FOR_APC megabytes of ram detected. Not enabling APC."
echo ">>> Under $MIN_REALMEM_FOR_APC megabytes of ram detected. Not enabling APC." | /usr/bin/logger -p daemon.info -i -t rc.php_ini_setup
else
# Calculate APC SHM size according
# to detected memory values
if [ "$AVAILMEM" -gt "135" ]; then
APCSHMEMSIZE="10M"
fi
if [ "$AVAILMEM" -gt "256" ]; then
APCSHMEMSIZE="20M"
fi
if [ "$AVAILMEM" -gt "384" ]; then
APCSHMEMSIZE="25M"
fi
if [ "$AVAILMEM" -gt "512" ]; then
APCSHMEMSIZE="30M"
fi
if [ "$AVAILMEM" -gt "784" ]; then
APCSHMEMSIZE="50M"
fi
fi
# Set upload directory # Set upload directory
if [ "$PLATFORM" = "nanobsd" ]; then if [ "$PLATFORM" = "nanobsd" ]; then
UPLOADTMPDIR=`/usr/bin/grep upload_path /etc/inc/globals.inc | /usr/bin/cut -d'"' -f4` UPLOADTMPDIR=`/usr/bin/grep upload_path /etc/inc/globals.inc | /usr/bin/cut -d'"' -f4`
...@@ -93,12 +49,9 @@ fi ...@@ -93,12 +49,9 @@ fi
# Define php modules. Do not add .so, it will # Define php modules. Do not add .so, it will
# be done automatically by the script below. # be done automatically by the script below.
PHPMODULES="standard" PHPMODULES="standard"
if [ "$LOWMEM" != "TRUE" ]; then
PHPMODULES="$PHPMODULES apc"
fi
# Config read/write # Config read/write
PHPMODULES="$PHPMODULES xml libxml dom" PHPMODULES="$PHPMODULES xml libxml dom"
PHPMODULES="$PHPMODULES simplexml xmlreader xmlwriter" PHPMODULES="$PHPMODULES SimpleXML xmlreader xmlwriter"
# Downloading via HTTP/FTP (pkg mgr, etc) # Downloading via HTTP/FTP (pkg mgr, etc)
PHPMODULES="$PHPMODULES curl date" PHPMODULES="$PHPMODULES curl date"
# Internationalization # Internationalization
...@@ -126,12 +79,10 @@ PHPMODULES="$PHPMODULES shmop" ...@@ -126,12 +79,10 @@ PHPMODULES="$PHPMODULES shmop"
PHPMODULES="$PHPMODULES zlib" PHPMODULES="$PHPMODULES zlib"
# SQLlite & Database # SQLlite & Database
PHPMODULES="$PHPMODULES spl" PHPMODULES="$PHPMODULES spl"
PHPMODULES="$PHPMODULES pdo" PHPMODULES="$PHPMODULES PDO"
PHPMODULES="$PHPMODULES sqlite3" PHPMODULES="$PHPMODULES sqlite3"
# RADIUS # RADIUS
PHPMODULES="$PHPMODULES radius" PHPMODULES="$PHPMODULES radius"
# ZeroMQ
PHPMODULES="$PHPMODULES zmq"
# SSH2 # SSH2
PHPMODULES="$PHPMODULES ssh2" PHPMODULES="$PHPMODULES ssh2"
# pfSense extensions # pfSense extensions
...@@ -143,23 +94,6 @@ PHPMODULES="$PHPMODULES bcmath" ...@@ -143,23 +94,6 @@ PHPMODULES="$PHPMODULES bcmath"
# filter # filter
PHPMODULES="$PHPMODULES filter" PHPMODULES="$PHPMODULES filter"
PHP_ZEND_MODULES="ioncube_loader"
PHP_ZEND_MODULES_TS="ioncube_loader_ts"
# Modules previously included.
# can be turned on by touching
# /etc/php_dynamodules/$modulename
# sysvmsg \
# sysvsem \
# sysvshm \
# bcmath \
# tokenizer \
# uploadprogress \
# sockets \
# Reflection \
# mysql \
# bz2 \
# Clear the .ini file to make sure we are clean # Clear the .ini file to make sure we are clean
if [ -f /usr/local/etc/php.ini ]; then if [ -f /usr/local/etc/php.ini ]; then
/bin/rm /usr/local/etc/php.ini /bin/rm /usr/local/etc/php.ini
...@@ -204,7 +138,6 @@ extension_dir=${EXTENSIONSDIR} ...@@ -204,7 +138,6 @@ extension_dir=${EXTENSIONSDIR}
date.timezone="${TIMEZONE}" date.timezone="${TIMEZONE}"
; Extensions ; Extensions
EOF EOF
# Copy php.ini file to etc/ too (cli) # Copy php.ini file to etc/ too (cli)
...@@ -227,18 +160,6 @@ if [ -d /etc/php_dynamodules ]; then ...@@ -227,18 +160,6 @@ if [ -d /etc/php_dynamodules ]; then
PHPMODULES="$PHPMODULES $DYNA_MODULES" PHPMODULES="$PHPMODULES $DYNA_MODULES"
fi fi
# Read in zend modules
if [ -d /etc/php_dynamodules_zend ]; then
DYNA_MODULES=`/bin/ls /etc/php_dynamodules_zend/`
PHP_ZEND_MODULES="$PHP_ZEND_MODULES $DYNA_MODULES"
fi
# Read in zend threaded modules
if [ -d /etc/php_dynamodules_zend_ts ]; then
DYNA_MODULES=`/bin/ls /etc/php_dynamodules_zend_ts/`
PHP_ZEND_MODULES_TS="$PHP_ZEND_MODULES_TS $DYNA_MODULES"
fi
# Loop through and generate modules to load. # Loop through and generate modules to load.
# Take into account modules built into php. # Take into account modules built into php.
for EXT in $PHPMODULES; do for EXT in $PHPMODULES; do
...@@ -257,37 +178,7 @@ for EXT in $PHPMODULES; do ...@@ -257,37 +178,7 @@ for EXT in $PHPMODULES; do
fi fi
done done
# Zend modules /bin/cat >>/usr/local/lib/php.ini <<EOF
for EXT in $PHP_ZEND_MODULES; do
# Ensure extension exists before adding.
if [ -f "${EXTENSIONSDIR}/ioncube/${EXT}.so" ]; then
echo "zend_extension=${EXTENSIONSDIR}/ioncube/${EXT}.so" >> /usr/local/lib/php.ini
fi
done
# Zend threaded modules
for EXT in $PHP_ZEND_MODULES_TS; do
# Ensure extension exists before adding.
if [ -f "${EXTENSIONSDIR}/ioncube/${EXT}.so" ]; then
echo "zend_extension_ts=${EXTENSIONSDIR}/ioncube/${EXT}.so" >> /usr/local/lib/php.ini
fi
done
if [ "$LOWMEM" != "TRUE" ]; then
/bin/cat >>/usr/local/lib/php.ini <<EOF
; APC Settings
apc.enabled="1"
apc.enable_cli="0"
apc.shm_size="${APCSHMEMSIZE}"
EOF
fi
/bin/cat >>/usr/local/lib/php.ini <<EOF
[suhosin] [suhosin]
suhosin.get.max_array_depth = 5000 suhosin.get.max_array_depth = 5000
suhosin.get.max_array_index_length = 256 suhosin.get.max_array_index_length = 256
...@@ -302,10 +193,8 @@ suhosin.request.max_array_index_length = 256 ...@@ -302,10 +193,8 @@ suhosin.request.max_array_index_length = 256
suhosin.request.max_vars = 5000 suhosin.request.max_vars = 5000
suhosin.request.max_value_length = 500000 suhosin.request.max_value_length = 500000
suhosin.memory_limit = 512435456 suhosin.memory_limit = 512435456
EOF EOF
# Copy php.ini file to etc/ too (cli) # Copy php.ini file to etc/ too (cli)
/bin/cp /usr/local/lib/php.ini /usr/local/etc/php.ini /bin/cp /usr/local/lib/php.ini /usr/local/etc/php.ini
...@@ -327,15 +216,6 @@ for EXT in $PHPMODULESLC; do ...@@ -327,15 +216,6 @@ for EXT in $PHPMODULESLC; do
SHOULDREMOVE="false" SHOULDREMOVE="false"
fi fi
done done
# Handle low memory situations
if [ "$LOWMEM" = "TRUE" ]; then
if [ "$EXT" = "apc" ]; then
SHOULDREMOVE="true"
fi
if [ "$EXT" = "xcache" ]; then
SHOULDREMOVE="true"
fi
fi
if [ "$SHOULDREMOVE" = "true" ]; then if [ "$SHOULDREMOVE" = "true" ]; then
if [ -f "${EXTENSIONSDIR}${EXT}.so" ]; then if [ -f "${EXTENSIONSDIR}${EXT}.so" ]; then
echo ">>> ${EXT} did not load correctly. Removing from php.ini..." >> /var/run/php_modules_load_errors.txt echo ">>> ${EXT} did not load correctly. Removing from php.ini..." >> /var/run/php_modules_load_errors.txt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment