From 41af7984c1d7172aae736e16d42b024b8470f91c Mon Sep 17 00:00:00 2001 From: tomas Date: Wed, 24 Nov 2004 04:07:46 +0000 Subject: [PATCH] Changes for less verbose and more robust setup process. Some documentation added. --- livesupport/modules/archiveServer/Makefile | 48 ++++--------- .../modules/archiveServer/bin/getUrl.sh | 44 ++++++++++++ .../modules/archiveServer/bin/setupDirs.sh | 59 ++++++++++++++++ livesupport/modules/archiveServer/doc/INSTALL | 6 +- .../modules/archiveServer/var/conf.php | 6 +- .../archiveServer/var/install/getGname.php | 39 +++++++++++ .../archiveServer/var/install/getWwwRoot.php | 39 +++++++++++ .../archiveServer/var/install/getXrUrl.php | 39 +++++++++++ .../archiveServer/var/install/install.php | 34 +++++----- .../archiveServer/var/install/uninstall.php | 14 ++-- .../archiveServer/var/xmlrpc/testRunner.sh | 6 +- livesupport/modules/storageServer/Makefile | 57 +++++----------- .../modules/storageServer/bin/getUrl.sh | 44 ++++++++++++ .../modules/storageServer/bin/setupDirs.sh | 59 ++++++++++++++++ livesupport/modules/storageServer/doc/INSTALL | 4 ++ .../modules/storageServer/var/GreenBox.php | 8 +-- .../modules/storageServer/var/conf.php | 6 +- .../storageServer/var/install/getGname.php | 36 +++++++++- .../storageServer/var/install/getWwwRoot.php | 35 +++++++++- .../storageServer/var/install/getXrUrl.php | 35 +++++++++- .../storageServer/var/install/install.php | 37 +++++----- .../storageServer/var/install/uninstall.php | 16 +++-- .../storageServer/var/tests/transTest.php | 68 +++++++++++++++---- .../storageServer/var/xmlrpc/testRunner.sh | 61 +++++++++-------- 24 files changed, 619 insertions(+), 181 deletions(-) create mode 100755 livesupport/modules/archiveServer/bin/getUrl.sh create mode 100755 livesupport/modules/archiveServer/bin/setupDirs.sh create mode 100644 livesupport/modules/archiveServer/var/install/getGname.php create mode 100644 livesupport/modules/archiveServer/var/install/getWwwRoot.php create mode 100644 livesupport/modules/archiveServer/var/install/getXrUrl.php create mode 100755 livesupport/modules/storageServer/bin/getUrl.sh create mode 100755 livesupport/modules/storageServer/bin/setupDirs.sh diff --git a/livesupport/modules/archiveServer/Makefile b/livesupport/modules/archiveServer/Makefile index 7224744ae..3cb7e60c1 100644 --- a/livesupport/modules/archiveServer/Makefile +++ b/livesupport/modules/archiveServer/Makefile @@ -20,7 +20,7 @@ # # # Author : $Author: tomas $ -# Version : $Revision: 1.2 $ +# Version : $Revision: 1.3 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/Attic/Makefile,v $ # # @configure_input@ @@ -62,17 +62,13 @@ USR_LIB_DIR = ${USR_DIR}/lib DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config -GET_GNAME = install/getGname.php -WWW_ROOT := $(shell cd ../storageServer/var/install; php -q getWwwRoot.php) -HTTP_GROUP := $(shell curl -s ${WWW_ROOT}/${GET_GNAME}) - -PHP_DIR = ${BASE_DIR}/var -INSTALL_DIR = ${PHP_DIR}/install -STOR_DIR = ${PHP_DIR}/stor -ACCESS_DIR = ${PHP_DIR}/access -TRANS_DIR = ${PHP_DIR}/trans -BUFF_DIR = ${STOR_DIR}/buffer -TEST_RUNNER = ${PHP_DIR}/xmlrpc/testRunner.sh +PHP_DIR = ${BASE_DIR}/var +INSTALL_DIR = ${PHP_DIR}/install +STOR_DIR = ${PHP_DIR}/stor +ACCESS_DIR = ${PHP_DIR}/access +TRANS_DIR = ${PHP_DIR}/trans +BUFF_DIR = ${STOR_DIR}/buffer +TEST_RUNNER = ${PHP_DIR}/xmlrpc/testRunner.sh #------------------------------------------------------------------------------- # Configuration parameters @@ -93,11 +89,13 @@ TEST_RUNNER = ${PHP_DIR}/xmlrpc/testRunner.sh #------------------------------------------------------------------------------- # Targets #------------------------------------------------------------------------------- -.PHONY: all dir_setup doc clean docclean depclean distclean dist db_init db_clean +.PHONY: all dir_setup doc clean docclean depclean distclean dist \ + db_init db_clean all: dir_setup db_init -dir_setup: ${DOXYGEN_DIR} ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR} +dir_setup: ${DOXYGEN_DIR} + bin/setupDirs.sh ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR} ${BUFF_DIR} doc: ${DOXYGEN} ${DOXYGEN_CONFIG} @@ -120,7 +118,8 @@ distclean: clean docclean #check: all ${TEST_RUNNER} # ${TEST_RUNNER} check: all - +# $(MAKE) -C ../storageServer transtest + #------------------------------------------------------------------------------- # Specific targets #------------------------------------------------------------------------------- @@ -136,25 +135,6 @@ ${TMP_DIR}: ${DOXYGEN_DIR}: ${MKDIR} ${DOXYGEN_DIR} -${STOR_DIR}: - ${MKDIR} ${STOR_DIR} - chown .${HTTP_GROUP} ${STOR_DIR} - chmod g+ws ${STOR_DIR} - -${ACCESS_DIR}: - ${MKDIR} ${ACCESS_DIR} - chown .${HTTP_GROUP} ${ACCESS_DIR} - chmod g+ws ${ACCESS_DIR} - -${TRANS_DIR}: - ${MKDIR} ${TRANS_DIR} - chown .${HTTP_GROUP} ${TRANS_DIR} - chmod g+ws ${TRANS_DIR} - -${BUFF_DIR}: - ${MKDIR} ${BUFF_DIR} - chmod g+w ${BUFF_DIR} - ${TEST_RUNNER}: #------------------------------------------------------------------------------- diff --git a/livesupport/modules/archiveServer/bin/getUrl.sh b/livesupport/modules/archiveServer/bin/getUrl.sh new file mode 100755 index 000000000..a6d13613a --- /dev/null +++ b/livesupport/modules/archiveServer/bin/getUrl.sh @@ -0,0 +1,44 @@ +#!/bin/bash +#------------------------------------------------------------------------------- +# Copyright (c) 2004 Media Development Loan Fund +# +# This file is part of the LiveSupport project. +# http://livesupport.campware.org/ +# To report bugs, send an e-mail to bugs@campware.org +# +# LiveSupport is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LiveSupport is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LiveSupport; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# Author : $Author: tomas $ +# Version : $Revision: 1.1 $ +# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/bin/getUrl.sh,v $ +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# This script grabs string at suplied URL +#------------------------------------------------------------------------------- + +URL=$1 +RES=`curl -sf ${URL}` || \ + { + ERN=$?; + if [ $ERN == 22 ] ; then + echo "ERROR: curl: 22 - wrong URL ($URL)"; + else + echo "ERROR: $ERN - unknown"; + fi; + exit 1; + } +echo $RES diff --git a/livesupport/modules/archiveServer/bin/setupDirs.sh b/livesupport/modules/archiveServer/bin/setupDirs.sh new file mode 100755 index 000000000..5dea8250c --- /dev/null +++ b/livesupport/modules/archiveServer/bin/setupDirs.sh @@ -0,0 +1,59 @@ +#!/bin/bash +#------------------------------------------------------------------------------- +# Copyright (c) 2004 Media Development Loan Fund +# +# This file is part of the LiveSupport project. +# http://livesupport.campware.org/ +# To report bugs, send an e-mail to bugs@campware.org +# +# LiveSupport is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LiveSupport is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LiveSupport; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# Author : $Author: tomas $ +# Version : $Revision: 1.1 $ +# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/bin/setupDirs.sh,v $ +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# This script does httpd writeable directories setup +#------------------------------------------------------------------------------- + +WWW_ROOT=`cd var/install; php -q getWwwRoot.php` || exit $? +echo "# archiveServer root URL: $WWW_ROOT" + +HTTP_GROUP=`bin/getUrl.sh $WWW_ROOT/install/getGname.php` || \ + { + ERN=$?; + echo $HTTP_GROUP; + echo " -> Probably wrong setting in var/conf.php: URL configuration"; + exit $ERN; + } +echo "# group running http daemon: $HTTP_GROUP" + +for i in $* +do + echo "mkdir $i" + mkdir -p $i || exit $? + chown :$HTTP_GROUP $i || \ + { + ERN=$?; + echo " -> You should have permissions to set group owner to group $HTTP_GROUP"; + exit $ERN; + } + chmod g+sw $i || exit $? +done + +echo "# Directories setup finished OK" +exit 0 diff --git a/livesupport/modules/archiveServer/doc/INSTALL b/livesupport/modules/archiveServer/doc/INSTALL index 533e45d0f..1b6340921 100644 --- a/livesupport/modules/archiveServer/doc/INSTALL +++ b/livesupport/modules/archiveServer/doc/INSTALL @@ -5,7 +5,7 @@ Install steps for file uploading (do it with appropriate changes): 2) move put.cgi there from var subdir 3) add to apache2 config (i.g. commonapache2.conf): - + Script PUT /cgi-bin-put/put.cgi ScriptAlias /cgi-bin-put/ "/usr/local/apache2/cgi-bin-put/" @@ -31,5 +31,9 @@ For running archiveServer on different HW then storageServer: - check if include_path in php.ini points to PEAR too (/usr/lib/php or /usr/local/lib/php) - setup var/conf.php - at least "basic configuration" part + - create symlink with name corresponding to "URL configuration" part + of var/conf.php file - example for default values: + http://localhost:80/livesupportArchiveServer/ should point to + /modules/archiveServer/var directory - run 'make check' to: setup directories, create db tables and run test scripts OR 'make all' without tests diff --git a/livesupport/modules/archiveServer/var/conf.php b/livesupport/modules/archiveServer/var/conf.php index f01ca893f..5acf88527 100644 --- a/livesupport/modules/archiveServer/var/conf.php +++ b/livesupport/modules/archiveServer/var/conf.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/var/conf.php,v $ ------------------------------------------------------------------------------*/ @@ -65,12 +65,12 @@ $config = array( /* ==================================================== URL configuration */ // on central archive side: storage=archive ! - 'storageUrlPath' => '/livesupport/modules/archiveServer/var', + 'storageUrlPath' => '/livesupportArchiveServer', 'storageXMLRPC' => 'xmlrpc/xrArchive.php', 'storageUrlHost' => 'localhost', 'storageUrlPort' => 80, // only for returning right URLs: - 'archiveUrlPath' => '/livesupport/modules/archiveServer/var', + 'archiveUrlPath' => '/livesupportArchiveServer', 'archiveXMLRPC' => 'xmlrpc/xrArchive.php', 'archiveUrlHost' => 'localhost', 'archiveUrlPort' => 80, diff --git a/livesupport/modules/archiveServer/var/install/getGname.php b/livesupport/modules/archiveServer/var/install/getGname.php new file mode 100644 index 000000000..d7d51d50e --- /dev/null +++ b/livesupport/modules/archiveServer/var/install/getGname.php @@ -0,0 +1,39 @@ + \ No newline at end of file diff --git a/livesupport/modules/archiveServer/var/install/getWwwRoot.php b/livesupport/modules/archiveServer/var/install/getWwwRoot.php new file mode 100644 index 000000000..0d7262026 --- /dev/null +++ b/livesupport/modules/archiveServer/var/install/getWwwRoot.php @@ -0,0 +1,39 @@ + \ No newline at end of file diff --git a/livesupport/modules/archiveServer/var/install/getXrUrl.php b/livesupport/modules/archiveServer/var/install/getXrUrl.php new file mode 100644 index 000000000..c819f4bbf --- /dev/null +++ b/livesupport/modules/archiveServer/var/install/getXrUrl.php @@ -0,0 +1,39 @@ + \ No newline at end of file diff --git a/livesupport/modules/archiveServer/var/install/install.php b/livesupport/modules/archiveServer/var/install/install.php index 6e29c9be6..f459a4e1c 100644 --- a/livesupport/modules/archiveServer/var/install/install.php +++ b/livesupport/modules/archiveServer/var/install/install.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/var/install/install.php,v $ ------------------------------------------------------------------------------*/ @@ -36,51 +36,53 @@ function errCallback($err) if(assert_options(ASSERT_ACTIVE)==1) return; echo "ERROR:\n"; echo "request: "; print_r($_REQUEST); - echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo()."\nui:\n".$err->getUserInfo()."\n\n"; - exit; + echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo(). + "\nui:\n".$err->getUserInfo()."\n\n"; + exit(1); } - PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s
\n"); $dbc = DB::connect($config['dsn'], TRUE); if(PEAR::isError($dbc)){ echo "Database connection problem.\n"; - echo "Check if database '{$config['dsn']['database']}' exists with corresponding permissions.\n"; - echo "Database access is defined by 'dsn' values in conf.php.\n"; - exit; + echo "Check if database '{$config['dsn']['database']}' exists". + " with corresponding permissions.\n"; + echo "Database access is defined by 'dsn' values in var/conf.php.\n"; + exit(1); } $dbc->setFetchMode(DB_FETCHMODE_ASSOC); $gb = &new GreenBox(&$dbc, $config); -echo "Archive: Install ...\n"; +echo "\n# archiveServer: Install ...\n"; $dbc->setErrorHandling(PEAR_ERROR_RETURN); $gb->uninstall(); PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s
\n"); $gb->install(); -echo " Testing ...\n"; +echo "# Testing ...\n"; $gb->test(); $log = $gb->test_log; -echo " TESTS:\n$log\n---\n"; +echo " TESTS:\n{$log}"; -#echo " Reinstall + testdata insert ...\n"; +#echo "# Reinstall + testdata insert ...\n"; #$gb->reinstall(); #$gb->sessid = $gb->login('root', $gb->config['tmpRootPass']); #$gb->testData(); #$gb->logout($gb->sessid); unset($gb->sessid); -echo " TREE DUMP:\n"; -echo $gb->dumpTree(); +#echo "# TREE DUMP:\n"; +#echo $gb->dumpTree(); -echo " Delete test data ...\n"; +echo "# Delete test data ...\n"; $gb->deleteData(); if(!($fp = @fopen($config['storageDir']."/_writeTest", 'w'))) - echo "\n!!! make {$config['storageDir']} dir webdaemon-writeable !!!\nand run install again\n\n"; + echo "\nmake {$config['storageDir']} dir webdaemon-writeable". + "\nand run install again\n\n"; else{ fclose($fp); unlink($config['storageDir']."/_writeTest"); - echo "\nArchive is probably installed OK\n"; + echo "#archiveServer install: OK\n\n"; } $dbc->disconnect(); diff --git a/livesupport/modules/archiveServer/var/install/uninstall.php b/livesupport/modules/archiveServer/var/install/uninstall.php index 30abf5257..9b7ebdca0 100644 --- a/livesupport/modules/archiveServer/var/install/uninstall.php +++ b/livesupport/modules/archiveServer/var/install/uninstall.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/var/install/uninstall.php,v $ ------------------------------------------------------------------------------*/ @@ -36,8 +36,9 @@ function errCallback($err) if(assert_options(ASSERT_ACTIVE)==1) return; echo "ERROR:\n"; echo "request: "; print_r($_REQUEST); - echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo()."\nui:\n".$err->getUserInfo()."\n\n"; - exit; + echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo(). + "\nui:\n".$err->getUserInfo()."\n\n"; + exit(1); } @@ -45,16 +46,17 @@ PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s
\n"); $dbc = DB::connect($config['dsn'], TRUE); if(PEAR::isError($dbc)){ echo "Database connection problem.\n"; - echo "Check if database '{$config['dsn']['database']}' exists with corresponding permissions.\n"; + echo "Check if database '{$config['dsn']['database']}' exists". + " with corresponding permissions.\n"; echo "Database access is defined by 'dsn' values in conf.php.\n"; - exit; + exit(1); } $dbc->setFetchMode(DB_FETCHMODE_ASSOC); $gb = &new GreenBox(&$dbc, $config); # $dbc->setErrorHandling(PEAR_ERROR_RETURN); -echo "Trying to uninstall Archive ...\n"; +echo "# Trying to uninstall archiveServer ...\n"; $gb->uninstall(); $dbc->disconnect(); diff --git a/livesupport/modules/archiveServer/var/xmlrpc/testRunner.sh b/livesupport/modules/archiveServer/var/xmlrpc/testRunner.sh index 0096289fc..4b16100fa 100755 --- a/livesupport/modules/archiveServer/var/xmlrpc/testRunner.sh +++ b/livesupport/modules/archiveServer/var/xmlrpc/testRunner.sh @@ -23,7 +23,7 @@ # # # Author : $Author: tomas $ -# Version : $Revision: 1.1 $ +# Version : $Revision: 1.2 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/archiveServer/var/xmlrpc/testRunner.sh,v $ #------------------------------------------------------------------------------- @@ -31,8 +31,8 @@ COMM=$1 shift GUNID=$1 -XMLRPC=http://localhost:80/livesupport/modules/archiveServer/var/xmlrpc/xrArchive.php -echo "XMLRPC server URL (check it in troubles):" +XMLRPC=`cd var/install; php -q getXrUrl.php` || exit $? +echo " archiveServer XMLRPC URL:" echo $XMLRPC TESTDIR=`dirname $0` diff --git a/livesupport/modules/storageServer/Makefile b/livesupport/modules/storageServer/Makefile index bbbdeb2d9..015ccebad 100644 --- a/livesupport/modules/storageServer/Makefile +++ b/livesupport/modules/storageServer/Makefile @@ -20,7 +20,7 @@ # # # Author : $Author: tomas $ -# Version : $Revision: 1.4 $ +# Version : $Revision: 1.5 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/Attic/Makefile,v $ # # @configure_input@ @@ -62,17 +62,13 @@ USR_LIB_DIR = ${USR_DIR}/lib DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config -GET_GNAME = install/getGname.php -WWW_ROOT := $(shell cd var/install; php -q getWwwRoot.php) -HTTP_GROUP := $(shell curl -s ${WWW_ROOT}/${GET_GNAME}) - -PHP_DIR = ${BASE_DIR}/var -INSTALL_DIR = ${PHP_DIR}/install -STOR_DIR = ${PHP_DIR}/stor -ACCESS_DIR = ${PHP_DIR}/access -TRANS_DIR = ${PHP_DIR}/trans -BUFF_DIR = ${STOR_DIR}/buffer -TEST_RUNNER = ${PHP_DIR}/xmlrpc/testRunner.sh +PHP_DIR = ${BASE_DIR}/var +INSTALL_DIR = ${PHP_DIR}/install +STOR_DIR = ${PHP_DIR}/stor +ACCESS_DIR = ${PHP_DIR}/access +TRANS_DIR = ${PHP_DIR}/trans +BUFF_DIR = ${STOR_DIR}/buffer +TEST_RUNNER = ${PHP_DIR}/xmlrpc/testRunner.sh #------------------------------------------------------------------------------- # Configuration parameters @@ -97,9 +93,10 @@ TEST_RUNNER = ${PHP_DIR}/xmlrpc/testRunner.sh db_init db_clean transtest all: dir_setup db_init - $(MAKE) -C ../archiveServer all +# $(MAKE) -C ../archiveServer all -dir_setup: ${DOXYGEN_DIR} ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR} +dir_setup: ${DOXYGEN_DIR} + bin/setupDirs.sh ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR} ${BUFF_DIR} doc: ${DOXYGEN} ${DOXYGEN_CONFIG} @@ -113,7 +110,7 @@ docclean: ${RMDIR} ${DOXYGEN_DIR}/html depclean: clean - $(MAKE) -C ../archiveServer clean +# $(MAKE) -C ../archiveServer clean dist: ${TAR_C} ${MODULE_NAME}${DATE}${DIST_EXT} * @@ -122,19 +119,15 @@ distclean: clean docclean check: all ${TEST_RUNNER} ${TEST_RUNNER} - $(MAKE) transtest +# $(MAKE) transtest #------------------------------------------------------------------------------- # Specific targets #------------------------------------------------------------------------------- transtest: - @echo "Transfer module test (needs ArchiveServer installed):" cd var/tests; php -q transTest.php db_init: - @echo "Settings:" - @echo "Http daemon group: ${HTTP_GROUP}" - @echo "WWW root: ${WWW_ROOT}" cd var/install; php -q install.php db_clean: @@ -146,29 +139,11 @@ ${TMP_DIR}: ${DOXYGEN_DIR}: ${MKDIR} ${DOXYGEN_DIR} -${STOR_DIR}: - @echo "Http daemon group: ${HTTP_GROUP}" - @echo "You should be in this group for easy testing" - ${MKDIR} ${STOR_DIR} - chown .${HTTP_GROUP} ${STOR_DIR} - chmod g+ws ${STOR_DIR} - -${ACCESS_DIR}: - ${MKDIR} ${ACCESS_DIR} - chown .${HTTP_GROUP} ${ACCESS_DIR} - chmod g+ws ${ACCESS_DIR} - -${TRANS_DIR}: - ${MKDIR} ${TRANS_DIR} - chown .${HTTP_GROUP} ${TRANS_DIR} - chmod g+ws ${TRANS_DIR} - -${BUFF_DIR}: - ${MKDIR} ${BUFF_DIR} - chmod g+w ${BUFF_DIR} - ${TEST_RUNNER}: +testonly: ${TEST_RUNNER} + ${TEST_RUNNER} + #------------------------------------------------------------------------------- # Pattern rules #------------------------------------------------------------------------------- diff --git a/livesupport/modules/storageServer/bin/getUrl.sh b/livesupport/modules/storageServer/bin/getUrl.sh new file mode 100755 index 000000000..be5010839 --- /dev/null +++ b/livesupport/modules/storageServer/bin/getUrl.sh @@ -0,0 +1,44 @@ +#!/bin/bash +#------------------------------------------------------------------------------- +# Copyright (c) 2004 Media Development Loan Fund +# +# This file is part of the LiveSupport project. +# http://livesupport.campware.org/ +# To report bugs, send an e-mail to bugs@campware.org +# +# LiveSupport is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LiveSupport is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LiveSupport; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# Author : $Author: tomas $ +# Version : $Revision: 1.1 $ +# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/bin/getUrl.sh,v $ +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# This script grabs string at suplied URL +#------------------------------------------------------------------------------- + +URL=$1 +RES=`curl -sf ${URL}` || \ + { + ERN=$?; + if [ $ERN == 22 ] ; then + echo "ERROR: curl: 22 - wrong URL ($URL)"; + else + echo "ERROR: $ERN - unknown"; + fi; + exit 1; + } +echo $RES diff --git a/livesupport/modules/storageServer/bin/setupDirs.sh b/livesupport/modules/storageServer/bin/setupDirs.sh new file mode 100755 index 000000000..c86a838ce --- /dev/null +++ b/livesupport/modules/storageServer/bin/setupDirs.sh @@ -0,0 +1,59 @@ +#!/bin/bash +#------------------------------------------------------------------------------- +# Copyright (c) 2004 Media Development Loan Fund +# +# This file is part of the LiveSupport project. +# http://livesupport.campware.org/ +# To report bugs, send an e-mail to bugs@campware.org +# +# LiveSupport is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LiveSupport is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LiveSupport; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# +# Author : $Author: tomas $ +# Version : $Revision: 1.1 $ +# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/bin/setupDirs.sh,v $ +#------------------------------------------------------------------------------- + +#------------------------------------------------------------------------------- +# This script does httpd writeable directories setup +#------------------------------------------------------------------------------- + +WWW_ROOT=`cd var/install; php -q getWwwRoot.php` || exit $? +echo "# storageServer root URL: $WWW_ROOT" + +HTTP_GROUP=`bin/getUrl.sh $WWW_ROOT/install/getGname.php` || \ + { + ERN=$?; + echo $HTTP_GROUP; + echo " -> Probably wrong setting in var/conf.php: URL configuration"; + exit $ERN; + } +echo "# group running http daemon: $HTTP_GROUP" + +for i in $* +do + echo "mkdir $i" + mkdir -p $i || exit $? + chown :$HTTP_GROUP $i || \ + { + ERN=$?; + echo " -> You should have permissions to set group owner to group $HTTP_GROUP"; + exit $ERN; + } + chmod g+sw $i || exit $? +done + +echo "# Directories setup finished OK" +exit 0 diff --git a/livesupport/modules/storageServer/doc/INSTALL b/livesupport/modules/storageServer/doc/INSTALL index 4c4853096..6ea527ab3 100644 --- a/livesupport/modules/storageServer/doc/INSTALL +++ b/livesupport/modules/storageServer/doc/INSTALL @@ -6,6 +6,10 @@ - setup var/conf.php - at least "basic configuration" part (follow comments in the source - or use doxygen and its output) - setup archiveServer/var/conf.php too - test scripts will use archive +- create symlink with name corresponding to "URL configuration" part + of var/conf.php file - example for default values: + http://localhost:80/livesupportStorageServer/ should point to + /modules/storageServer/var directory - configure apache for archiveServer file upload (as described in archiveServer/doc/INSTALL) - run 'make check' to: setup directories, create db tables and run test scripts diff --git a/livesupport/modules/storageServer/var/GreenBox.php b/livesupport/modules/storageServer/var/GreenBox.php index ebc3da60b..da3e7d1cc 100644 --- a/livesupport/modules/storageServer/var/GreenBox.php +++ b/livesupport/modules/storageServer/var/GreenBox.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $ ------------------------------------------------------------------------------*/ @@ -48,7 +48,7 @@ require_once "Transport.php"; * LiveSupport file storage module * * @author $Author: tomas $ - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ * @see Alib */ class GreenBox extends Alib{ @@ -717,7 +717,7 @@ class GreenBox extends Alib{ $ac =& StoredFile::recallFromLink(&$this, $acf['tmplink'], $sessid); $ac->releaseRawMediaData($sessid); } - parent::logout($sessid); + return parent::logout($sessid); } /** @@ -1000,7 +1000,7 @@ class GreenBox extends Alib{ "; $this->test_dump = $this->dumpTree($this->storId); if($this->test_dump==$this->test_correct) - { $this->test_log.="Storage: OK\n"; return true; } + { $this->test_log.="storageServer: OK\n"; return true; } else PEAR::raiseError('GreenBox::test:', 1, PEAR_ERROR_DIE, '%s'. "
\ncorrect:\n.{$this->test_correct}.\n".
             "dump:\n.{$this->test_dump}.\n
