pfsense/etc/rc.php_ini_setup
Scott Ullrich e83dca8c59 * Define all modules in a variable
* Move php.ini to /tmp and test for built in modules
* Generate final php.ini by merging the two together and only load needed
  modules from php.ini that are not built in
2008-12-22 05:11:02 +00:00

71 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
# Set our operating platform
PLATFORM=`cat /etc/platform`
PHPMODULES="pcre bz2 bcmath ctype curl gettext mbstring mhash \
pcntl posix readline session shmop sysvmsg sysvsem sysvshm \
tokenizer xml ldap zlib uploadprogress"
mv /usr/local/etc/php.ini /tmp/
mv /usr/local/lib/php.ini /tmp/
LOADED_MODULES=`php -m | grep -v "\["`
if [ "$PLATFORM" != "cdrom" ]; then
# Populate a dummy php.ini to avoid
# the file being clobbered and the firewall
# not being able to boot back up.
cat >/usr/local/lib/php.ini <<EOF
# File generated from /etc/rc
output_buffering = "0"
expose_php = Off
implicit_flush = true
magic_quotes_gpc = Off
max_execution_time = 99999999
max_input_time = 99999999
register_argc_argv = On
file_uploads = On
upload_tmp_dir = /tmp
upload_max_filesize = 100M
post_max_size = 100M
html_errors = Off
zlib.output_compression = On
zlib.output_compression_level = 1
include_path = ".:/etc/inc:/usr/local/www:/usr/local/captiveportal:/usr/local/pkg"
uploadprogress.file.filename_template = /tmp/uploadprogress_%s.txt
extension_dir=/usr/local/lib/php/20060613/
EOF
# Loop through and generate modules to load.
# Take into account modules built into php.
for EXT in $PHPMODULES; do
SHOULDADD="true"
for LM in $LOADED_MODULES; do
if [ "$EXT" = "$LM" ]; then
SHOULDADD="false"
fi
done
if [ "$SHOULDADD" = "true" ]; then
echo "extension=${EXT}.so" >> /usr/local/lib/php.ini
fi
done
RAM=`sysctl hw.realmem | awk '{print $2/1000000}' | awk -F '.' '{print $1}'`
export RAM
if [ $RAM -gt 96 ]; then
cat >>/usr/local/lib/php.ini <<EOF
apc.enabled="1"
apc.enable_cli="1"
apc.shm_size="25"
EOF
fi
fi
cp /usr/local/lib/php.ini /usr/local/etc/php.ini