Menu

[r593]: / branches / Release-3-1-8 / php-java-bridge / install.sh  Maximize  Restore  History

Download this file

336 lines (309 with data), 12.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#!/bin/sh
# Installation script for the PHP/Java Bridge module and its back-ends.
#set -x
v=""
if test "X$1" = "X--verbose" || test "X$1" = "X-v" ; then
v="-v"
fi
if ! test -d modules; then
echo "Nothing to install. Do a phpize && configure && make first, bye."
exit 10
fi
php=`php-config --php-binary`
if test $? != 0; then php="`which php`"; fi
if test $? != 0; then php="`which php-cgi`"; fi
if test $? != 0; then
for i in /usr/bin/php /usr/bin/php-cgi /usr/local/bin/php /usr/local/bin/php-cgi; do
if test -f $i; then php=$i; break; fi
done
fi
if test X$php = X; then echo "php not installed, bye."; exit 3; fi
echo '<?php phpinfo();?>' | ${php} >/tmp/phpinfo.$$
ini=`fgrep "Scan this dir for additional" /tmp/phpinfo.$$ | head -1 |
sed 's/<[TtRr][/a-z ="0-9]*>/ => /g' |
sed 's/<[/a-z ="0-9]*>//g' |
sed 's/^.*=> //' | sed 's/ *$//; s/^ *//'`
ext=`fgrep extension_dir /tmp/phpinfo.$$ | head -1 |
sed 's/<[TtRr][/a-z ="0-9]*>/ => /g' |
sed 's/<[/a-z ="0-9]*>//g' |
sed 's/^.*=> //' | sed 's/ *$//; s/^ *//'`
phpini=`fgrep "Configuration File (php.ini) Path" /tmp/phpinfo.$$ | head -1 |
sed 's/<[TtRr][/a-z ="0-9]*>/ => /g' |
sed 's/<[/a-z ="0-9]*>//g' |
sed 's/^.*=> //' | sed 's/ *$//; s/^ *//'`
phpinc=`fgrep "include_path" /tmp/phpinfo.$$ | head -1 |
sed 's/<[TtRr][/a-z ="0-9]*>/ => /g' |
sed 's/<[/a-z ="0-9]*>//g' |
sed 's/^.*=> //' | sed 's/ *$//; s/^ *//' |
LANG=C awk '{for(i=1; i<=(split($0, ar, "[;:]")); i++) if(substr(ar[i], 1) != "." && substr(ar[i], 1) != "..") print ar[i] }' |
head -1`
/bin/rm -f /tmp/phpinfo.$$
# install generic ini
make install >install.log || exit 1
mod_dir=`/bin/cat install.log | sed -n '/Installing shared extensions:/s///p' | awk '{print $1}'`
if test X$v != X; then echo "installed in $mod_dir"; fi
overwrite="no"
if test X$ini = X; then
echo ""
echo "This php installation does not have a config-file-scan-dir,"
echo "java.ini, java-standalone.ini and java-servlet.ini not installed,"
echo "will use file $phpini instead."
if test -f ${phpini}; then
echo -n "Overwrite existing php.ini file (yes/no): "; read overwrite;
fi
fi
if test -d "$ext"; then
if test X$v != X; then echo "Using extension_dir: $ext"; fi
else
echo ""
echo "Warning: Your php installation is broken, the \"extension_dir\" does "
echo "not exist or is not a directory (see php.ini extension_dir setting)."
echo "Please correct this, for example type:"
echo "mkdir \"$ext\""
echo ""
fi
/bin/rm -f $ini 2>/dev/null
if test X$ini != X; then
/bin/mkdir -p $ini
/bin/cp $v java.ini $ini
else
if test X$overwrite = "Xyes"; then
/bin/rm $v -f "${phpini}.backup"
/bin/mv $v "$phpini" "${phpini}.backup"
/bin/cat java.ini >"$phpini"
fi
fi
if test 0 = 1; then
jre=modules/java
else
jre=java
sdk_home=/home/users/j/jo/jost2345/PHP-JAVA-BRIDGE-amd64/j2re1.4.2.amd64
if ! $jre -classpath modules/JavaBridge.jar php.java.bridge.JavaBridge --version >/dev/null; then
echo "Default JRE: $jre is not usuable."
echo "You have configured against ${sdk_home} but the installed JRE is:"
echo ""
echo " `$jre -version|head -5`"
echo ""
echo "Please configure as follows:"
echo " ./configure --with-java=$sdk_home,$sdk_home"
echo "to avoid this warning -- the jre version must be >= the jdk version.";
echo "Ignoring $jre and using ${sdk_home}/bin/java instead."
jre=${sdk_home}/bin/java
echo "Please either use the above ./configure command or add"
echo " java.java=$jre"
echo "to your php .ini file."
fi
fi
# devel
/bin/rm $v -f /usr/share/java/JavaBridge.jar /usr/share/java/script-api.jar /usr/share/java/php-script.jar /usr/java/packages/lib/ext/JavaBridge.jar /usr/java/packages/lib/ext/php-script.jar
if test -f modules/php-script.jar; then
echo ""
echo "Do you want to install the development files for jdk1.6?";
echo -n "install development files (yes/no): "; read devel;
if test "X$devel" != "Xno"; then
/bin/mkdir -p /usr/share/java 2>/dev/null
/bin/cp $v modules/JavaBridge.jar \
modules/php-script.jar \
modules/script-api.jar /usr/share/java
/bin/mkdir -p /usr/java/packages/lib/ext 2>/dev/null
/bin/rm -f /usr/java/packages/lib/ext/JavaBridge.jar \
/usr/java/packages/lib/ext/php-script.jar 2>/dev/null
/bin/ln $v -s /usr/share/java/JavaBridge.jar \
/usr/share/java/php-script.jar /usr/java/packages/lib/ext
echo "Installed in /usr/share/java"
echo ""
echo "The development files have been installed on this computer."
echo "Type (e.g.) /usr/java/jdk1.6.0/bin/jrunscript -l php-interactive"
echo "to start an interactive php session."
echo ""
fi
fi
# convert Java -> PHP
if test X$phpinc = X; then phpinc="/usr/share/pear"; fi
echo "";
echo "Generate PHP classes from standard Java classes and install them in"
echo "the ${phpinc} directory?"
echo -n "convert java libraries (yes/no): "; read convert;
if ! test "X$convert" = "Xno"; then
$jre -Djava.library.path=./modules -Djava.class.path=./modules/JavaBridge.jar -Djava.awt.headless=true -Dphp.java.bridge.base=./modules php.java.bridge.JavaBridge --convert ${phpinc} unsupported/lucene.jar
echo ""
fi
check_document_root() {
document_root="/var/www/html";
if ! test -d /var/www/html; then
document_root="/usr/local/var/www/html";
echo ""
echo "Enter the location of HTTP server document root (e.g.: /usr/local/htdocs)";
echo -n "document root ($document_root): "; read document_root;
if test X$document_root = X; then document_root="/usr/local/var/www/html";fi
echo ""
if ! test -d $document_root; then echo "$document_root is not directory"; exit 5; fi
fi
}
j2ee=no
# j2ee/servlet
/bin/rm $v -f ${ini}/java-servlet.ini 2>/dev/null
if test -f modules/JavaBridge.war; then
echo ""
echo "Do you want to start the Servlet/J2EE back-end as a service?";
echo "This is the fastest and easiest service, only RedHat Enterprise"
echo "or Fedora Linux users should say no here."
echo "Say no, if you want to enable Security Enhanced Linux."
echo "Say no, if you want to start the service automatically with Apache."
echo "If unsure, say no";
echo -n "install j2ee back-end (yes/no): "; read j2ee;
if test "X$j2ee" != "Xno"; then
webapps="`locate /webapps | fgrep tomcat | grep 'webapps$' | head -1`"
echo ""
echo "Enter the location of the autodeploy folder (e.g.: /opt/tomcat/webapps):";
echo -n "autodeploy ($webapps): "; read webapps2;
if test X$webapps2 != X; then webapps=$webapps2; fi
/bin/rm $v -rf ${webapps}/JavaBridge.war ${webapps}/JavaBridge
/bin/cp $v modules/JavaBridge.war $webapps;
echo "Installed in $webapps.";
check_document_root || exit 5
if test -d ${document_root} && ! test -e ${document_root}/JavaBridge; then
ln -s $webapps/JavaBridge ${document_root}/;
echo "Installed in ${document_root}. "
fi
if test X$ini != X; then
/bin/cp $v java-servlet.ini $ini;
else
if test X$overwrite = "Xyes"; then
/bin/cat java-servlet.ini >>"$phpini";
fi
fi
if test -f /etc/selinux/config && test -f /usr/sbin/semodule; then
if test X$v = X; then
(cd security/module; /usr/bin/make; /usr/sbin/semodule -i php-java-bridge-tomcat.pp) >/dev/null
else
(cd security/module; /usr/bin/make; /usr/sbin/semodule -i php-java-bridge-tomcat.pp)
fi
fi
echo ""
echo "The J2EE back-end has been desployed into the J2EE server. Now start the J2EE"
echo "server and the web server, for example with the commands (Linux):"
echo ""
echo " service tomcat5 restart"
echo " service httpd restart"
echo ""
echo " or (Unix):"
echo ""
echo " JAVA_HOME=$sdk_home `dirname $webapps`/bin/catalina.sh stop"
echo " JAVA_HOME=$sdk_home `dirname $webapps`/bin/catalina.sh start"
echo " apachectl restart"
echo ""
echo "Browse to http://localhost:<PORT>/JavaBridge to see the test page from the"
echo "J2EE server. PORT is 8080 for tomcat, 9080 for WebSphere and 8888 for Oracle."
echo "Browse to http://localhost/JavaBridge to see the test page from the web server."
echo ""
fi
fi
# standalone
/bin/rm $v -f ${ini}/java-standalone.ini 2>/dev/null
for i in /etc/init.d /etc/rc.d/init.d /etc/rc.d; do
if test -f ${i}/php-java-bridge; then
/bin/rm $v -f ${i}/php-java-bridge
break;
fi
done
install_sel_module() {
(
cd security/module;
/usr/bin/make;
/usr/sbin/semodule -i php-java-bridge.pp
/usr/bin/chcon -t javabridge_exec_t $ext/RunJavaBridge
/usr/bin/chcon -t sbin_t /usr/sbin/php-java-bridge
if test X$javabridgeservice != X; then /usr/bin/chcon -t initrc_exec_t $javabridgeservice; fi
)
}
if test -f modules/JavaBridge.jar && test "X$j2ee" = "Xno"; then
echo ""
echo "Do you want to start the standalone back-end from a service script?"
echo "Non- RedHat Enterprise or Fedora Linux users probably want to say no here.";
echo "Say no, if you want to start the service automatically with Apache."
echo "Say no, if this operating system doesn't support SysV service scripts."
echo "Say yes, if you want to enable Security Enhanced Linux."
echo "If unsure, say no";
echo -n "install service script (yes/no): "; read standalone;
if test "X$standalone" = "Xyes"; then
/bin/cp $v php-java-bridge /usr/sbin
/bin/chmod +x /usr/sbin/php-java-bridge
if test X$v != X; then echo "Installed /usr/sbin/php-java-bridge"; fi
for i in /etc/init.d /etc/rc.d/init.d /etc/rc.d; do
if test -d $i; then
/bin/cp $v php-java-bridge.service ${i}/php-java-bridge
/bin/chmod +x ${i}/php-java-bridge
javabridgeservice=${i}/php-java-bridge # used in install_sel_module
if test X$v != X; then echo "Installed service ${i}/php-java-bridge"; fi
break;
fi
done
/sbin/chkconfig --add php-java-bridge &&
/sbin/chkconfig php-java-bridge on
echo -n "run the back-end with limited rights (yes/no): "; read limited;
if test "X$limited" = "Xyes"; then
echo -n "run the back-end as user (default: apache): "; read user;
if test X$user = X; then user="apache"; fi
echo -n "run the back-end as group (default: apache): "; read group;
if test X$group = X; then group=$user; fi
(/bin/chown $user:$group $ext/RunJavaBridge &&
/bin/chmod 6111 $ext/RunJavaBridge) || /bin/rm -f $ext/RunJavaBridge
else
/bin/chmod 111 $ext/RunJavaBridge || /bin/rm -f $ext/RunJavaBridge
fi
if test X$ini != X; then
/bin/cat java-standalone.ini | sed 's|^;java\.java_home[\t =].*$|;java.java_home = |; s|^;java\.java[\t =].*$|java.java = '$jre'|' >${ini}/java-standalone.ini
if test X$v != X; then echo "Installed ${ini}/java-standalone.ini"; fi
else
if test X$overwrite = "Xyes"; then
/bin/cat java-standalone.ini | sed 's|^;java\.java_home[\t =].*$|;java.java_home = |; s|^;java\.java[\t =].*$|java.java = '$jre'|' >"$phpini"
fi
fi
check_document_root || exit 5;
if test -d ${document_root} && ! test -e ${document_root}/test.php; then
/bin/cp $v test.php ${document_root}/test.php
if test X$v != X; then echo "Installed ${document_root}/test.php."; fi
fi
echo -n "start now? (yes/no): "; read restart;
if test -f /etc/selinux/config && test -f /usr/sbin/semodule; then
if test X$v = X; then
install_sel_module >/dev/null
else
install_sel_module
fi
fi
if test "X${restart}" != "Xno"; then
/sbin/service php-java-bridge restart
/sbin/service httpd restart
fi
echo ""
echo "The php-java-bridge service has been installed. It can be started with:"
echo ""
echo " service php-java-bridge restart"
echo " service httpd restart"
echo ""
echo "Browse to http://localhost/test.php to see the test page."
echo ""
else
/bin/rm $v -f /usr/sbin/php-java-bridge $ext/RunJavaBridge
fi
else
/bin/rm $v -f /usr/sbin/php-java-bridge $ext/RunJavaBridge
fi
echo "PHP/Java Bridge installed."
if test -d /etc/selinux; then
if /usr/sbin/selinuxenabled; then
if test -f /etc/selinux/config && test -f /usr/sbin/semodule; then
echo "SEL Security: \"javabridge\" policy module installed."
fi
else
echo "You are running a SELinx system. Please install the policy sources"
echo "or install the files from the RPM distribution download."
echo "Please see the README document for details".
fi
fi
echo ""
echo "Now type \"${php} test.php\" to check the installation."
echo ""
exit 0
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.