\n"); diff --git a/livesupport/modules/storageServer/var/conf.php b/livesupport/modules/storageServer/var/conf.php index 8e0e77f9a..cae94405d 100644 --- a/livesupport/modules/storageServer/var/conf.php +++ b/livesupport/modules/storageServer/var/conf.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/conf.php,v $ ------------------------------------------------------------------------------*/ @@ -63,13 +63,13 @@ $config = array( 'accessDir' => dirname(getcwd()).'/access', /* ==================================================== URL configuration */ - 'storageUrlPath' => '/livesupport/modules/storageServer/var', + 'storageUrlPath' => '/livesupportStorageServer', 'storageXMLRPC' => 'xmlrpc/xrLocStor.php', 'storageUrlHost' => 'localhost', 'storageUrlPort' => 80, /* ================================================ archive configuration */ - 'archiveUrlPath' => '/livesupport/modules/archiveServer/var', + 'archiveUrlPath' => '/livesupportArchiveServer', 'archiveXMLRPC' => 'xmlrpc/xrArchive.php', 'archiveUrlHost' => 'localhost', 'archiveUrlPort' => 80, diff --git a/livesupport/modules/storageServer/var/install/getGname.php b/livesupport/modules/storageServer/var/install/getGname.php index 0136b40c2..821ee2604 100644 --- a/livesupport/modules/storageServer/var/install/getGname.php +++ b/livesupport/modules/storageServer/var/install/getGname.php @@ -1,6 +1,38 @@ -getMessage()."\ndi:\n".$err->getDebugInfo()."\nui:\n".$err->getUserInfo()."\n\n"; - exit; + echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo(). + "\nui:\n".$err->getUserInfo()."\n\n"; + exit(1); } - PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s
\n"); $dbc = DB::connect($config['dsn'], TRUE); if(PEAR::isError($dbc)){ echo "Database connection problem.\n"; - echo "Check if database '{$config['dsn']['database']}' exists with corresponding permissions.\n"; - echo "Database access is defined by 'dsn' values in conf.php.\n"; - exit; + echo "Check if database '{$config['dsn']['database']}' exists". + " with corresponding permissions.\n"; + echo "Database access is defined by 'dsn' values in var/conf.php.\n"; + exit(1); } $dbc->setFetchMode(DB_FETCHMODE_ASSOC); $gb = &new GreenBox(&$dbc, $config); -echo "Storage: Install ...\n"; +echo "\n# storageServer: Install ...\n"; $dbc->setErrorHandling(PEAR_ERROR_RETURN); $gb->uninstall(); PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s
\n"); $gb->install(); -echo " Testing ...\n"; +echo "# Testing ...\n"; $gb->test(); $log = $gb->test_log; -echo " TESTS:\n$log\n---\n"; +echo " TESTS:\n{$log}"; -#echo " Reinstall + testdata insert ...\n"; +#echo "# Reinstall + testdata insert ...\n"; #$gb->reinstall(); #$gb->sessid = $gb->login('root', $gb->config['tmpRootPass']); #$gb->testData(); #$gb->logout($gb->sessid); unset($gb->sessid); -echo " TREE DUMP:\n"; -echo $gb->dumpTree(); +#echo "# TREE DUMP:\n"; +#echo $gb->dumpTree(); -echo " Delete test data ...\n"; +echo "# Delete test data ...\n"; $gb->deleteData(); if(!($fp = @fopen($config['storageDir']."/_writeTest", 'w'))) - echo "\n!!! make {$config['storageDir']} dir webdaemon-writeable !!!\nand run install again\n\n"; + echo "\nmake {$config['storageDir']} dir webdaemon-writeable". + "\nand run install again\n\n"; else{ fclose($fp); unlink($config['storageDir']."/_writeTest"); - echo "\nStorage is probably installed OK\n"; + echo "#storageServer install: OK\n\n"; } -echo "Install Transport submodule ...\n"; +echo "# Install Transport submodule\n"; require_once "../Transport.php"; $tr =& new Transport(&$dbc, $config); $r = $tr->install(); +echo "\n"; $dbc->disconnect(); ?> diff --git a/livesupport/modules/storageServer/var/install/uninstall.php b/livesupport/modules/storageServer/var/install/uninstall.php index c1ee35959..ca46bd035 100644 --- a/livesupport/modules/storageServer/var/install/uninstall.php +++ b/livesupport/modules/storageServer/var/install/uninstall.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/install/uninstall.php,v $ ------------------------------------------------------------------------------*/ @@ -36,8 +36,9 @@ function errCallback($err) if(assert_options(ASSERT_ACTIVE)==1) return; echo "ERROR:\n"; echo "request: "; print_r($_REQUEST); - echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo()."\nui:\n".$err->getUserInfo()."\n\n"; - exit; + echo "gm:\n".$err->getMessage()."\ndi:\n".$err->getDebugInfo(). + "\nui:\n".$err->getUserInfo()."\n\n"; + exit(1); } @@ -45,19 +46,20 @@ PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s
\n"); $dbc = DB::connect($config['dsn'], TRUE); if(PEAR::isError($dbc)){ echo "Database connection problem.\n"; - echo "Check if database '{$config['dsn']['database']}' exists with corresponding permissions.\n"; + echo "Check if database '{$config['dsn']['database']}' exists". + " with corresponding permissions.\n"; echo "Database access is defined by 'dsn' values in conf.php.\n"; - exit; + exit(1); } $dbc->setFetchMode(DB_FETCHMODE_ASSOC); $gb = &new GreenBox(&$dbc, $config); # $dbc->setErrorHandling(PEAR_ERROR_RETURN); -echo "Trying to uninstall storageServer ...\n"; +echo "# Trying to uninstall storageServer ...\n"; $gb->uninstall(); -echo "Uninstall Tranport submodule ...\n"; +echo "# Uninstall Tranport submodule ...\n"; require_once "../Transport.php"; $tr =& new Transport(&$dbc, $config); $r = $tr->uninstall(); diff --git a/livesupport/modules/storageServer/var/tests/transTest.php b/livesupport/modules/storageServer/var/tests/transTest.php index a0aa18627..d36619660 100644 --- a/livesupport/modules/storageServer/var/tests/transTest.php +++ b/livesupport/modules/storageServer/var/tests/transTest.php @@ -1,6 +1,34 @@ -login('root', 'q'))."\n"; +echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n"; -echo"Store:\n"; -$r = $gb->storeAudioClip($sessid, $gunid, $mediaFile, $mdataFile); var_dump($r); +echo"# Store: "; +$r = $gb->storeAudioClip($sessid, $gunid, $mediaFile, $mdataFile); +if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); } +echo "$r\n"; -echo"Upload:\n"; $r = $gb->uploadFile('', $gunid, $sessid); var_dump($r); +echo"# Upload: "; $r = $gb->uploadFile('', $gunid, $sessid); +if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); } +echo join(', ',$r)."\n"; -echo"Cron:\n"; $r = $gb->cronJob(); var_dump($r); +echo"# Cron: "; list($r1, $r2) = $gb->cronJob(); +if(PEAR::isError($r1)){ echo "ERROR: ".$r1->getMessage()."\n"; exit(1); } +if(PEAR::isError($r2)){ echo "ERROR: ".$r2->getMessage()."\n"; exit(1); } +echo "$r1, $r2\n"; -echo"Delete:\n"; $r = $gb->deleteAudioClip($sessid, $gunid); var_dump($r); +echo"# Delete: "; $r = $gb->deleteAudioClip($sessid, $gunid); +if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); } +echo "$r\n"; -echo"Download:\n"; $r = $gb->downloadFile($gunid, $sessid); var_dump($r); +echo"# Download: "; $r = $gb->downloadFile($gunid, $sessid); +if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); } +echo join(', ',$r)."\n"; -echo"Cron:\n"; $r = $gb->cronJob(); var_dump($r); +echo"# Cron: "; $r = $gb->cronJob(); +if(PEAR::isError($r1)){ echo "ERROR: ".$r1->getMessage()."\n"; exit(1); } +if(PEAR::isError($r2)){ echo "ERROR: ".$r2->getMessage()."\n"; exit(1); } +echo "$r1, $r2\n"; -echo"logout: ".($r = $gb->logout($sessid))."\n"; +echo"# logout: "; $r = $gb->logout($sessid); +if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); } +echo "$r\n"; -echo"\n"; +echo "#Transport test: OK.\n\n" ?> \ No newline at end of file diff --git a/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh b/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh index 2b4cc1262..efbdc6ccf 100755 --- a/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh +++ b/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh @@ -23,7 +23,7 @@ # # # Author : $Author: tomas $ -# Version : $Revision: 1.4 $ +# Version : $Revision: 1.5 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh,v $ #------------------------------------------------------------------------------- @@ -31,74 +31,73 @@ COMM=$1 shift GUNID=$1 -#XMLRPC=http://localhost:80/livesupport/modules/storageServer/var/xmlrpc/xrLocStor.php -XMLRPC=`cd var/install; php -q getXrUrl.php` -echo "XMLRPC server URL (check it in troubles):" -echo $XMLRPC +echo "" +XMLRPC=`cd var/install; php -q getXrUrl.php` || exit $? +echo "# storageServer XMLRPC URL: $XMLRPC" TESTDIR=`dirname $0` -XR_CLI="$TESTDIR/xr_cli_test.py -s $XMLRPC" +XR_CLI="$TESTDIR/xr_cli_test.py -s ${XMLRPC}" login() { - echo "login:" - SESSID=`$XR_CLI login root q` + echo -n "# login: " + SESSID=`$XR_CLI login root q` || exit $? echo "sessid: $SESSID" } test() { - echo "test:" - $XR_CLI test $SESSID stringForUppercase + echo "# test: " + $XR_CLI test $SESSID stringForUppercase || exit $? } existsAudioClip() { - echo "existsAudioClip:" - $XR_CLI existsAudioClip $SESSID $GUNID + echo "# existsAudioClip: " + $XR_CLI existsAudioClip $SESSID $GUNID || exit $? } accessRawAudioData() { - echo "accessRawAudioData:" - FPATH=`$XR_CLI accessRawAudioData $SESSID $GUNID` + echo "# accessRawAudioData: " + FPATH=`$XR_CLI accessRawAudioData $SESSID $GUNID` || exit $? FPATH="" FPATH=`echo "$FPATH" | php -q` echo $FPATH - ls -l $FPATH - echo "releaseRawAudioData:" - $XR_CLI releaseRawAudioData $SESSID $FPATH +# ls -l $FPATH + echo -n "# releaseRawAudioData: " + $XR_CLI releaseRawAudioData $SESSID $FPATH || exit $? #$XR_CLI getAudioClip $SESSID $GUNID } storeAudioClip() { - echo "storeAudioClip:" + echo -n "# storeAudioClip: " MEDIA=../tests/ex1.mp3 METADATA=../tests/testStorage.xml - RGUNID=`$XR_CLI storeAudioClip "$SESSID" '' "$MEDIA" "$METADATA"` + RGUNID=`$XR_CLI storeAudioClip "$SESSID" '' "$MEDIA" "$METADATA"` || exit $? echo $RGUNID } deleteAudioClip() { - echo "deleteAudioClip:" - $XR_CLI deleteAudioClip $SESSID $GUNID + echo -n "# deleteAudioClip: " + $XR_CLI deleteAudioClip $SESSID $GUNID || exit $? } updateAudioClipMetadata() { - echo "updateAudioClipMetadata:" - $XR_CLI updateAudioClipMetadata $SESSID $GUNID '../tests/mdata3.xml' + echo -n "#updateAudioClipMetadata: " + $XR_CLI updateAudioClipMetadata $SESSID $GUNID '../tests/mdata3.xml' || exit $? } getAudioClip() { - echo "getAudioClip:" - $XR_CLI getAudioClip $SESSID $GUNID | $TESTDIR/urldecode + echo -n "#getAudioClip: " + $XR_CLI getAudioClip $SESSID $GUNID | $TESTDIR/urldecode || exit $? } searchMetadata() { - echo "searchMetadata:" -# $XR_CLI searchMetadata $SESSID '../tests/srch_cri1.xml' - $XR_CLI searchMetadata $SESSID 'John %' + echo -n "# searchMetadata: " +# $XR_CLI searchMetadata $SESSID '../tests/srch_cri1.xml' || exit $? + $XR_CLI searchMetadata $SESSID 'John %' || exit $? } logout() { - echo "logout:" - $XR_CLI logout $SESSID + echo -n "# logout: " + $XR_CLI logout $SESSID || exit $? } usage(){ @@ -147,6 +146,8 @@ elif [ "x$COMM" == "x" ]; then accessRawAudioData deleteAudioClip logout + echo "#XMLRPC tests: OK." + echo "" elif [ "$COMM" == "help" ]; then usage else