source: main/trunk/greenstone3/IPv4.sh@ 30036

Last change on this file since 30036 was 30036, checked in by ak19, 9 years ago

Scripts for adding in the IPv4 of the GS server machine into the solr.xml tomcat context file, so that even if they're not using localhost but the hostname of the machine, the /solr context still works off 8383 (host:port/solr).

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/bin/bash
2
3#http://www.wikihow.com/Find-Your-IP-Address-on-a-Mac#Finding_Your_Internal_IP_Using_the_Terminal_sub
4#http://stackoverflow.com/questions/1469849/how-to-split-one-string-into-multiple-strings-in-bash-shell
5#http://www.linuxforums.org/forum/red-hat-fedora-linux/193076-ifconfig-doesnt-display-ipv4-address.html
6
7
8# The following echoes the IPv4, e.g. 100.200.300.45
9# But need to still replace the . with \.
10
11#echo `ifconfig | grep "inet " | grep -v 127.0.0.1`|cut -d' ' -f 2|cut -d':' -f 2
12
13
14tmp=`ifconfig | grep "inet " | grep -v 127.0.0.1`
15
16tmp=`echo $tmp|cut -d' ' -f 2|cut -d':' -f 2`
17
18#http://stackoverflow.com/questions/13210880/replace-one-substring-for-another-string-in-shell-script
19#${original_string//searchterm/$string_to_replace_searchterm_with}
20replace="."
21replacement="\."
22
23tmp=${tmp//$replace/$replacement}
24
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
28if [[ ! -z "${tmp// }" ]]; then
29 tmp="|$tmp"
30else
31 tmp="|"
32fi
33
34
35echo $tmp
Note: See TracBrowser for help on using the repository browser.