Changeset 27829 for main


Ignore:
Timestamp:
07/12/13 17:22:47 (8 years ago)
Author:
davidb
Message:

Additional work to help support Greenstone running off a read-only medium, such as a DVD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/build.xml

    r27788 r27829  
    101101  <property name="build.home" value="${basedir}/build"/>
    102102  <property name="src.home" value="${basedir}/src/java"/>
    103   <property name="packages.home" value="${basedir}/packages"/>
    104   <!-- this may be set in build.properties, eg if you move the web dir to
    105   tomcats webapps directory -->
     103
     104  <if><bool><istrue value="${gsdl3home.isreadonly}"/></bool>
     105    <property name="readonly-packages.home" value="${basedir}/packages"/>
     106    <property name="packages.home" value="${gsdl3.writablehome}/packages"/>
     107  <else>
     108    <property name="packages.home" value="${basedir}/packages"/>
     109  </else>
     110  </if>
     111
     112  <!-- this may be set in build.properties, e.g. if you move the web dir to
     113       tomcats webapps directory -->
    106114  <property name="web.home" value="${basedir}/web"/>
     115  <property name="web.writablehome" value="${gsdl3.writablehome}"/>
     116
    107117  <!-- jar files needed by applets go here -->
    108118  <property name="web.applet" value="${web.home}/applet"/>
     
    110120  <!-- jar files needed by the servlet (and extra ones) go here -->
    111121  <property name="web.lib" value="${web.home}/WEB-INF/lib"/>
     122  <property name="web.writablelib" value="${web.writablehome}/WEB-INF/lib"/>
    112123  <!-- other files needed by the servlet go here -->
    113124  <property name="web.classes" value="${web.home}/WEB-INF/classes"/>
     125  <property name="web.writableclasses" value="${web.writablehome}/WEB-INF/classes"/>
     126
     127  <if>
     128    <bool><istrue value="${gsdl3home.isreadonly}"/></bool>
     129    <echo>Greenstone3 home directory is read-only</echo>
     130    <echo>  => Writable area is: ${gsdl3.writablehome}</echo>
     131
     132    <condition property="gsdl3.writablehome.already-exists">
     133      <available file="${gsdl3.writablehome}" type="dir"/>
     134    </condition>
     135
     136    <if>
     137      <bool><not><istrue value="${gsdl3.writablehome.already-exists}"/></not></bool>
     138
     139      <!-- set up writable area -->
     140      <echo>No previous Greenstone home writable area detected</echo>
     141      <echo>  => Setting up area</echo>
     142      <mkdir dir="${gsdl3.writablehome}"/>
     143      <mkdir dir="${gsdl3.writablehome}/packages"/>
     144      <mkdir dir="${gsdl3.writablehome}/logs"/>
     145
     146      <chmod perm="a+rwx" dir="${gsdl3.writablehome}"/>
     147      <chmod perm="a+rwx" dir="${gsdl3.writablehome}/packages"/>
     148      <chmod perm="a+rwx" dir="${gsdl3.writablehome}/logs"/>
     149
     150      <!-- copy over packages tomcat folder -->
     151
     152      <if>
     153    <bool><equals arg1="${os.bin.dir}" arg2="windows"/></bool>
     154    <copy todir="${gsdl3.writablehome}/packages/tomcat"
     155          preservelastmodified="true"
     156          failonerror="true" > 
     157      <fileset dir="${readonly-packages.home}/tomcat" includes="**"/> 
     158    </copy>
     159     
     160    <else>
     161      <!-- else assume Unix -->
     162      <!-- Can't go through the OS-independant <copy> task as it fails to preserve exec permissions -->
     163      <echo>Copying to ${gsdl3.writablehome}/packages/tomcat</echo>
     164      <exec executable="cp" output="/dev/null" spawn="false">
     165            <arg value="-r"/>
     166            <arg value="${readonly-packages.home}/tomcat"/>
     167            <arg value="${gsdl3.writablehome}/packages/."/>
     168      </exec>
     169     
     170    </else>
     171      </if>
     172     
     173      <echo>  => Copying Greenstone's web/WEB-INF to writable area</echo>
     174      <copy todir="${gsdl3.writablehome}/WEB-INF"
     175        preservelastmodified="true"
     176        failonerror="true" > 
     177    <fileset dir="${web.home}/WEB-INF" includes="**"/> 
     178      </copy>
     179
     180      <copy todir="${gsdl3.writablehome}"
     181        preservelastmodified="true"
     182        failonerror="true" > 
     183    <fileset dir="${web.home}" includes="index.html"/> 
     184      </copy>
     185
     186    </if>
     187  </if>
     188
     189
    114190  <!--- flax: the WordNet home -->
    115191  <property name="wn.home" value="${web.home}/WEB-INF/classes/flax/WordNet"/>
     
    128204   <property name="admin.dir"      value="${basedir}/admin"/>
    129205
    130   <!-- defaults - set these on the command line or in build.properties or they will take these default values-->
     206  <!-- defaults - set these on the command line or in build.properties or
     207       they will take these default values-->
    131208  <property name="app.version" value="trunk"/>
    132209  <property name="branch.path" value="trunk"/>
     
    137214
    138215  <!-- catalina home is set to tomcat basedir if already installed, otherwise
    139   use greenstone's tomcat -->
     216       use greenstone's tomcat -->
    140217  <condition property="catalina.home" value="${tomcat.installed.path}" else="${packages.home}/tomcat">
    141218    <and>
    142219      <isset property="tomcat.installed.path"/>
    143220      <not>
    144       <equals arg1="" arg2="${tomcat.installed.path}"/>
     221    <equals arg1="" arg2="${tomcat.installed.path}"/>
    145222      </not>
    146223    </and>
     
    501578    </fileset>
    502579   
    503     <pathelement location="${web.lib}"/>
    504     <fileset dir="${web.lib}">
     580    <pathelement location="${web.writablelib}"/>
     581    <fileset dir="${web.writablelib}">
    505582      <include name="derby.jar"/>
    506583    </fileset>
     
    706783
    707784  <target name="init-oaiconfig" if="oaiconfig.present">
    708     <echo>Writing out baseURL ${url}oaiserver to ${web.classes}/OAIConfig.xml</echo>
    709     <copy file="${web.classes}/OAIConfig.xml.in" tofile="${web.classes}/OAIConfig.xml"/>
    710     <rsr file="${web.classes}/OAIConfig.xml" pattern="&lt;baseURL&gt;.*&lt;/baseURL&gt;" replacement="&lt;baseURL&gt;${url}oaiserver&lt;/baseURL&gt;" />   
     785    <echo>Writing out baseURL ${url}oaiserver to ${web.writableclasses}/OAIConfig.xml</echo>
     786    <copy file="${web.classes}/OAIConfig.xml.in" tofile="${web.writableclasses}/OAIConfig.xml"/>
     787    <rsr file="${web.writableclasses}/OAIConfig.xml" pattern="&lt;baseURL&gt;.*&lt;/baseURL&gt;" replacement="&lt;baseURL&gt;${url}oaiserver&lt;/baseURL&gt;" />   
    711788  </target>
    712789
     
    715792 
    716793  <target name="restart" description="Shutdown and restart Tomcat"  depends="init,stop,start"/>
    717 
    718794
    719795  <!-- =========== Help targets ===================================  -->
     
    842918 
    843919  <target name="prepare-web" depends="init">
    844     <mkdir dir="${web.home}/applet"/>
    845     <mkdir dir="${web.home}/logs"/>
    846     <mkdir dir="${web.home}/logs/tmp"/>
     920    <mkdir dir="${web.writablehome}/applet"/>
     921    <mkdir dir="${web.writablehome}/logs"/>
     922    <mkdir dir="${web.writablehome}/logs/tmp"/>
    847923  </target>
    848924 
     
    9851061
    9861062      <!-- set the shebangs in the cgi files to point to the correct perlpath -->
    987       <rsr file="${web.home}/WEB-INF/cgi/gliserver.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
    988       <rsr file="${web.home}/WEB-INF/cgi/metadata-server.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
    989       <rsr file="${web.home}/WEB-INF/cgi/checksum.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>   
     1063      <if>
     1064    <bool><not><equals arg1="${web.home}" arg2="${web.writablehome}"></equals></not></bool>
     1065    <mkdir dir="${web.writablehome}"/>
     1066    <copy file="${web.home}/WEB-INF/cgi/gliserver.pl"       tofile="${web.writablehome}/WEB-INF/cgi/gliserver.pl"       overwrite="true"/>
     1067    <copy file="${web.home}/WEB-INF/cgi/metadata-server.pl" tofile="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" overwrite="true"/>
     1068    <copy file="${web.home}/WEB-INF/cgi/checksum.pl"        tofile="${web.writablehome}/WEB-INF/cgi/checksum.pl"        overwrite="true"/>
     1069      </if>
     1070
     1071      <rsr file="${web.writablehome}/WEB-INF/cgi/gliserver.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
     1072      <rsr file="${web.writablehome}/WEB-INF/cgi/metadata-server.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>
     1073      <rsr file="${web.writablehome}/WEB-INF/cgi/checksum.pl" pattern="^#!.*" replacement="#!${perl.exec} -w" lines="1"/>   
    9901074      <else>
    991     <echo>WARNING: perl.path is empty. Unable to set the shebangs in the perl files in ${web.home}/WEB-INF/cgi</echo>
     1075    <echo>WARNING: perl.path is empty. Unable to set the shebangs in the perl files in ${web.writablehome}/WEB-INF/cgi</echo>
    9921076      </else>
    9931077    </if>
     
    10001084      <path path="${web.home}"/>
    10011085    </pathconvert>
     1086    <pathconvert targetos="unix" property="src.gsdl3.writablehome.unix">
     1087      <path path="${web.writablehome}"/>
     1088    </pathconvert>
    10021089
    10031090    <antcall target="set-perl-shebangs" inheritAll="true" />
     
    10061093    <filter token="gsdl3srchome" value="${basedir}"/>
    10071094    <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
     1095    <filter token="gsdl3writablehome" value="${src.gsdl3.writablehome.unix}"/>
    10081096    <filter token="gsdl3version" value="${app.version}"/>
    10091097    <filter token="tomcat.server" value="${tomcat.server}"/>
     
    10111099    <filter token="perlpath" value="${escaped.perl.path}"/>
    10121100    <filter token="disable.collection.building" value="${disable.collection.building}"/>
    1013     <copy file="${web.home}/WEB-INF/cgi/gsdl3site.cfg.in" tofile="${web.home}/WEB-INF/cgi/gsdl3site.cfg" filtering="true" overwrite="true"/>
    1014     <copy file="${basedir}/resources/java/global.properties.in" tofile="${web.classes}/global.properties" filtering="true" overwrite="true"/>
    1015     <copy file="${basedir}/resources/java/log4j.properties.in" tofile="${web.classes}/log4j.properties" filtering="true" overwrite="true"/>
    1016     <chmod file="${web.classes}/global.properties" perm="600"/>
    1017     <chmod file="${web.classes}/log4j.properties" perm="600"/>
     1101    <copy file="${web.home}/WEB-INF/cgi/gsdl3site.cfg.in" tofile="${web.writablehome}/WEB-INF/cgi/gsdl3site.cfg" filtering="true" overwrite="true"/>
     1102
     1103    <copy file="${basedir}/resources/java/global.properties.in" tofile="${web.writableclasses}/global.properties" filtering="true" overwrite="true"/>
     1104    <copy file="${basedir}/resources/java/log4j.properties.in" tofile="${web.writableclasses}/log4j.properties" filtering="true" overwrite="true"/>
     1105    <if><bool><istrue value="${gsdl3home.isreadonly}"/></bool>
     1106      <!-- uncomment the writablehome properties -->
     1107      <rsr file="${web.writableclasses}/global.properties" pattern="^#gsdl3\.(writable{1})?home" replacement="gsdl3.$1home" />
     1108    </if>
     1109    <chmod file="${web.writableclasses}/global.properties" perm="644"/>
     1110    <chmod file="${web.writableclasses}/log4j.properties" perm="644"/>
    10181111  </target>
    10191112
     
    10601153    <exec executable="svn">
    10611154      <arg value="update"/>
    1062       <arg value="${web.home}"/>
     1155      <arg value="${web.writablehome}"/>
    10631156      <arg value="-r"/><arg value="${branch.revision}"/>
    10641157    </exec>
     
    11481241      <filterset>
    11491242        <filter token="gsdl3webhome" value="${web.home}"/>
     1243        <filter token="gsdl3webwritablehome" value="${web.writablehome}"/>
    11501244    <filter token="privilegedattribute" value ="${privileged.attribute}"/>
    11511245      </filterset>
     
    11831277    </if>
    11841278
    1185     <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
    1186     <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
     1279    <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
     1280    <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
    11871281   
    11881282    <exec executable="${catalina.home}/bin/catalina.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
     
    12251319 
    12261320
    1227 <!-- Another way: http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/ -->
     1321  <!-- Another way: http://ptrthomas.wordpress.com/2006/03/25/how-to-start-and-stop-tomcat-from-ant/ -->
    12281322  <target name="start-tomcat" description="Startup only Tomcat" depends="init" if="tomcat.islocal">
    12291323    <property name="tomcat.classpath" refid="local.tomcat.classpath"/>
     
    12381332    </if>
    12391333
    1240     <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
    1241     <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
     1334    <echo file="${catalina.home}/bin/setenv.bat">set CLASSPATH=${tomcat.classpath}</echo>
     1335    <echo file="${catalina.home}/bin/setenv.sh">export CLASSPATH=${tomcat.classpath}</echo>
    12421336   
    12431337    <exec executable="${catalina.home}/bin/startup.sh" os="${os.unix}" dir="${catalina.home}/bin" spawn="false">
     
    13731467    It seems to have a problem with cat or </dev/null, with or without the < sign. -->
    13741468  <target name="reset-logs" description="Empties catalina.out, greenstone.log and contents of web/logs/tmp">
    1375     <echo>Truncating catalina.out, greenstone.log and server.log, and emptying ${web.home}/logs/tmp</echo>   
     1469    <echo>Truncating catalina.out, greenstone.log and server.log, and emptying ${web.writablehome}/logs/tmp</echo>   
    13761470    <exec executable="rm" os="${os.unix}" dir="${catalina.home}/logs" spawn="false">
    13771471      <arg value="-f"/>
    13781472      <arg value="catalina.out"/>
    13791473    </exec>
    1380     <exec executable="rm" os="${os.unix}" dir="${web.home}/logs" spawn="false">
     1474    <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
    13811475      <arg value="-f"/>
    13821476      <arg value="greenstone.log"/>
    13831477    </exec>
    1384     <exec executable="rm" os="${os.unix}" dir="${web.home}/logs" spawn="false">
     1478    <exec executable="rm" os="${os.unix}" dir="${web.writablehome}/logs" spawn="false">
    13851479      <arg value="-f"/>
    13861480      <arg value="server.log"/>
     
    13911485      <arg value="catalina.out"/>
    13921486    </exec>
    1393     <exec executable="touch" os="${os.unix}" dir="${web.home}/logs"
     1487    <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
    13941488      spawn="false">
    13951489      <arg value="greenstone.log"/>
    13961490    </exec>
    1397     <exec executable="touch" os="${os.unix}" dir="${web.home}/logs"
     1491    <exec executable="touch" os="${os.unix}" dir="${web.writablehome}/logs"
    13981492      spawn="false">
    13991493      <arg value="server.log"/>
     
    14031497      <arg line="/c echo. > catalina.out"/>
    14041498    </exec>
    1405     <exec executable="cmd" os="${os.windows}" dir="${web.home}/logs" spawn="false">
     1499    <exec executable="cmd" os="${os.windows}" dir="${web.writablehome}/logs" spawn="false">
    14061500      <arg line="/c echo. > greenstone.log"/>
    14071501    </exec>
    1408     <exec executable="cmd" os="${os.windows}" dir="${web.home}/logs" spawn="false">
     1502    <exec executable="cmd" os="${os.windows}" dir="${web.writablehome}/logs" spawn="false">
    14091503      <arg line="/c echo. > server.log"/>
    14101504    </exec>
    14111505
    14121506    <if>
    1413       <bool><available file="${web.home}/logs/tmp" type="dir"/></bool>
     1507      <bool><available file="${web.writablehome}/logs/tmp" type="dir"/></bool>
    14141508      <delete>
    1415     <fileset dir="${web.home}/logs/tmp" includes="**/*"/>
     1509    <fileset dir="${web.writablehome}/logs/tmp" includes="**/*"/>
    14161510      </delete>
    14171511    </if>
     
    27392833
    27402834    <!-- create empty directories -->
    2741     <mkdir dir="${web.home}/applet"/>
    2742     <mkdir dir="${web.home}/logs"/>
    2743     <mkdir dir="${web.home}/logs/tmp"/>
     2835    <mkdir dir="${web.writablehome}/applet"/>
     2836    <mkdir dir="${web.writablehome}/logs"/>
     2837    <mkdir dir="${web.writablehome}/logs/tmp"/>
    27442838
    27452839    <!-- os specific tidy-ups -->
Note: See TracChangeset for help on using the changeset viewer.