Changeset 30038

Show
Ignore:
Timestamp:
17.07.2015 17:45:54 (4 years ago)
Author:
ak19
Message:

Modified IPv4 scripts to take the parameter -format-for-tomcat-context if it needs to format the IPv4 address. If not passed this flag, it will return the IPv4 address unformatted. build.xml is now updated to pass this flag to the scripts.

Location:
main/trunk/greenstone3
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/bin/script/IPv4.bat

    r30037 r30038  
    11@echo off 
     2 
     3rem This script will echo the IPv4 of this windows machine. E.g. 100.200.300.45 
     4rem If passed -format-for-tomcat-context, it will echo the same with a pipe 
     5rem symbol up front and all the . escaped with a "\". E.g. "|100\.200\.300\.45" 
     6 
    27for /f "usebackq tokens=2 delims=:" %%a in (`ipconfig ^| find "IPv4"`) do (set result=%%a) 
    38 
    4 :: To lop off extra space in front of IPv4 number, end with: 
     9:: To lop off the single extra space in front of IPv4 number, end with: 
    510::do (set result=%a& echo %result:~1%) 
    611:: Alternative: for /f "tokens=2 delims=:" %a in ('ipconfig ^| findstr /C:"IPv4 Address"') do echo %a 
     
    1116 
    1217:: The above produces the IPv4 number, e.g. 100.200.300.45 
     18 
     19 
     20rem Check if we're requested to format the IPv4 for the solr.xml tomcat context file 
     21if [%1]==[] goto done 
     22if not "%1"=="-format-for-tomcat-context" goto done 
     23 
    1324:: Still need to replace . with \. 
    1425:: http://scripts.dragon-it.co.uk/scripts.nsf/docs/batch-search-replace-substitute!OpenDocument&ExpandSection=3&BaseTarget=East&AutoFramed 
     
    2536::set result=^|%result% 
    2637 
     38echo ^|%result% 
     39goto fin 
     40 
     41 
     42:done 
    2743:: Echo a vertical bar up front, regardless of whether the result is empty 
    28 echo ^|%result% 
     44echo %result% 
     45 
     46:fin 
  • main/trunk/greenstone3/bin/script/IPv4.sh

    r30037 r30038  
    11#!/bin/bash 
     2 
     3# This script will echo the IPv4 of this unix machine. E.g. 100.200.300.45 
     4# If passed -format-for-tomcat-context, it will echo the same with a pipe 
     5# symbol up front and all the . escaped with a "\". E.g. "|100\.200\.300\.45" 
    26 
    37#http://www.wikihow.com/Find-Your-IP-Address-on-a-Mac#Finding_Your_Internal_IP_Using_the_Terminal_sub 
     
    1115#echo `ifconfig | grep "inet " | grep -v 127.0.0.1`|cut -d' ' -f 2|cut -d':' -f 2 
    1216 
    13  
    1417tmp=`ifconfig | grep "inet " | grep -v 127.0.0.1` 
    1518 
    1619tmp=`echo $tmp|cut -d' ' -f 2|cut -d':' -f 2` 
    1720 
    18 #http://stackoverflow.com/questions/13210880/replace-one-substring-for-another-string-in-shell-script 
    19 #${original_string//searchterm/$string_to_replace_searchterm_with} 
    20 replace="." 
    21 replacement="\." 
     21# if requested to format the IPv4 for the solr.xml tomcat context file 
     22if [ "$1" == "-format-for-tomcat-context" ]; then 
    2223 
    23 tmp=${tmp//$replace/$replacement} 
     24    #http://stackoverflow.com/questions/13210880/replace-one-substring-for-another-string-in-shell-script 
     25    #${original_string//searchterm/$string_to_replace_searchterm_with} 
     26    replace="." 
     27    replacement="\." 
     28     
     29    tmp=${tmp//$replace/$replacement} 
     30     
     31    # next, if the tmp variable is not the empty string, prefix the | operator 
     32    # http://unix.stackexchange.com/questions/146942/how-can-i-test-if-a-variable-is-empty-or-contains-only-spaces 
     33    # Can just return | if $tmp is empty, as that doesn't really matter. Will be consistent with windows 
     34    if [[ ! -z "${tmp// }" ]]; then 
     35    tmp="|$tmp" 
     36    else 
     37    tmp="|" 
     38    fi 
    2439 
    25 # next, if the tmp variable is not the empty string, prefix the | operator 
    26 # http://unix.stackexchange.com/questions/146942/how-can-i-test-if-a-variable-is-empty-or-contains-only-spaces 
    27 # Can just return | if $tmp is empty, as that doesn't really matter. Will be consistent with windows 
    28 if [[ ! -z "${tmp// }" ]]; then 
    29     tmp="|$tmp" 
    30 else 
    31     tmp="|" 
    3240fi 
    3341 
     42echo $tmp 
    3443 
    35 echo $tmp 
  • main/trunk/greenstone3/build.xml

    r30037 r30038  
    14141414 
    14151415  </target>   
    1416  
    1417   <target name="test-ipv4"> 
    1418     <exec executable="${basedir}/bin/script/IPv4.sh" os="${os.unix}" failonerror="false" outputproperty="ipv4.val"/> 
    1419     <exec executable="${basedir}/IPv4.bat" osfamily="windows" failonerror="false" outputproperty="ipv4.val"/> 
    1420     <echo>IPv4 was: ${ipv4.val}</echo> 
    1421   </target> 
    1422    
    14231416   
    14241417  <target name="configure-tomcat" depends="init,configure-tomcat-local,configure-tomcat-external"/> 
     
    14351428 
    14361429    <!-- set up the solr context --> 
    1437      
    1438     <exec executable="${basedir}/bin/script/IPv4.sh" os="${os.unix}" failonerror="false" outputproperty="ipv4.val"/> 
    1439     <exec executable="${basedir}/bin/script/IPv4.bat" osfamily="windows" failonerror="false" outputproperty="ipv4.val"/> 
    1440  
     1430 
     1431    <!-- First work out the IPv4 address for this machine --> 
     1432    <exec executable="${basedir}/bin/script/IPv4.sh" os="${os.unix}" failonerror="false" outputproperty="ipv4.val"> 
     1433      <arg value="-format-for-tomcat-context"/> 
     1434    </exec> 
     1435    <exec executable="${basedir}/bin/script/IPv4.bat" osfamily="windows" failonerror="false" outputproperty="ipv4.val"> 
     1436      <arg value="-format-for-tomcat-context"/> 
     1437    </exec> 
    14411438 
    14421439    <copy file="${basedir}/ext/solr/solr-tomcat-context.xml.in" tofile="${packages.home}/tomcat/conf/Catalina/localhost/solr.xml" overwrite="true">