1 |
40e46009
|
Scott Ullrich
|
#!/bin/sh
|
2 |
de96a790
|
Scott Ullrich
|
#
|
3 |
|
|
# rc.php_ini_setup
|
4 |
1e86e897
|
Scott Ullrich
|
# Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
|
5 |
de96a790
|
Scott Ullrich
|
# All rights reserved.
|
6 |
|
|
#
|
7 |
|
|
# Redistribution and use in source and binary forms, with or without
|
8 |
|
|
# modification, are permitted provided that the following conditions are met:
|
9 |
|
|
#
|
10 |
|
|
# 1. Redistributions of source code must retain the above copyright notice,
|
11 |
|
|
# this list of conditions and the following disclaimer.
|
12 |
|
|
#
|
13 |
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
14 |
|
|
# notice, this list of conditions and the following disclaimer in the
|
15 |
|
|
# documentation and/or other materials provided with the distribution.
|
16 |
|
|
#
|
17 |
|
|
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
18 |
|
|
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
19 |
|
|
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
20 |
|
|
# AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
21 |
|
|
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
22 |
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
23 |
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
24 |
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
25 |
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
26 |
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
27 |
40e46009
|
Scott Ullrich
|
|
28 |
|
|
# Set our operating platform
|
29 |
51d0f816
|
Ermal
|
PLATFORM=`/bin/cat /etc/platform`
|
30 |
c44417f8
|
Scott Ullrich
|
|
31 |
79454450
|
Scott Ullrich
|
if [ -d /usr/local/lib/php/20090626 ]; then
|
32 |
|
|
EXTENSIONSDIR="/usr/local/lib/php/20090626/"
|
33 |
|
|
else
|
34 |
|
|
EXTENSIONSDIR="/usr/local/lib/php/20060613/"
|
35 |
|
|
fi
|
36 |
|
|
|
37 |
0d60f50a
|
Seth Mos
|
# Grab amount of memory that is detected
|
38 |
47eee8fa
|
Scott Ullrich
|
if [ -f /var/log/dmesg.boot ]; then
|
39 |
839cad07
|
smos
|
AVAILMEM=`/bin/cat /var/log/dmesg.boot |/usr/bin/awk '/avail memory/ { memory=($4 / 1048576); printf("%0.0f\n", memory); exit}'`
|
40 |
47eee8fa
|
Scott Ullrich
|
else
|
41 |
839cad07
|
smos
|
AVAILMEM=`/sbin/dmesg -a |/usr/bin/awk '/avail memory/ { memory=($4 / 1048576); printf("%0.0f\n", memory); exit}'`
|
42 |
47eee8fa
|
Scott Ullrich
|
fi
|
43 |
c44417f8
|
Scott Ullrich
|
|
44 |
b713d790
|
Scott Ullrich
|
if [ -z "$AVAILMEM" ]; then
|
45 |
51d0f816
|
Ermal
|
MEM=`/sbin/sysctl hw.physmem | cut -d':' -f2`
|
46 |
|
|
AVAILMEM=`/bin/expr $MEM / 1048576`
|
47 |
b713d790
|
Scott Ullrich
|
fi
|
48 |
|
|
|
49 |
2b11ff4d
|
Scott Ullrich
|
# Calculate APC SHM size according
|
50 |
|
|
# to detected memory values
|
51 |
cddedb40
|
Scott Ullrich
|
if [ "$AVAILMEM" -lt "65" ]; then
|
52 |
eebccaca
|
Erik Fonnesbeck
|
APCSHMEMSIZE="1M"
|
53 |
cddedb40
|
Scott Ullrich
|
fi
|
54 |
|
|
if [ "$AVAILMEM" -lt "96" ]; then
|
55 |
eebccaca
|
Erik Fonnesbeck
|
APCSHMEMSIZE="5M"
|
56 |
cddedb40
|
Scott Ullrich
|
fi
|
57 |
4e315836
|
Phil Davis
|
if [ "$AVAILMEM" -le "128" ]; then
|
58 |
eebccaca
|
Erik Fonnesbeck
|
APCSHMEMSIZE="10M"
|
59 |
2b11ff4d
|
Scott Ullrich
|
fi
|
60 |
|
|
if [ "$AVAILMEM" -gt "128" ]; then
|
61 |
eebccaca
|
Erik Fonnesbeck
|
APCSHMEMSIZE="15M"
|
62 |
2b11ff4d
|
Scott Ullrich
|
fi
|
63 |
|
|
if [ "$AVAILMEM" -gt "256" ]; then
|
64 |
eebccaca
|
Erik Fonnesbeck
|
APCSHMEMSIZE="20M"
|
65 |
2b11ff4d
|
Scott Ullrich
|
fi
|
66 |
|
|
if [ "$AVAILMEM" -gt "384" ]; then
|
67 |
eebccaca
|
Erik Fonnesbeck
|
APCSHMEMSIZE="25M"
|
68 |
2b11ff4d
|
Scott Ullrich
|
fi
|
69 |
|
|
if [ "$AVAILMEM" -gt "512" ]; then
|
70 |
eebccaca
|
Erik Fonnesbeck
|
APCSHMEMSIZE="30M"
|
71 |
2b11ff4d
|
Scott Ullrich
|
fi
|
72 |
|
|
if [ "$AVAILMEM" -gt "784" ]; then
|
73 |
eebccaca
|
Erik Fonnesbeck
|
APCSHMEMSIZE="35M"
|
74 |
2b11ff4d
|
Scott Ullrich
|
fi
|
75 |
40e46009
|
Scott Ullrich
|
|
76 |
31c96a14
|
Scott Ullrich
|
# Set upload directory
|
77 |
dee5d2fb
|
Renato Botelho
|
if [ "$PLATFORM" = "embedded" -o "$PLATFORM" = "nanobsd" ]; then
|
78 |
7ff663d3
|
Warren Baker
|
UPLOADTMPDIR=`/usr/bin/grep upload_path /etc/inc/globals.inc | /usr/bin/cut -d'"' -f4`
|
79 |
31c96a14
|
Scott Ullrich
|
else
|
80 |
|
|
UPLOADTMPDIR="/tmp"
|
81 |
|
|
fi
|
82 |
|
|
|
83 |
de96a790
|
Scott Ullrich
|
# Define php modules. Do not add .so, it will
|
84 |
|
|
# be done automatically by the script below.
|
85 |
5556f3a1
|
Ermal
|
PHPMODULES="apc"
|
86 |
|
|
PHPMODULES="$PHPMODULES standard"
|
87 |
c25197ba
|
smos
|
# Config read/write
|
88 |
|
|
PHPMODULES="$PHPMODULES xml libxml dom"
|
89 |
|
|
PHPMODULES="$PHPMODULES simplexml xmlreader xmlwriter"
|
90 |
be1db1d3
|
Scott Ullrich
|
# Downloading via HTTP/FTP (pkg mgr, etc)
|
91 |
5556f3a1
|
Ermal
|
PHPMODULES="$PHPMODULES curl date"
|
92 |
be1db1d3
|
Scott Ullrich
|
# Internationalization
|
93 |
5556f3a1
|
Ermal
|
PHPMODULES="$PHPMODULES gettext"
|
94 |
be1db1d3
|
Scott Ullrich
|
# User manager
|
95 |
5556f3a1
|
Ermal
|
PHPMODULES="$PHPMODULES ldap openssl pcntl"
|
96 |
d9867431
|
jim-p
|
PHPMODULES="$PHPMODULES hash"
|
97 |
b3765f4c
|
Roberto Nunnari
|
PHPMODULES="$PHPMODULES mcrypt"
|
98 |
be1db1d3
|
Scott Ullrich
|
# Regexs, PERL style!
|
99 |
5556f3a1
|
Ermal
|
PHPMODULES="$PHPMODULES pcre"
|
100 |
be1db1d3
|
Scott Ullrich
|
# The mighty posix!
|
101 |
5556f3a1
|
Ermal
|
PHPMODULES="$PHPMODULES posix"
|
102 |
|
|
PHPMODULES="$PHPMODULES readline"
|
103 |
be1db1d3
|
Scott Ullrich
|
# Login sessions
|
104 |
5556f3a1
|
Ermal
|
PHPMODULES="$PHPMODULES session"
|
105 |
be1db1d3
|
Scott Ullrich
|
# Extra sanity seatbelts
|
106 |
c25197ba
|
smos
|
PHPMODULES="$PHPMODULES suhosin"
|
107 |
fca48a65
|
Scott Ullrich
|
# Firewall rules edit
|
108 |
5556f3a1
|
Ermal
|
PHPMODULES="$PHPMODULES ctype"
|
109 |
16058a05
|
Scott Ullrich
|
# firewall_rules_edit.php
|
110 |
5556f3a1
|
Ermal
|
PHPMODULES="$PHPMODULES mbstring"
|
111 |
|
|
# Synchronization primitives
|
112 |
|
|
PHPMODULES="$PHPMODULES shmop"
|
113 |
be1db1d3
|
Scott Ullrich
|
# Page compression
|
114 |
5556f3a1
|
Ermal
|
PHPMODULES="$PHPMODULES zlib"
|
115 |
|
|
# SQLlite & Database
|
116 |
|
|
PHPMODULES="$PHPMODULES spl"
|
117 |
|
|
PHPMODULES="$PHPMODULES pdo"
|
118 |
|
|
PHPMODULES="$PHPMODULES sqlite"
|
119 |
04747c75
|
Warren Baker
|
# RADIUS
|
120 |
|
|
PHPMODULES="$PHPMODULES radius"
|
121 |
e929c925
|
Scott Ullrich
|
# ZeroMQ
|
122 |
5556f3a1
|
Ermal
|
PHPMODULES="$PHPMODULES zmq"
|
123 |
c88ff708
|
Scott Ullrich
|
# SSH2
|
124 |
|
|
PHPMODULES="$PHPMODULES ssh2"
|
125 |
5556f3a1
|
Ermal
|
# pfSense extensions
|
126 |
|
|
PHPMODULES="$PHPMODULES pfSense"
|
127 |
a1f77238
|
Darren Embry
|
# json
|
128 |
|
|
PHPMODULES="$PHPMODULES json"
|
129 |
c1993935
|
jim-p
|
# bcmath
|
130 |
|
|
PHPMODULES="$PHPMODULES bcmath"
|
131 |
e83dca8c
|
Scott Ullrich
|
|
132 |
277ee858
|
lgcosta
|
PHP_ZEND_MODULES="ioncube_loader"
|
133 |
|
|
PHP_ZEND_MODULES_TS="ioncube_loader_ts"
|
134 |
8ef700da
|
Scott Ullrich
|
|
135 |
80d887d1
|
Scott Ullrich
|
# Modules previously included.
|
136 |
fcdf9492
|
Scott Ullrich
|
# can be turned on by touching
|
137 |
80d887d1
|
Scott Ullrich
|
# /etc/php_dynamodules/$modulename
|
138 |
|
|
# sysvmsg \
|
139 |
|
|
# sysvsem \
|
140 |
|
|
# sysvshm \
|
141 |
|
|
# bcmath \
|
142 |
|
|
# tokenizer \
|
143 |
|
|
# uploadprogress \
|
144 |
|
|
# sockets \
|
145 |
|
|
# Reflection \
|
146 |
|
|
# mysql \
|
147 |
|
|
# bz2 \
|
148 |
|
|
|
149 |
5556f3a1
|
Ermal
|
# Clear the .ini file to make sure we are clean
|
150 |
69b27c16
|
Scott Ullrich
|
if [ -f /usr/local/etc/php.ini ]; then
|
151 |
51d0f816
|
Ermal
|
/bin/rm /usr/local/etc/php.ini
|
152 |
69b27c16
|
Scott Ullrich
|
fi
|
153 |
|
|
if [ -f /usr/local/lib/php.ini ]; then
|
154 |
51d0f816
|
Ermal
|
/bin/rm /usr/local/lib/php.ini
|
155 |
69b27c16
|
Scott Ullrich
|
fi
|
156 |
51d0f816
|
Ermal
|
LOADED_MODULES=`/usr/local/bin/php -m | /usr/bin/grep -v "\["`
|
157 |
e83dca8c
|
Scott Ullrich
|
|
158 |
9d0be827
|
smos
|
# Fetch the timezone from the XML and set it here. We set it later too in the running scripts
|
159 |
|
|
TIMEZONE=`cat /conf/config.xml | egrep -E '<timezone>(.*?)</timezone>' | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'`
|
160 |
|
|
|
161 |
5556f3a1
|
Ermal
|
# Get a loaded module list in the stock php
|
162 |
2ed3203c
|
Scott Ullrich
|
# Populate a dummy php.ini to avoid
|
163 |
|
|
# the file being clobbered and the firewall
|
164 |
|
|
# not being able to boot back up.
|
165 |
51d0f816
|
Ermal
|
/bin/cat >/usr/local/lib/php.ini <<EOF
|
166 |
4b29393a
|
Scott Ullrich
|
; File generated from /etc/rc.php_ini_setup
|
167 |
40e46009
|
Scott Ullrich
|
output_buffering = "0"
|
168 |
|
|
expose_php = Off
|
169 |
|
|
implicit_flush = true
|
170 |
|
|
magic_quotes_gpc = Off
|
171 |
9d0be827
|
smos
|
max_execution_time = 900
|
172 |
7e824233
|
smos
|
max_input_time = 1800
|
173 |
40e46009
|
Scott Ullrich
|
register_argc_argv = On
|
174 |
|
|
file_uploads = On
|
175 |
31c96a14
|
Scott Ullrich
|
upload_tmp_dir = ${UPLOADTMPDIR}
|
176 |
199c320b
|
jim-p
|
upload_max_filesize = 128M
|
177 |
|
|
post_max_size = 128M
|
178 |
40e46009
|
Scott Ullrich
|
html_errors = Off
|
179 |
f4015bd7
|
Scott Ullrich
|
zlib.output_compression = Off
|
180 |
40e46009
|
Scott Ullrich
|
zlib.output_compression_level = 1
|
181 |
|
|
include_path = ".:/etc/inc:/usr/local/www:/usr/local/captiveportal:/usr/local/pkg"
|
182 |
8919256f
|
Scott Ullrich
|
display_startup_errors=on
|
183 |
|
|
display_errors=on
|
184 |
baa2dba2
|
Scott Ullrich
|
log_errors=on
|
185 |
|
|
error_log=/tmp/PHP_errors.log
|
186 |
0804f515
|
Scott Ullrich
|
extension_dir=${EXTENSIONSDIR}
|
187 |
9d0be827
|
smos
|
date.timezone="${TIMEZONE}"
|
188 |
40e46009
|
Scott Ullrich
|
|
189 |
4b29393a
|
Scott Ullrich
|
; Extensions
|
190 |
a8e61346
|
Ermal
|
|
191 |
40e46009
|
Scott Ullrich
|
EOF
|
192 |
|
|
|
193 |
5556f3a1
|
Ermal
|
# Copy php.ini file to etc/ too (cli)
|
194 |
51d0f816
|
Ermal
|
/bin/cp /usr/local/lib/php.ini /usr/local/etc/php.ini
|
195 |
5556f3a1
|
Ermal
|
|
196 |
7f16265a
|
Scott Ullrich
|
# Ensure directory exists
|
197 |
|
|
if [ ! -d /etc/php_dynamodules ]; then
|
198 |
51d0f816
|
Ermal
|
/bin/mkdir /etc/php_dynamodules
|
199 |
7f16265a
|
Scott Ullrich
|
fi
|
200 |
5b9afe1e
|
Scott Ullrich
|
if [ ! -d /etc/php_dynamodules_zend ]; then
|
201 |
|
|
/bin/mkdir /etc/php_dynamodules_zend
|
202 |
|
|
fi
|
203 |
|
|
if [ ! -d /etc/php_dynamodules_zend_ts ]; then
|
204 |
|
|
/bin/mkdir /etc/php_dynamodules_zend_ts
|
205 |
|
|
fi
|
206 |
7f16265a
|
Scott Ullrich
|
|
207 |
|
|
# Read in dynamodules
|
208 |
c44417f8
|
Scott Ullrich
|
if [ -d /etc/php_dynamodules ]; then
|
209 |
fd3e19f3
|
Scott Ullrich
|
DYNA_MODULES=`/bin/ls -Utr /etc/php_dynamodules/`
|
210 |
c44417f8
|
Scott Ullrich
|
PHPMODULES="$PHPMODULES $DYNA_MODULES"
|
211 |
|
|
fi
|
212 |
|
|
|
213 |
8ef700da
|
Scott Ullrich
|
# Read in zend modules
|
214 |
|
|
if [ -d /etc/php_dynamodules_zend ]; then
|
215 |
f81cbdad
|
Scott Ullrich
|
DYNA_MODULES=`/bin/ls /etc/php_dynamodules_zend/`
|
216 |
8ef700da
|
Scott Ullrich
|
PHP_ZEND_MODULES="$PHP_ZEND_MODULES $DYNA_MODULES"
|
217 |
|
|
fi
|
218 |
|
|
|
219 |
|
|
# Read in zend threaded modules
|
220 |
|
|
if [ -d /etc/php_dynamodules_zend_ts ]; then
|
221 |
f81cbdad
|
Scott Ullrich
|
DYNA_MODULES=`/bin/ls /etc/php_dynamodules_zend_ts/`
|
222 |
14033103
|
Scott Ullrich
|
PHP_ZEND_MODULES_TS="$PHP_ZEND_MODULES_TS $DYNA_MODULES"
|
223 |
8ef700da
|
Scott Ullrich
|
fi
|
224 |
|
|
|
225 |
e83dca8c
|
Scott Ullrich
|
# Loop through and generate modules to load.
|
226 |
|
|
# Take into account modules built into php.
|
227 |
|
|
for EXT in $PHPMODULES; do
|
228 |
|
|
SHOULDADD="true"
|
229 |
de96a790
|
Scott Ullrich
|
# Check to see if module is compiled into php statically
|
230 |
e83dca8c
|
Scott Ullrich
|
for LM in $LOADED_MODULES; do
|
231 |
|
|
if [ "$EXT" = "$LM" ]; then
|
232 |
|
|
SHOULDADD="false"
|
233 |
|
|
fi
|
234 |
|
|
done
|
235 |
|
|
if [ "$SHOULDADD" = "true" ]; then
|
236 |
de96a790
|
Scott Ullrich
|
# Ensure extension exists before adding.
|
237 |
69b27c16
|
Scott Ullrich
|
if [ -f "${EXTENSIONSDIR}${EXT}.so" ]; then
|
238 |
0804f515
|
Scott Ullrich
|
echo "extension=${EXT}.so" >> /usr/local/lib/php.ini
|
239 |
|
|
fi
|
240 |
e83dca8c
|
Scott Ullrich
|
fi
|
241 |
|
|
done
|
242 |
|
|
|
243 |
8ef700da
|
Scott Ullrich
|
# Zend modules
|
244 |
|
|
for EXT in $PHP_ZEND_MODULES; do
|
245 |
|
|
# Ensure extension exists before adding.
|
246 |
5c52cd56
|
lgcosta
|
if [ -f "${EXTENSIONSDIR}/ioncube/${EXT}.so" ]; then
|
247 |
|
|
echo "zend_extension=${EXTENSIONSDIR}/ioncube/${EXT}.so" >> /usr/local/lib/php.ini
|
248 |
8ef700da
|
Scott Ullrich
|
fi
|
249 |
|
|
done
|
250 |
|
|
|
251 |
|
|
# Zend threaded modules
|
252 |
|
|
for EXT in $PHP_ZEND_MODULES_TS; do
|
253 |
|
|
# Ensure extension exists before adding.
|
254 |
5c52cd56
|
lgcosta
|
if [ -f "${EXTENSIONSDIR}/ioncube/${EXT}.so" ]; then
|
255 |
|
|
echo "zend_extension_ts=${EXTENSIONSDIR}/ioncube/${EXT}.so" >> /usr/local/lib/php.ini
|
256 |
8ef700da
|
Scott Ullrich
|
fi
|
257 |
|
|
done
|
258 |
|
|
|
259 |
de96a790
|
Scott Ullrich
|
# Get amount of ram installed on this system
|
260 |
51d0f816
|
Ermal
|
RAM=`/sbin/sysctl hw.realmem | /usr/bin/awk '{print $2/1000000}' | /usr/bin/awk -F '.' '{print $1}'`
|
261 |
40e46009
|
Scott Ullrich
|
export RAM
|
262 |
8ee1dc80
|
Scott Ullrich
|
export LOWMEM
|
263 |
430b921b
|
Irving Popovetsky
|
if [ "$RAM" -gt 135 ]; then
|
264 |
40e46009
|
Scott Ullrich
|
|
265 |
51d0f816
|
Ermal
|
/bin/cat >>/usr/local/lib/php.ini <<EOF
|
266 |
e83dca8c
|
Scott Ullrich
|
|
267 |
4b29393a
|
Scott Ullrich
|
; APC Settings
|
268 |
40e46009
|
Scott Ullrich
|
apc.enabled="1"
|
269 |
59218e22
|
Scott Ullrich
|
apc.enable_cli="0"
|
270 |
de96a790
|
Scott Ullrich
|
apc.shm_size="${APCSHMEMSIZE}"
|
271 |
40e46009
|
Scott Ullrich
|
|
272 |
5556f3a1
|
Ermal
|
EOF
|
273 |
|
|
|
274 |
|
|
else
|
275 |
|
|
LOWMEM="TRUE"
|
276 |
|
|
echo ">>> WARNING! under 128 megabytes of ram detected. Not enabling APC."
|
277 |
51d0f816
|
Ermal
|
echo ">>> WARNING! under 128 megabytes of ram detected. Not enabling APC." | /usr/bin/logger -p daemon.info -i -t rc.php_ini_setup
|
278 |
5556f3a1
|
Ermal
|
fi
|
279 |
|
|
|
280 |
51d0f816
|
Ermal
|
/bin/cat >>/usr/local/lib/php.ini <<EOF
|
281 |
5556f3a1
|
Ermal
|
|
282 |
a8e61346
|
Ermal
|
[suhosin]
|
283 |
|
|
suhosin.get.max_array_depth = 5000
|
284 |
|
|
suhosin.get.max_array_index_length = 256
|
285 |
|
|
suhosin.get.max_vars = 5000
|
286 |
4f1bace5
|
Ermal
|
suhosin.get.max_value_length = 500000
|
287 |
a8e61346
|
Ermal
|
suhosin.post.max_array_depth = 5000
|
288 |
|
|
suhosin.post.max_array_index_length = 256
|
289 |
|
|
suhosin.post.max_vars = 5000
|
290 |
4f1bace5
|
Ermal
|
suhosin.post.max_value_length = 500000
|
291 |
a8e61346
|
Ermal
|
suhosin.request.max_array_depth = 5000
|
292 |
|
|
suhosin.request.max_array_index_length = 256
|
293 |
|
|
suhosin.request.max_vars = 5000
|
294 |
4f1bace5
|
Ermal
|
suhosin.request.max_value_length = 500000
|
295 |
b9bc333b
|
Scott Ullrich
|
suhosin.memory_limit = 512435456
|
296 |
a8e61346
|
Ermal
|
|
297 |
40e46009
|
Scott Ullrich
|
EOF
|
298 |
|
|
|
299 |
|
|
|
300 |
de96a790
|
Scott Ullrich
|
# Copy php.ini file to etc/ too (cli)
|
301 |
51d0f816
|
Ermal
|
/bin/cp /usr/local/lib/php.ini /usr/local/etc/php.ini
|
302 |
e1fda0c0
|
Scott Ullrich
|
|
303 |
|
|
# Remove old log file if it exists.
|
304 |
|
|
if [ -f /var/run/php_modules_load_errors.txt ]; then
|
305 |
51d0f816
|
Ermal
|
/bin/rm /var/run/php_modules_load_errors.txt
|
306 |
e1fda0c0
|
Scott Ullrich
|
fi
|
307 |
|
|
|
308 |
7030262c
|
Scott Ullrich
|
for EXT in $PHPMODULES; do
|
309 |
51d0f816
|
Ermal
|
PHPMODULESLC="$PHPMODULESLC `echo "$EXT" | /usr/bin/tr '[:upper:]' '[:lower:]'`"
|
310 |
7030262c
|
Scott Ullrich
|
done
|
311 |
|
|
|
312 |
e1fda0c0
|
Scott Ullrich
|
# Check loaded modules and remove anything that did not load correctly
|
313 |
51d0f816
|
Ermal
|
LOADED_MODULES=`/usr/local/bin/php -m | /usr/bin/tr '[:upper:]' '[:lower:]' 2>/dev/null | /usr/bin/grep -v "\["`
|
314 |
7030262c
|
Scott Ullrich
|
for EXT in $PHPMODULESLC; do
|
315 |
e1fda0c0
|
Scott Ullrich
|
SHOULDREMOVE="true"
|
316 |
|
|
for LM in $LOADED_MODULES; do
|
317 |
|
|
if [ "$EXT" = "$LM" ]; then
|
318 |
|
|
SHOULDREMOVE="false"
|
319 |
|
|
fi
|
320 |
|
|
done
|
321 |
1e86e897
|
Scott Ullrich
|
# Handle low memory situations
|
322 |
8ee1dc80
|
Scott Ullrich
|
if [ "$LOWMEM" = "TRUE" ]; then
|
323 |
|
|
if [ "$EXT" = "apc" ]; then
|
324 |
|
|
SHOULDREMOVE="true"
|
325 |
|
|
fi
|
326 |
|
|
if [ "$EXT" = "xcache" ]; then
|
327 |
|
|
SHOULDREMOVE="true"
|
328 |
|
|
fi
|
329 |
|
|
fi
|
330 |
e1fda0c0
|
Scott Ullrich
|
if [ "$SHOULDREMOVE" = "true" ]; then
|
331 |
|
|
if [ -f "${EXTENSIONSDIR}${EXT}.so" ]; then
|
332 |
|
|
echo ">>> ${EXT} did not load correctly. Removing from php.ini..." >> /var/run/php_modules_load_errors.txt
|
333 |
51d0f816
|
Ermal
|
/bin/cat /usr/local/lib/php.ini | /usr/bin/grep -v $EXT > /tmp/php.ini
|
334 |
|
|
/bin/rm -f /usr/local/lib/php.ini
|
335 |
|
|
/bin/mv /tmp/php.ini /usr/local/lib/php.ini
|
336 |
e1fda0c0
|
Scott Ullrich
|
fi
|
337 |
|
|
fi
|
338 |
|
|
done
|
339 |
|
|
|
340 |
|
|
# Copy php.ini file to etc/ too (cli)
|
341 |
51d0f816
|
Ermal
|
/bin/cp /usr/local/lib/php.ini /usr/local/etc/php.ini
|