configure-sun-webserver revision 904
c80e152862cc3e3207dc837fde7116bd4c0e4b9dTinderbox User# CDDL HEADER START
8d1b3ceb4d491ce32572f1702f37ed585eede993Evan Hunt# The contents of this file are subject to the terms of the
d77cb075aae5595e460e3299bfc1e8ea5d42b560Evan Hunt# Common Development and Distribution License (the "License").
d77cb075aae5595e460e3299bfc1e8ea5d42b560Evan Hunt# You may not use this file except in compliance with the License.
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews# See the License for the specific language governing permissions
30ca20f720ad0887772a79e7abb25b4fa0e4b5b0Mark Andrews# and limitations under the License.
7ec97ae74e42ec21b354fd2d1366313b41d947d6Evan Hunt# When distributing Covered Code, include this CDDL HEADER in each
701a93f5a592e4652343e049aa495d409c3ee133Mark Andrews# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
701a93f5a592e4652343e049aa495d409c3ee133Mark Andrews# If applicable, add the following below this CDDL HEADER, with the
002f1373374a0b72fc0329baa682917929bef168Tony Finch# fields enclosed by brackets "[]" replaced with your own identifying
002f1373374a0b72fc0329baa682917929bef168Tony Finch# information: Portions Copyright [yyyy] [name of copyright owner]
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrews# CDDL HEADER END
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrews# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
73cf0ba4e82c6baef638ecc4e31321223f841d28Mark Andrews# Helper functions
d8351dfc9b725b0d727be7acab6247d7d501d9a0Mark Andrews echo "Usage: This script will update a given Web Server 7 instance's configuration"
d8351dfc9b725b0d727be7acab6247d7d501d9a0Mark Andrews echo " files to be able to execute PHP scripts."
3a29ce9c08dd31709c73e7187aebda0d360c537bEvan Hunt echo "This script recognizes following arguments:"
5c78f1f50e53d8e2ed51a187efc2c9a0f43b4b1bMark Andrews echo " --installroot : Top level Sun Web Server 7 installation location. "
f1740da065d4555039fe8bb53beb4153e3f94de3Mark Andrews echo " --instancename : Name of Web Server instance (https-php) which should"
31c7ab4fb3f7710af87dc9c3d64c5daf9a3dea35Mark Andrews echo " --sapi : How should PHP runtime be loaded within Web Server 7"
31c7ab4fb3f7710af87dc9c3d64c5daf9a3dea35Mark Andrews echo " fastcgi (Default) or NSAPI (Optional). "
fc04365d2f83f197c8a54545dd9cd4ce6a209940Mark Andrews until [ $# -eq 0 ]
2cf0fe3b8092f64f8f68ae3693fe2e73e90ad1a4Mark Andrews # Get user response on Web Server 7 installation location and instance name.
2cf0fe3b8092f64f8f68ae3693fe2e73e90ad1a4Mark Andrews echo -n "Enter your Web Server installation location : "
4221d9cd1d02311fbf9b5f08a038f5af78b10b4aEvan Hunt echo -n "Enter your Web Server instance name to configure with PHP runtime: "
e526027287b849f0b6ab6e069156697cbafa22c1Michał Kępień while [ 0 ]; do
e526027287b849f0b6ab6e069156697cbafa22c1Michał Kępień echo -n "How you would like Sun Web Server 7 to load PHP engine (fastcgi|nsapi) [fastcgi]: "
ec29d217ba3a2bf3e617a7b5b6708ae221bee999Mark Andrews if [ -n "$sapi" ] && [ $sapi = "fastcgi" -o $sapi = "nsapi" ]; then
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt if [ ! -d "$install_root" ] || [ ! -x "$install_root/lib/webservd" ]; then
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt echo "Warning: Unable to find valid Web Server installation under $install_root"
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt echo "Please try again by providing a valid Web Server 7 installation location."
7ff28f5befbee76048a23e504dcd3f9a44ce6209Evan Hunt if [ ! -d "$install_root" ] || [ ! -x "$install_root/lib/webservd" ]; then
cad79077bd5b2616bc4a7a6b3cbc0953bef8917fMark Andrews echo "Warning: Unable to find valid Web Server installation under $install_root"
cad79077bd5b2616bc4a7a6b3cbc0953bef8917fMark Andrews echo "Please try again by providing a valid Web Server 7 installation location."
adfe58e8e5cd1890585e92b67f1fd01989a1fa7dMark Andrews if [ -n "$sapi" ] && [ $sapi != "fastcgi" -a $sapi != "nsapi" ]; then
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrews echo "Error: Invalid SAPI option is provided.Valid SAPI argument is either 'fastcgi' or 'nsapi'"
c3237dec879f82855403ff7e3ba87b298172efd5Mark Andrews echo "Please try again by providing a valid SAPI as argument."
0f14b041328c062b1fa391887376388dfc8b2fe5Mark Andrews if [ ! -f $temp_file ]; then
0d6328ce5f6b799f8e7c6cbbb3b965cf29bfb7baMark Andrews tail +${perl_start_line} $PROGRAM_NAME > $temp_file
677f507de7c546c187c1505c48bc7b440545485cMark Andrews total_line=`wc -l $PROGRAM_NAME | awk '{print $1}' 2>/dev/null`
124cc0660c7eff8021c2422fb47441e9ca08b3f9Tinderbox User tail -${few_lines} $PROGRAM_NAME > $temp_file
bf459d24a117ae2c54c37016430b41cd6d73491cMark Andrews if [ ! -d "${WS_INSTANCEROOT}/${instance_name}" ]; then
677f507de7c546c187c1505c48bc7b440545485cMark Andrews echo "Warning: Unable to find instance:'$instance_name' under $WS_INSTANCEROOT"
677f507de7c546c187c1505c48bc7b440545485cMark Andrews echo " Please try again by providing a valid instance name."
81e3e3084980afcd61416f572c6e72d38a3808abMichał Kępień ln -sf "<<INSTALL_DIR>>/nsapi/libphp5.so" "$install_root/plugins/webstack-php/libphp5.so"
a38f07c73790170842e4523b4a474d01ca0dede1Michał Kępień ${WS_PERL}/perl -I ${WS_PERL} -I ${WS_PERL}/lib -I ${WS_PERL}/lib/site_perl $temp_file \
a38f07c73790170842e4523b4a474d01ca0dede1Michał Kępień -installroot=${WS_INSTALLROOT} -instanceroot=${WS_INSTANCEROOT} -instancename=$instance_name \
39d5523a8afc73cbdb4fa426de2ce071267a5d6fMark Andrews -phpconfroot="${PHPCONFROOT}" -phpmodulesconfroot="${PHPCONFROOT_SCANDIR}"
1f4a3c7088594d1b64cd734eb69e1fd023fde8bfMichał Kępień if [ $status -eq 0 ]; then
1f4a3c7088594d1b64cd734eb69e1fd023fde8bfMichał Kępień if [ -f $temp_file ]; then
91827e6fd3851a5fe129ef5409ff45833ca01a0eMark Andrews elif [ $status -ne 0 ]; then
91827e6fd3851a5fe129ef5409ff45833ca01a0eMark Andrews echo "Unable to successfully setup PHP within Web Server 7"
57b1d64d9ae12d56973716e96f9743a00d47af4aMichał Kępień#-------------------------------------------------------------------------------
2d517e233ff3b3fcd272eb5b2e2d3db6d31a1681Michał KępieńPATH=/bin:/usr/bin:/usr/gnu/bin:/usr/sfw/bin
86d2f9abc8493321aacb0d540485de4d562fb734Mark Andrews# Global variables.
c7e57ce1b0bca9bc7da14bec485f7a7e3e4c761fMichał Kępień# This below line need to point to the start of embedded perl script.
3ed16e796dba90c96933c8a8a3f5b9404d8d3e61Mark Andrewsecho "This script will update a given Web Server 7 instance's configuration"
3ed16e796dba90c96933c8a8a3f5b9404d8d3e61Mark Andrewsecho "files to be able to execute PHP scripts."
14d8a144779b54b103d2da741a2242bf5f9052f7Mark Andrews# Verify if the program is called with necessary arguments.
70e041bea19b6ad9522b89c2299ad315a2deaafdMark Andrewsif [ -n "$1" ]; then
67247b4a8304bac790648a351a95b8b0f4c512a6Mark Andrews # Invoked with no arguments. Try interactive.
f8362536c647625e602c8450a778a2b7ba90c9f4Mark Andrews#---------------------EOF-------------------------------------------------------
24231e53a5c3079431f84dcddfee1e761fec7329Mark Andrews# Helper Script to configure PHP runtime environment within Web Server 7
764e2f3413ca89d09abffb3eb228c8c820bf08b8Mark Andrews# -----------------------------------------------------------------------------
764e2f3413ca89d09abffb3eb228c8c820bf08b8Mark Andrews# getCommandOptions
764e2f3413ca89d09abffb3eb228c8c820bf08b8Mark Andrews# Process the command line options
764e2f3413ca89d09abffb3eb228c8c820bf08b8Mark Andrews# -----------------------------------------------------------------------------
a06198688faca5c7bc1a35ec0ec18bc68c07691cEvan Hunt for (my $counter=0; $#ARGV >= $counter; $counter++) {
3c12bec945ee71a38c5ba6f624abd12e2da7eea5Mark Andrews $INSTALL_ROOT = substr($argument, length("-installroot="));
f44202ab640d22e17b4c74bdad7817622918bd27Mark Andrews $INSTANCE_ROOT = substr($argument, length("-instanceroot="));
ad9772c559c6aa42f8930f4acf1a2d833a08040aMichał Kępień $PHP_ROOT = substr($argument, length("-phproot="));
5d7d67f82a8913fae5f1098e111fe50edb86cd5bEvan Hunt $PHP_CONF_ROOT = substr($argument, length("-phpconfroot="));
6216df5ccded056abd5db4abac4e5cbd78c73f45Evan Hunt $PHP_MODULES_CONF_ROOT = substr($argument, length("-phpmodulesconfroot="));
6216df5ccded056abd5db4abac4e5cbd78c73f45Evan Hunt $INSTANCE_NAME = substr($argument, length("-instancename="));
56e30ebae6fdb0bdf94419caff3a43fb2d16c5dfEvan Hunt if ((!defined $PHP_CONF_ROOT) || ($PHP_CONF_ROOT eq "")) {
0612274565d80e0ad87a19920e561cce5bddb05bEvan Hunt if ((not defined $INSTANCE_NAME) or ($INSTANCE_NAME !~ m/\S+/)) {
f592d2f76cac7115038124c510d2ba3050334b4dEvan Hunt exit 1 unless defined isValidFile("$INSTANCE_ROOT/$INSTANCE_NAME/config");
f592d2f76cac7115038124c510d2ba3050334b4dEvan Hunt# -----------------------------------------------------------------------------
f592d2f76cac7115038124c510d2ba3050334b4dEvan Hunt# migrateObjConf
4ee1fbe056e812e661b856b4b448296331a40249Michał Kępień# Migrate obj.conf file to php 1.1
4ee1fbe056e812e661b856b4b448296331a40249Michał Kępień# -----------------------------------------------------------------------------
43d53a4e4b2f0f9482485a8ab764137a9898ab32Evan Hunt if ((not -f $objConfFile or ref($pContents) != "ARRAY")) {
5fa4be41a383cfbf5e1d195b18c04bdbf5603710Evan Hunt my $pLine = \$pContents->[$i];
2732d4922c2e72a399204320791acfd2fd3d6c7cMark Andrews if ($$pLine =~ m@(.*\s+app-path=['"])(\S+)\s*(['"].*)@) {
24ffba17f06746257d5c009ca8ebfe6043966d20Evan Hunt $tmp1 = $1; $tmp2 = $2; $tmp3 = $3;
24ffba17f06746257d5c009ca8ebfe6043966d20Evan Hunt $tmp2 =~ s@$PHP_ROOT/bin/php@$PHP_ROOT/bin/php-cgi@;
d5bd8bb71a8970d4ebc4701b3e9ec3efef4954b7Evan Hunt elsif ($$pLine =~ m@(.*\s+app-env=['"])(\S+)(=)(\S+)(['"].*)@) {
d5bd8bb71a8970d4ebc4701b3e9ec3efef4954b7Evan Hunt my ($tmp, $tmp1, $tmp2, $tmp3, $tmp4, $tmp5);
d5bd8bb71a8970d4ebc4701b3e9ec3efef4954b7Evan Hunt $tmp1 = $1; $tmp2 = $2; $tmp3 = $3; $tmp4 = $4; $tmp5 = $5;
d5bd8bb71a8970d4ebc4701b3e9ec3efef4954b7Evan Hunt if (($tmp2 =~ m@LD_LIBRARY_PATH@) or ($tmp2 =~ m@LD_LIBRARY_PATH_64@)) {
d5bd8bb71a8970d4ebc4701b3e9ec3efef4954b7Evan Hunt if ($tmp4 =~ m@$PHP_ROOT/64@) {
ad1317338af79edad878c9c3e4361798503310baMark Andrews $tmp4 =~ s@$PHP_ROOT/64@$newLibPath64@g;
9519bb92d7f3f35015aecb84954dd21607cc2c80Evan Hunt elsif ($tmp4 =~ m@$PHP_ROOT/64([:].*)@) {
9519bb92d7f3f35015aecb84954dd21607cc2c80Evan Hunt $tmp4 =~ s@$PHP_ROOT/64(:.*)@$newLibPath64$1@g;
1c81aef28ddf0905344cc58dd3ea0ca539ef1414Evan Hunt elsif ($tmp4 =~ m@$PHP_ROOT([:].*)@) {
1c81aef28ddf0905344cc58dd3ea0ca539ef1414Evan Hunt $tmp4 =~ s@$PHP_ROOT(:.*)@$newLibPath$1@g;
1c81aef28ddf0905344cc58dd3ea0ca539ef1414Evan Hunt elsif ($tmp4 =~ m@$PHP_ROOT@) {
da1f585afa8c103508c759142d6aed4edae6936eMark Andrews $tmp4 =~ s@$PHP_ROOT@$newLibPath@g;
a8fa3e2d44ce6a8f4069d8f4229d29f5ba6a4a27Mukund Sivaraman elsif ($tmp2 =~ m@PHP_FCGI_MAX_REQUEST@) {
a8fa3e2d44ce6a8f4069d8f4229d29f5ba6a4a27Mukund Sivaraman $tmp2 =~ s@PHP_FCGI_MAX_REQUEST@PHP_FCGI_MAX_REQUESTS@g;
a8fa3e2d44ce6a8f4069d8f4229d29f5ba6a4a27Mukund Sivaraman $tmp4 =~ s@200@2000@;
d71d41341d36ddfd347daab982f0cb85d3dd7c4eMark Andrews $tmp = $tmp1.$tmp2.$tmp3.$tmp4.$tmp5."\n";
d72952cf254b71c44e5e956a306016a5be9b9c38Mark Andrews $pContents->[$i] = $tmp;
d72952cf254b71c44e5e956a306016a5be9b9c38Mark Andrews $update_reqd = 1;
6b183c64a3281491f8232959a5ece303b4499706Mark Andrews if ($update_reqd) {
5a8f2f0cd67a5dd93d95e6a0935d4805721c3a0bMichał Kępień open(TMPOBJ,">$tmpObjConfFile") or $tmpObjConfStatus = undef;
5a8f2f0cd67a5dd93d95e6a0935d4805721c3a0bMichał Kępień if (defined $tmpObjConfStatus) {
5a8f2f0cd67a5dd93d95e6a0935d4805721c3a0bMichał Kępień for (my $i = 0; $i < $#{@{$pContents}}; $i++) {
5a8f2f0cd67a5dd93d95e6a0935d4805721c3a0bMichał Kępień my $line = $pContents->[$i];
5a8f2f0cd67a5dd93d95e6a0935d4805721c3a0bMichał Kępień print TMPOBJ $line;
e2cc7418bf895d22854d84590b63905fac0d4b90Mark Andrews print "UPDATED: $objConfFile \n";
36ec0d374836d070ba05b495e6f0a27f60e94476Evan Hunt close(TMPOBJ);
36ec0d374836d070ba05b495e6f0a27f60e94476Evan Hunt unlink("$objConfFile");
36ec0d374836d070ba05b495e6f0a27f60e94476Evan Hunt rename("$tmpObjConfFile", "$objConfFile");
e446fd29b9c6c4a7b6b5bb0aee3932578c346718Mukund Sivaraman chmod(0600, "$objConfFile");
b5252fcde512405a68dd4becfe683d9763bd0feaMukund Sivaraman# -----------------------------------------------------------------------------
b5252fcde512405a68dd4becfe683d9763bd0feaMukund Sivaraman# processServerXml
99056063905a9273ec59cf477ae747e0490182b7Mukund Sivaraman# Parse the server.xml and get all the mime files and object files
99056063905a9273ec59cf477ae747e0490182b7Mukund Sivaraman# -----------------------------------------------------------------------------
62f2fefaec754e6a4841ff0e72726e6c0cd89c86Michał Kępieńsub processServerXml {
62f2fefaec754e6a4841ff0e72726e6c0cd89c86Michał Kępień my $file = undef;
62f2fefaec754e6a4841ff0e72726e6c0cd89c86Michał Kępień my $serverXml = "$INSTANCE_ROOT/$INSTANCE_NAME/config/server.xml";
b351a5864727a390e06d787e522b141ca760590fMichał Kępień my $config = eval{XMLin("$serverXml", forcearray=>1, keyattr=>[])};
b351a5864727a390e06d787e522b141ca760590fMichał Kępień print("\nERROR: Problem parsing the $serverXml. Not a valid xml file. \n\n");
b351a5864727a390e06d787e522b141ca760590fMichał Kępień #get the server level mime file
8008de0b11bacb3de3a1016c8c0a46f3c0653184Mark Andrews $file = $config->{"mime-file"}->[0];
8008de0b11bacb3de3a1016c8c0a46f3c0653184Mark Andrews if (defined $file) {
8008de0b11bacb3de3a1016c8c0a46f3c0653184Mark Andrews $file = getValidAbsoluteFilePath($file);
8008de0b11bacb3de3a1016c8c0a46f3c0653184Mark Andrews if (defined $file) {
8008de0b11bacb3de3a1016c8c0a46f3c0653184Mark Andrews push (@$MIME_TYPES_FILES, $file);
7cd594b8427fe742d44295790ba367e1de22a47dEvan Hunt # get the server platform mode
7cd594b8427fe742d44295790ba367e1de22a47dEvan Hunt my $mode = $config->{"platform"}->[0];
7cd594b8427fe742d44295790ba367e1de22a47dEvan Hunt if (defined $mode) {
c76e8412f4ff4f5945157410312df2a8950f942dMark Andrews if ($mode == "64") {
c76e8412f4ff4f5945157410312df2a8950f942dMark Andrews $SERVER_64BIT_MODE = "64";
a2a0100e0fc73c0af67a7c9e3524816954448dc6Evan Hunt for (my $vsCounter = 0; ${config}->{"virtual-server"}->[$vsCounter]; $vsCounter++) {
1feffc6fdb1ba386b22d45ea2d2f1613e717cb9eMark Andrews my $virutalServerElement = ${config}->{"virtual-server"}->[$vsCounter];
1feffc6fdb1ba386b22d45ea2d2f1613e717cb9eMark Andrews #get the virtual server level mime files
1feffc6fdb1ba386b22d45ea2d2f1613e717cb9eMark Andrews for (my $mimeTypescounter = 0; ${virutalServerElement}->{"mime-file"}->[$mimeTypescounter]; $mimeTypescounter++) {
22bed621ef87bc8b6c1fea599b02c4b38dd6bf48Mark Andrews $file = ${virutalServerElement}->{"mime-file"}->[$mimeTypescounter];
22bed621ef87bc8b6c1fea599b02c4b38dd6bf48Mark Andrews $file = getValidAbsoluteFilePath($file);
22bed621ef87bc8b6c1fea599b02c4b38dd6bf48Mark Andrews if (defined $file) {
68d7ff133c9a1b8cfe683c70e997d83395ffd155Evan Hunt push (@$MIME_TYPES_FILES, $file);
e5f5675b1da287ed40aeff081ad2af86090e8d17Evan Hunt #get the virtual server level object files
e5f5675b1da287ed40aeff081ad2af86090e8d17Evan Hunt for (my $objectFilecounter = 0; ${virutalServerElement}->{"object-file"}->[$objectFilecounter]; $objectFilecounter++) {
e5f5675b1da287ed40aeff081ad2af86090e8d17Evan Hunt $file = ${virutalServerElement}->{"object-file"}->[$objectFilecounter];
29f0ced781d745591fd058e530a68a281cd7a510Evan Hunt $file = getValidAbsoluteFilePath($file);
29f0ced781d745591fd058e530a68a281cd7a510Evan Hunt if (defined $file) {
29f0ced781d745591fd058e530a68a281cd7a510Evan Hunt push (@$OBJ_CONF_FILES, $file);
fcb5e646e4d775539e348fa21ba13307f2695bf5Mark Andrews if (@$MIME_TYPES_FILES < 1) {
a22c3cf51567651f74aee5c263c597b8d752c2ccMichał Kępień push (@$MIME_TYPES_FILES, "$INSTANCE_ROOT/$INSTANCE_NAME/config/mime.types");
b301c4293c082fcce4ec26218e6fad346976eb9eMark Andrews if (@$OBJ_CONF_FILES < 1) {
b301c4293c082fcce4ec26218e6fad346976eb9eMark Andrews push (@$OBJ_CONF_FILES, "$INSTANCE_ROOT/$INSTANCE_NAME/config/obj.conf");
5c4e0c7800b5c7783e7f8b9ce80a6f8dc47f8856Mark Andrews# -----------------------------------------------------------------------------
6e1f755f19ef244422e1efa4551fe23775e1a38cMark Andrews# processMagnusConf
6e1f755f19ef244422e1efa4551fe23775e1a38cMark Andrews# Append the MAGNUS_CONF_APPEND_STRING value at the end of magnus.conf file.
6e1f755f19ef244422e1efa4551fe23775e1a38cMark Andrews# -----------------------------------------------------------------------------
435a7cd2293dfa9264678508762ab9acb8d41e50Mark Andrewssub processMagnusConf {
435a7cd2293dfa9264678508762ab9acb8d41e50Mark Andrews my $magnusConfFile = "$INSTANCE_ROOT/$INSTANCE_NAME/config/magnus.conf";
b7a823a402eb5c4e99f283e58d778a903d2e72f5Michał Kępień my $magnusConfStatus = 1;
b7a823a402eb5c4e99f283e58d778a903d2e72f5Michał Kępień if (defined isValidFile($magnusConfFile))
031bc55634f443c7c70fbf44c6ac6d8abe72f22bEvan Hunt # Get the current File Stat.
031bc55634f443c7c70fbf44c6ac6d8abe72f22bEvan Hunt my @statInfo = stat $magnusConfFile;
a64daf673deff2358a91bee26bbf2bf874f47c6eMark Andrews # Verify if the changes already exist.
a64daf673deff2358a91bee26bbf2bf874f47c6eMark Andrews if (open(MAGNUS_R,"<$magnusConfFile")) {
a64daf673deff2358a91bee26bbf2bf874f47c6eMark Andrews my @contents = <MAGNUS_R>;
0aadc6dd7b719539445e7a0a058b15dd9d982a9bMichał Kępień foreach (@contents) {
0aadc6dd7b719539445e7a0a058b15dd9d982a9bMichał Kępień next if (/^\#/); #ignore comments;
0aadc6dd7b719539445e7a0a058b15dd9d982a9bMichał Kępień if ((isNSAPI()) and (/shlib(.*)$phpSoName(.*)/g)) {
0aadc6dd7b719539445e7a0a058b15dd9d982a9bMichał Kępień close(MAGNUS_R);
f20ff8b74d21fa3e3f071544f6fd060d015cf27eMichał Kępień } elsif ((not isNSAPI()) and (/shlib(.*)$fastCGISoName(.*)/g)) {
f20ff8b74d21fa3e3f071544f6fd060d015cf27eMichał Kępień close(MAGNUS_R);
7ff682f3c628d785048bbe0242e6a32ea26c6747Michał Kępień close(MAGNUS_R);
e02fa56849131911e9554133b17a5325b37d0828Michał Kępień open(MAGNUS,">>$magnusConfFile") or $magnusConfStatus = 0;
e02fa56849131911e9554133b17a5325b37d0828Michał Kępień if ($magnusConfStatus == 1) {
abcea74291c37abf68be4e06997c59e5494f06adMark Andrews addToMagnusConf(\*MAGNUS);
abcea74291c37abf68be4e06997c59e5494f06adMark Andrews print "\n\nUPDATED: $magnusConfFile \n";
d748d8a4afc200800f6289683361a393b15ba6bfMichał Kępień print "\nERROR: Unable to write $magnusConfFile. \n\n";
d748d8a4afc200800f6289683361a393b15ba6bfMichał Kępień close(MAGNUS);
cbb33c87f4bcf415c840acb61c9d4642c3c2a8e0Michał Kępień close(MAGNUS);
cbb33c87f4bcf415c840acb61c9d4642c3c2a8e0Michał Kępień chown $statInfo[4], $statInfo[5], $magnusConfFile;
4dc6fa1e92af7a62875b6f6f2931beefd58cb4faEvan Hunt# -----------------------------------------------------------------------------
4dc6fa1e92af7a62875b6f6f2931beefd58cb4faEvan Hunt# processObjConf
4dc6fa1e92af7a62875b6f6f2931beefd58cb4faEvan Hunt# Append the OBJ_CONF_APPEND_STRING value after the <object name="default"
b81b178ab919bdbd92021cfc7e6e8d971cd38e83Mark Andrews# directive in all object files.
b81b178ab919bdbd92021cfc7e6e8d971cd38e83Mark Andrews# -----------------------------------------------------------------------------
bf216589c1a81e4431653a145b252b6ce367d7cdMark Andrewssub processObjConf {
bf216589c1a81e4431653a145b252b6ce367d7cdMark Andrews while(scalar(@$OBJ_CONF_FILES) > 0) {
7dbeb5e7f067585abfb12fac314a0d2a8f0dd040Evan Hunt my $objConfFile = pop(@$OBJ_CONF_FILES);
7dbeb5e7f067585abfb12fac314a0d2a8f0dd040Evan Hunt my $objConfStatus = 1;
6e10f87913db176724e89b52e686b0992898da75Mukund Sivaraman my $tmpObjConfStatus = 1;
6e10f87913db176724e89b52e686b0992898da75Mukund Sivaraman if (defined isValidFile($objConfFile))
6e10f87913db176724e89b52e686b0992898da75Mukund Sivaraman # Get the current File Stat.
37f6466aa327a5b444e41c8cb57ab5caacfe6279Evan Hunt my @statInfo = stat $objConfFile;
36babd3e630f507843c423207cbbbd4758d7cffaTinderbox User # Verify if the changes already exist.
37f6466aa327a5b444e41c8cb57ab5caacfe6279Evan Hunt open(OBJ,"<$objConfFile") or $objConfStatus = undef;
4162d3b36d1a3c25724c7e37ce839f67b2352bbbMark Andrews if (defined $objConfStatus) {
4162d3b36d1a3c25724c7e37ce839f67b2352bbbMark Andrews my @lines = <OBJ>;
4162d3b36d1a3c25724c7e37ce839f67b2352bbbMark Andrews my $escape_path = $PHP_ROOT;
ce6f0c122140647b5652c0d4de523c994fcfea08Michał Kępień $escape_path =~ s/\/(\w)/\\\/$1/g;
ce6f0c122140647b5652c0d4de523c994fcfea08Michał Kępień $escape_path =~ s/\\(\w)/\/$1/g;
f72f5879424ce4081893b306b8c31f29fe9205e0Evan Hunt my $contents = join("",@lines);
f72f5879424ce4081893b306b8c31f29fe9205e0Evan Hunt my $already_configured = undef;
f72f5879424ce4081893b306b8c31f29fe9205e0Evan Hunt if ((isNSAPI()) and ($contents =~ m/
f72f5879424ce4081893b306b8c31f29fe9205e0Evan Hunt \s*Service\s+type="magnus-internal\/php"\s+fn="php5_execute"
1073e2001caee13cc1fa52de97feddd633d50fd8Evan Hunt $already_configured = 1;
1073e2001caee13cc1fa52de97feddd633d50fd8Evan Hunt if ((not isNSAPI()) and (($contents =~ m/
1073e2001caee13cc1fa52de97feddd633d50fd8Evan Hunt \s*Service\s+type=[\"]magnus-internal\/php[\"]
11c4e6d8fcc9bc148543c1ee632315e096d2bcf2Michał Kępień \s*fn=[\"]responder-fastcgi[\"]
11c4e6d8fcc9bc148543c1ee632315e096d2bcf2Michał Kępień \s*app-path=[\"](.*)[\"]
59122481b2aa65de4518677c6949f03711d2553aEvan Hunt /mx) and ($1 =~ m@$escape_path@))) {
59122481b2aa65de4518677c6949f03711d2553aEvan Hunt $already_configured = 1;
fe6d2fd8338d6f6ac4c79bea9a8daad903460040Evan Hunt # migrate existing obj.conf configurations.
fe6d2fd8338d6f6ac4c79bea9a8daad903460040Evan Hunt &migrateObjConf($objConfFile, \@lines);
05a456499af940762d6658366abafb220c5053ccMark Andrews next if ($already_configured);
05a456499af940762d6658366abafb220c5053ccMark Andrews # Create a new obj.conf
cb4e0ef4e2c8a942f99af6ecc6aa564c903b00a0Mark Andrews my $tmpObjConfFile = "$objConfFile"."tmp";
cb4e0ef4e2c8a942f99af6ecc6aa564c903b00a0Mark Andrews open(TMPOBJ,">$tmpObjConfFile") or $tmpObjConfStatus = undef;
cb4e0ef4e2c8a942f99af6ecc6aa564c903b00a0Mark Andrews if (defined $tmpObjConfStatus) {
cb4e0ef4e2c8a942f99af6ecc6aa564c903b00a0Mark Andrews if (@lines) {
e3efc855f9f0acc9b14bb8e9c833e0fa209068b6Mark Andrews foreach my $line (@lines) {
e3efc855f9f0acc9b14bb8e9c833e0fa209068b6Mark Andrews if (($line =~ /^<Object/i) &&
e3efc855f9f0acc9b14bb8e9c833e0fa209068b6Mark Andrews (($line =~ /name=default>/i) ||
e56c0854589d936f911e0aac2f2bf53cbc8a6af7Michał Kępień ($line =~ /name=default\s/i) ||
e56c0854589d936f911e0aac2f2bf53cbc8a6af7Michał Kępień ($line =~ /name="default"/i))) {
e56c0854589d936f911e0aac2f2bf53cbc8a6af7Michał Kępień print TMPOBJ $line;
6727802528c27484e0d36d70f0b936022d3226e3Michał Kępień addToObjConf(\*TMPOBJ);
6727802528c27484e0d36d70f0b936022d3226e3Michał Kępień print "UPDATED: $objConfFile \n";
6727802528c27484e0d36d70f0b936022d3226e3Michał Kępień } elsif ($line =~ /PathCheck\s+fn\s*=\s*(\S+)\s+(\S+)\s*=\s*(\S+)$/) {
6727802528c27484e0d36d70f0b936022d3226e3Michał Kępień my $funcName = $1;
4d41be5f9e86c11a6f00e2b005cfc5abae2c1ab3Mark Andrews my $valueName = $2;
4d41be5f9e86c11a6f00e2b005cfc5abae2c1ab3Mark Andrews my $values = $3;
bfde61d5194a534d800f3b90008d1f52261922c5Mark Andrews if (($funcName =~ /find-index/) and ($valueName =~ /index-names/)) {
bfde61d5194a534d800f3b90008d1f52261922c5Mark Andrews $values =~ s/[\"](\S+)[\"]/$1/;
bfde61d5194a534d800f3b90008d1f52261922c5Mark Andrews $values = "$1".",index.php";
42ae02626d05921ca7508ae6f9c48ea699596bc6Mark Andrews my $newLine = <<__UP_TO_THIS_POINT_;
6b56350522d18f10edbf2d3778cd0fea74e4f3d2Mark AndrewsPathCheck fn=$funcName $valueName=\"$values\"
6b56350522d18f10edbf2d3778cd0fea74e4f3d2Mark Andrews__UP_TO_THIS_POINT_
42ae02626d05921ca7508ae6f9c48ea699596bc6Mark Andrews print TMPOBJ $newLine;
16f43564c6875e2bedd346c18c494933ad51e4faMukund Sivaraman print TMPOBJ $line;
16f43564c6875e2bedd346c18c494933ad51e4faMukund Sivaraman print TMPOBJ $line;
8ed6c49f1a7f06d3ed39bee7731ff91d8dfd8dc7Mark Andrews print "\nERROR: Unable to write $objConfFile \n\n";
8ed6c49f1a7f06d3ed39bee7731ff91d8dfd8dc7Mark Andrews close(TMPOBJ);
565535d1820c63c64ec3c89e1f4815c326aed7aeEvan Hunt unlink("$tmpObjConfFile");
f7d148398ca4511551c737e655b15f7d0d59a783Mark Andrews close(TMPOBJ);
f7d148398ca4511551c737e655b15f7d0d59a783Mark Andrews unlink("$objConfFile");
3a84275b10ab16965e86f6ca97e70c1bdca885a0Mark Andrews rename("$tmpObjConfFile", "$objConfFile");
3a84275b10ab16965e86f6ca97e70c1bdca885a0Mark Andrews chmod(0600, "$objConfFile");
3a84275b10ab16965e86f6ca97e70c1bdca885a0Mark Andrews chown $statInfo[4], $statInfo[5], $objConfFile;
398834f7559617bdfd6c10ba555609a2f306e3d4Mark Andrews# -----------------------------------------------------------------------------
28061f80b698171892e81c0856bc722190947998Evan Hunt# processMimeTypes
28061f80b698171892e81c0856bc722190947998Evan Hunt# Append the MIME_TYPES_APPEND_STRING value at the end of
28061f80b698171892e81c0856bc722190947998Evan Hunt# all the mime types file.
a785bf2c39c6f223a93c27bbff81591b38095577Mark Andrews# -----------------------------------------------------------------------------
a03f4b1ea4f1a4a70963fbeb606841c217f9e5f3Evan Huntsub processMimeTypes {
a03f4b1ea4f1a4a70963fbeb606841c217f9e5f3Evan Hunt while(scalar(@$MIME_TYPES_FILES) > 0) {
a03f4b1ea4f1a4a70963fbeb606841c217f9e5f3Evan Hunt my $mimeTypesFile = pop(@$MIME_TYPES_FILES);
a03f4b1ea4f1a4a70963fbeb606841c217f9e5f3Evan Hunt my $mimeTypesStatus = 1;
d315545e6db6792692fe2dcb788ac6717a33b75fEvan Hunt if (defined isValidFile($mimeTypesFile)) {
d315545e6db6792692fe2dcb788ac6717a33b75fEvan Hunt # Get the current File Stat.
00f131293520b70728cd48840e09953fa45a745bMark Andrews my @statInfo = stat $mimeTypesFile;
00f131293520b70728cd48840e09953fa45a745bMark Andrews # Verify if the changes already exist.
b2e71853060a384070d422afda6d1c692ff608e3Mark Andrews if (open(MIME_R,"<$mimeTypesFile")) {
b2e71853060a384070d422afda6d1c692ff608e3Mark Andrews my @contents = <MIME_R>;
b2e71853060a384070d422afda6d1c692ff608e3Mark Andrews for (my $i = $#contents; $i > 0; $i--) {
b2e71853060a384070d422afda6d1c692ff608e3Mark Andrews if ($contents[$i] =~ /magnus-internal\/php/g) {
42c1acfa478aacfbda2d298cf74a137de2df4b87Michał Kępień close(MIME_R);
214b53880b6d77359f60feccb91bd2589059300aEvan Hunt close(MIME_R);
dd5375de0a7a515ee4fb2fd217e9577259d38c07Mark Andrews open(MIME,">>$mimeTypesFile") or $mimeTypesStatus = undef;
dd5375de0a7a515ee4fb2fd217e9577259d38c07Mark Andrews if (defined $mimeTypesStatus) {
dd5375de0a7a515ee4fb2fd217e9577259d38c07Mark Andrews addToMimeTypes(\*MIME);
3a58e1fefb0a9fd5dab11f271a320c6b90473f76Mukund Sivaraman print "UPDATED: $mimeTypesFile \n";
3a58e1fefb0a9fd5dab11f271a320c6b90473f76Mukund Sivaraman print "\nERROR: Unable to write $mimeTypesFile. \n\n";
7c67b8c2b076971e6a9f8b0db932201366f13d47Mark Andrews close(MIME);
5aed5dc329a2bf1340e9ff2256c1cf4e3005ea0bMark Andrews close(MIME);
5aed5dc329a2bf1340e9ff2256c1cf4e3005ea0bMark Andrews chown $statInfo[4], $statInfo[5], $mimeTypesFile;
387f5e872d40426acbc739d2e9b2bb37c123dd56Mark Andrews# -----------------------------------------------------------------------------
3440cf9c60cd5d35634e7f274fd3eccbba2173a5Evan Hunt# addMagnusConfEntry
3440cf9c60cd5d35634e7f274fd3eccbba2173a5Evan Hunt# Add the required magnus conf entry
3440cf9c60cd5d35634e7f274fd3eccbba2173a5Evan Hunt# -----------------------------------------------------------------------------
387f5e872d40426acbc739d2e9b2bb37c123dd56Mark Andrewssub addToMagnusConf {
032d2134a4c1808696688db9bf6f20253e5d05b5Mark Andrews my $FILENAME = shift;
032d2134a4c1808696688db9bf6f20253e5d05b5Mark Andrews my $phpNsapi = $phpSoName;
fb9ef31fed818384ef8997f2dc5f27252c6f767eEvan Hunt if (isNSAPI()) {
fb9ef31fed818384ef8997f2dc5f27252c6f767eEvan Hunt $entry = <<__UP_TO_THIS_POINT_;
823ccd1f02802966395d58c916e9f988320fd6eeEvan HuntInit fn="load-modules" shlib="$phpNsapi" shlib_flags="global|now"
823ccd1f02802966395d58c916e9f988320fd6eeEvan Hunt funcs="php5_init,php5_close,php5_execute,php5_auth_trans"
b6fa637fc8c92f42a21e6f97259598968717af3dEvan HuntInit fn="php5_init"
b6fa637fc8c92f42a21e6f97259598968717af3dEvan Hunt php_ini="$PHP_CONF_ROOT"
b6fa637fc8c92f42a21e6f97259598968717af3dEvan Hunt php_ini_scandir="$PHP_MODULES_CONF_ROOT"
b6fa637fc8c92f42a21e6f97259598968717af3dEvan Hunt errorString="PHP failed to initialize."
ace5680c122ef239e64eec1120f13f5a7f087d79Mark Andrews__UP_TO_THIS_POINT_
59d940391ce90963cd3f4b22201b3fca2ffda22aMark Andrews } else { # fastcgi
59d940391ce90963cd3f4b22201b3fca2ffda22aMark Andrews $entry = <<__UP_TO_THIS_POINT_;
6b432e11497f905a6b6f048df3e8a01ce8abbb1eMark AndrewsInit fn="load-modules" shlib="$fastCGISoName"
cb9345c996de9d9c990009f14fc83fbbe9c5e3e6Mark Andrews__UP_TO_THIS_POINT_
c935952ede45595a821cfed7f73b57f3b239ca2bMark Andrews print $FILENAME $entry;
9604a49da0130534f2f4aaa0cbfa78b5f589196fMark Andrews# -----------------------------------------------------------------------------
9604a49da0130534f2f4aaa0cbfa78b5f589196fMark Andrews# addMimeTypesEntry
da5b569ddb9b8bf84242f3085d18e215ec490fdaMark Andrews# Add the required mime types entry
da5b569ddb9b8bf84242f3085d18e215ec490fdaMark Andrews# -----------------------------------------------------------------------------
da5b569ddb9b8bf84242f3085d18e215ec490fdaMark Andrewssub addToMimeTypes {
c83a3061551c86bd661839be935de061f7322f5cEvan Hunt my $FILENAME = shift;
c83a3061551c86bd661839be935de061f7322f5cEvan Hunt my $entry = <<__UP_TO_THIS_POINT_;
c83a3061551c86bd661839be935de061f7322f5cEvan Hunttype=magnus-internal/php exts=php,php3,php4,php5
ac9072210cea5283e554f1787876b647a08fda96Mark Andrews__UP_TO_THIS_POINT_
ac9072210cea5283e554f1787876b647a08fda96Mark Andrews print $FILENAME $entry;
512765ba1e3f0b29e2c1ae4b0138838c6422f2bdEvan Hunt# -----------------------------------------------------------------------------
512765ba1e3f0b29e2c1ae4b0138838c6422f2bdEvan Hunt# addObjConfEntry
27a262bc4d38c7a8230677ac2685ec7a4f509f70Mark Andrews# Add the required obj conf entry
27a262bc4d38c7a8230677ac2685ec7a4f509f70Mark Andrews# -----------------------------------------------------------------------------
27a262bc4d38c7a8230677ac2685ec7a4f509f70Mark Andrewssub addToObjConf {
3b38e4b8344cb3bb28f2b116d2e39f8371ef8e34Mukund Sivaraman my $FILENAME = shift;
3b38e4b8344cb3bb28f2b116d2e39f8371ef8e34Mukund Sivaraman # On windows, replace \ with / in paths
3b38e4b8344cb3bb28f2b116d2e39f8371ef8e34Mukund Sivaraman my $l_php_root = $PHP_ROOT;
3b38e4b8344cb3bb28f2b116d2e39f8371ef8e34Mukund Sivaraman if (isWindows()) {
3b38e4b8344cb3bb28f2b116d2e39f8371ef8e34Mukund Sivaraman $l_php_root =~ s/\\/\//g;
0d24df5c0b2f9546f403113df8ac4457223bc92fEvan Hunt my $newLibPath = "$l_php_root/lib";
0d24df5c0b2f9546f403113df8ac4457223bc92fEvan Hunt my $newLibPath64 = "$l_php_root/lib/64";
0d24df5c0b2f9546f403113df8ac4457223bc92fEvan Hunt my $childs = &detectDefaultChildren();
7c1c9b4dcd9efa507cdb58d3d83e99ab4836096dMark Andrews my $unixFastCGIEntry = <<__UNIX_FASTCGI_ENTRY_
7c1c9b4dcd9efa507cdb58d3d83e99ab4836096dMark Andrews<If -f \$path>
9689922a0d936b04feb418fbaf4c1420f745ea58Mark Andrews fn="responder-fastcgi"
02989eceeff85cd6c5dd31848a12674f74bba7cfEvan Hunt bind-path="localhost:3101"
02989eceeff85cd6c5dd31848a12674f74bba7cfEvan Hunt app-env="PHPRC=$PHP_CONF_ROOT"
02989eceeff85cd6c5dd31848a12674f74bba7cfEvan Hunt app-env="PHP_INI_SCANDIR=$PHP_MODULES_CONF_ROOT"
34f649fa22a16acb488ccf0f8a41d541c6ba7da1Evan Hunt app-env="PHP_FCGI_CHILDREN=$childs"
34f649fa22a16acb488ccf0f8a41d541c6ba7da1Evan Hunt app-env="PHP_FCGI_MAX_REQUESTS=2000"
34f649fa22a16acb488ccf0f8a41d541c6ba7da1Evan Hunt app-env="FCGI_WEB_SERVER_ADDRS=127.0.0.1"
34f649fa22a16acb488ccf0f8a41d541c6ba7da1Evan Hunt bucket="php-bucket"
8b9c4592ed718c4187971f1104381faf538bf4f7Evan HuntService type="magnus-internal/php" fn="set-variable" error="404"
264e17e73941059877ccf3c96f26aac15a25500bMukund Sivaraman__UNIX_FASTCGI_ENTRY_
9a8b2b3ab35fbbdf03acba32dade90ad91f75742Mukund Sivaraman my $windowsFastCGIEntry = <<__WINDOWS_FASTCGI_ENTRY_
eeb16584fbd3564136cb4c950fc5e1b54690de68Mukund Sivaraman fn="responder-fastcgi"
eeb16584fbd3564136cb4c950fc5e1b54690de68Mukund Sivaraman bind-path="$INSTANCE_NAME--php_cgi"
eeb16584fbd3564136cb4c950fc5e1b54690de68Mukund Sivaraman app-env="PHPRC=$l_php_root"
eeb16584fbd3564136cb4c950fc5e1b54690de68Mukund Sivaraman app-env="PHP_FCGI_CHILDREN=$childs"
9540b42695c15fdd5f01b4c663e21936e6c38c82Mukund Sivaraman app-env="PHP_FCGI_MAX_REQUESTS=2000"
9540b42695c15fdd5f01b4c663e21936e6c38c82Mukund Sivaraman bucket="php-bucket"
9540b42695c15fdd5f01b4c663e21936e6c38c82Mukund Sivaraman__WINDOWS_FASTCGI_ENTRY_
fec9247b8f1ab52e999643ae03f0550387ec359fMukund Sivaraman my $nsapiEntry = <<__NSAPI_ENTRY_
fec9247b8f1ab52e999643ae03f0550387ec359fMukund SivaramanService type="magnus-internal/php" fn="php5_execute"
0d7548ee341c83c540624a423e2c701b6e9ddc4eEvan Hunt__NSAPI_ENTRY_
527163f0e5e8639bcceb7fe52387285042f5b24cEvan Hunt if (isNSAPI()) {
62a6147e51fd1ccb9ec1c1b6c97b6e9b9ef1f002Evan Hunt $entry = $nsapiEntry;
62a6147e51fd1ccb9ec1c1b6c97b6e9b9ef1f002Evan Hunt if (isWindows()) {
4c432aae90bc9b220725ca7df5a6af40cf4c74b3Mark Andrews $entry = $windowsFastCGIEntry;
4c432aae90bc9b220725ca7df5a6af40cf4c74b3Mark Andrews $entry = $unixFastCGIEntry;
911576956388270fe2401fbf9236d8879d2795e9Evan Hunt print $FILENAME $entry;
fd0d60b3a0139c040fedb0bb765fd9667831412eMark Andrews# -----------------------------------------------------------------------------
fd0d60b3a0139c040fedb0bb765fd9667831412eMark Andrews# Check if SAPI is nsapi
3001a1b4e6298466882a4147307b4c28a3b08f91Mark Andrews# -----------------------------------------------------------------------------
3001a1b4e6298466882a4147307b4c28a3b08f91Mark Andrewssub isNSAPI() {
1bce43adcc11d21afaf645cbe466553aabc725b2Mark Andrews if ($SAPI =~ m/nsapi/i) {
52cae869e0296713b764f6065bdad80832d4c493Mark Andrews# -----------------------------------------------------------------------------
403e7b451207fe6514a5d641562713b1af233b9cEvan Hunt# Check platform
403e7b451207fe6514a5d641562713b1af233b9cEvan Hunt# -----------------------------------------------------------------------------
62b5dd5b09cb575281f8193476b58a4bd9870fc9Evan Huntsub isWindows() {
62b5dd5b09cb575281f8193476b58a4bd9870fc9Evan Hunt if ($OSNAME =~ m/WIN/i) {
8bcd80824c51c802c2927236b012cd526f569b04Mark Andrews# -----------------------------------------------------------------------------
3be4330b77e6de0c6aa7cca74c1ae17fc661ac32Tinderbox User# checkFilesWritable
8bcd80824c51c802c2927236b012cd526f569b04Mark Andrews# Check all the necessary files writable before adding the entries
7fcbbd6fa9ed199cf6947bb6b204da5438211faaMark Andrews# -----------------------------------------------------------------------------
7fcbbd6fa9ed199cf6947bb6b204da5438211faaMark Andrewssub checkFilesWritable {
559cbe04e73cf601784a371e09554c20407a6c7bEvan Hunt exit 1 unless defined isValidFile("$INSTANCE_ROOT/$INSTANCE_NAME/config/magnus.conf");
559cbe04e73cf601784a371e09554c20407a6c7bEvan Hunt my @TMP_OBJ_CONF_FILES = @$OBJ_CONF_FILES;
559cbe04e73cf601784a371e09554c20407a6c7bEvan Hunt my @TMP_MIME_TYPES_FILES = @$MIME_TYPES_FILES;
559cbe04e73cf601784a371e09554c20407a6c7bEvan Hunt while(scalar(@TMP_OBJ_CONF_FILES) > 0) {
6ef61e764583887172e27c3bc681e36cfa27b469Mark Andrews my $objConfFile = pop(@TMP_OBJ_CONF_FILES);
94a94fca2444bb18b4bf74d6c5dbcbb89f139237Mark Andrews exit 1 unless defined isValidFile("$objConfFile");
b81977ae70138c9befd8fa4bb66b6145e1986561Mark Andrews while(scalar(@TMP_MIME_TYPES_FILES) > 0) {
43769594c0e42e9822ef71daee8bbf35252d9300Evan Hunt my $mimeTypesFile = pop(@TMP_MIME_TYPES_FILES);
43769594c0e42e9822ef71daee8bbf35252d9300Evan Hunt exit 1 unless defined isValidFile("$mimeTypesFile");
fc8c8966c906b305cb8b416a8f23f21abf103b7fEvan Hunt# -----------------------------------------------------------------------------
fc8c8966c906b305cb8b416a8f23f21abf103b7fEvan Hunt# getValidAbsoluteFilePath
fc8c8966c906b305cb8b416a8f23f21abf103b7fEvan Hunt# To get the valid absolute file path
07b7a3eadeda94eddd50977c9582dae2f955b638Evan Hunt# -----------------------------------------------------------------------------
07b7a3eadeda94eddd50977c9582dae2f955b638Evan Huntsub getValidAbsoluteFilePath {
07b7a3eadeda94eddd50977c9582dae2f955b638Evan Hunt my ($file) = @_;
85a26f938eac3e147a48f671f6a6b5ee9cd1767dEvan Hunt if (defined $file) {
85a26f938eac3e147a48f671f6a6b5ee9cd1767dEvan Hunt my ($fileName,$filePath,$fileNameSuffix) = fileparse("$file");
4901f2c10b4393fd4407c8feb022c3415ab323c7Mark Andrews if ($fileName eq $file) {
4901f2c10b4393fd4407c8feb022c3415ab323c7Mark Andrews $file = "$INSTANCE_ROOT/$INSTANCE_NAME/config/$fileName";
8e9dbb62224ce4d7342b0e7db96cf31e415aaaf0Evan Hunt $file = undef unless defined isValidFile($file);
b5ad0916242ca4ce3f053efe78c1725dce996717Mark Andrews return $file;
da23e32e410eb9b106ae926858140303bfd1d96fMark Andrews# -----------------------------------------------------------------------------
da23e32e410eb9b106ae926858140303bfd1d96fMark Andrews# getValidAbsoluteFilePath
da23e32e410eb9b106ae926858140303bfd1d96fMark Andrews# Valid file check
18ab9a0a34ea025a6bbb09b711b00cfa11eec1b5Evan Hunt# -----------------------------------------------------------------------------
832f5803f69f4548ba3777f8b5741768bbbf5f75Mark Andrewssub isValidFile {
c742ef745e1f3400b79c9df3d188896ccbb50f15Evan Hunt my ($file) = @_;
832f5803f69f4548ba3777f8b5741768bbbf5f75Mark Andrews my $status = undef;
832f5803f69f4548ba3777f8b5741768bbbf5f75Mark Andrews if (-e "$file") {
832f5803f69f4548ba3777f8b5741768bbbf5f75Mark Andrews if (-w "$file") {
4441328a1d38bbb2ec20a0a219b84d472312da26Mark Andrews $status = 1;
4441328a1d38bbb2ec20a0a219b84d472312da26Mark Andrews print "\nERROR: $file is not writable. \n\n";
7bcba68b9510908c07d6c2568faca06629511660Mark Andrews print "\nERROR: $file not found, $! \n\n";
2cee8eadec6545fb0ce10fb8c1d7b60870ec2fb4Mark Andrews return $status;
81df1363fbd13f3a80987704c23e14413e6f1d2aMark Andrews# -----------------------------------------------------------------------------
81df1363fbd13f3a80987704c23e14413e6f1d2aMark Andrews# detectDefaultChildren
81df1363fbd13f3a80987704c23e14413e6f1d2aMark Andrews# detect current architecture and come up with default values.
08397f5b6ca783a8c55f48b827201b75c3fca4bfMark Andrews# set default value to a higher value on Niagara based servers.
08397f5b6ca783a8c55f48b827201b75c3fca4bfMark Andrews# -----------------------------------------------------------------------------
08397f5b6ca783a8c55f48b827201b75c3fca4bfMark Andrewssub detectDefaultChildren {
e63d63dc8510c669e1575b2762265842e8783822Evan Hunt my $default = 2;
e63d63dc8510c669e1575b2762265842e8783822Evan Hunt if ($OSNAME =~ /SOLARIS/i) {
e63d63dc8510c669e1575b2762265842e8783822Evan Hunt if (-x "/bin/uname") {
f5c17a057fc5974bb51d7bc8c5827a7fd6dc9aeeEvan Hunt my $type = qx(/bin/uname -m);
f5c17a057fc5974bb51d7bc8c5827a7fd6dc9aeeEvan Hunt chomp($type);
f5c17a057fc5974bb51d7bc8c5827a7fd6dc9aeeEvan Hunt $default *= 3 if ($type =~ /sun4u/i);
d6080de9be23024f5f7a1e40d0cb06df94cdcb72Mark Andrews $default *= 6 if ($type =~ /sun4v/);
6649db1ca4f3dc2d14f41f77e03867ac013215f9Evan Hunt return $default;
6649db1ca4f3dc2d14f41f77e03867ac013215f9Evan Hunt# -----------------------------------------------------------------------------
b1866070ef4fb9e17bff16ad458f629bbc5a4accwpk# printUsage
b1866070ef4fb9e17bff16ad458f629bbc5a4accwpk# print the usage command
6b45fd062bbcf2986078bf25b2b617b844a9fde4Mark Andrews# -----------------------------------------------------------------------------
6b45fd062bbcf2986078bf25b2b617b844a9fde4Mark Andrewssub printUsage {
6b45fd062bbcf2986078bf25b2b617b844a9fde4Mark Andrews print "This script will configure a web server instance to run PHP scripts\n" .
72cae054ad81a985f1e0023f9ff92b6ff1872183Mark Andrews "either as FastCGI or NSAPI \n".
72cae054ad81a985f1e0023f9ff92b6ff1872183Mark Andrews "usage : \n" .
72cae054ad81a985f1e0023f9ff92b6ff1872183Mark Andrews " setupPHP -instancename=<instance name> [-sapi=fastcgi|nsapi]\n" .
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews "Examples:\n" .
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews "This below example configures Web Server to run PHP in FastCGI mode (Default)\n".
544e2b48ece5724f2c4a0d6636048a72335cfd54Evan Hunt " setupPHP -instancename=https-php\n" .
23ac7e663494ffdfd78b52d1a0a62d93f0d30d93Mark Andrews "This below example configures Web Server to run PHP in NSAPI mode\n".
458e816ed08044cfe82c89fecd38bce540b23ff0Mark Andrews " setupPHP -instancename=https-php -sapi=nsapi\n";
d84a356d4b122d9a50dbca6776c820f5e59ec44dMark Andrews# -----------------------------------------------------------------------------
bc2510a6a5e406bdef580452e6ae3e1298a7d1d6Mark Andrews# printResult
bc2510a6a5e406bdef580452e6ae3e1298a7d1d6Mark Andrews# print the post setup steps
bc2510a6a5e406bdef580452e6ae3e1298a7d1d6Mark Andrews# -----------------------------------------------------------------------------
1160ea4c2847b276946cf6bd00504929ec4f6e44Mark Andrewssub printResult {
1160ea4c2847b276946cf6bd00504929ec4f6e44Mark Andrews #remove "https-" from the instance name and use it as the config name
348d80fb8490f4547aaa569e5f7ea2a032543bacMark Andrews my $configName = undef;
348d80fb8490f4547aaa569e5f7ea2a032543bacMark Andrews $configName = $INSTANCE_NAME;
47071b7310bd6d4d12169c336faac72c8c3d9ecfMark Andrews $configName = substr($INSTANCE_NAME, 6) if ($INSTANCE_NAME =~ /^https/);
45f206e6c1521c710947e9d5e734c32c6b286b13Mark Andrews my $result = <<__UP_TO_THIS_POINT_;
45f206e6c1521c710947e9d5e734c32c6b286b13Mark AndrewsSetup was sucessful.
f6f3264d8c81cda5d489e29d2141f1a92fbe4c84Mark Andrews--------------------
f6f3264d8c81cda5d489e29d2141f1a92fbe4c84Mark AndrewsThe following steps are necessary to make the changes to all the nodes.
960989925556246cc86f1905a5d62e6b0b69dc02Mark Andrews(1) Start the admin server
d77cab69bf9676f828c48c217828a25e8ba41c63Mark Andrews(2) Connect to the admin server using wadm command
d77cab69bf9676f828c48c217828a25e8ba41c63Mark Andrews $INSTALL_ROOT/bin/wadm [--user=admin-user] [--password-file=admin-pswd-file] [--host=admin-host] [--port=admin-port]
f1b29d8428362842c429157b4925e529463eab4cEvan Hunt(3) Pull the modified config from the node to config store
f1b29d8428362842c429157b4925e529463eab4cEvan Hunt using the following command in wadm console:
d0c5ff7f65a08e2ccc9bc06e0ef9f61e36875b50Mark Andrews pull-config --config=$configName nodehost
83a28ca274521e15086fc39febde507bcc4e145eMark Andrews For Example: If the host name for the node is xyz.com then enter the command like,
1585a9f239969a65b974ff741ff2a7a79b148891Evan Hunt pull-config --config=$configName xyz.com
1585a9f239969a65b974ff741ff2a7a79b148891Evan Hunt(4) Deploy the new changes to all nodes using
2fb4184d9d55a6b8709356144730e323e265d58fEvan Hunt the following command in wadm console:
2fb4184d9d55a6b8709356144730e323e265d58fEvan Hunt deploy-config $configName
5be93f5dff21fa067f52065e3521b7d82f32c779Mark Andrews__UP_TO_THIS_POINT_
6ae22c411920be5f5fd1780ac0cd44cbb21b144aMukund Sivaraman print $result;