blob: e91fe0a797c268732f4457a52f0a2df1de97ef6c [file] [log] [blame]
Till Westmann276bbc22013-06-05 18:56:27 -07001#/*
Ian Maxond8857792015-09-11 14:19:53 -07002 # Licensed to the Apache Software Foundation (ASF) under one
3 # or more contributor license agreements. See the NOTICE file
4 # distributed with this work for additional information
5 # regarding copyright ownership. The ASF licenses this file
6 # to you under the Apache License, Version 2.0 (the
7 # "License"); you may not use this file except in compliance
8 # with the License. You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing,
13 # software distributed under the License is distributed on an
14 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 # KIND, either express or implied. See the License for the
16 # specific language governing permissions and limitations
17 # under the License.
18 #*/
vinayakb5d8a2f22013-01-29 19:45:44 +000019#get the OS
20OS_NAME=`uname -a|awk '{print $1}'`
21LINUX_OS='Linux'
22
23if [ $OS_NAME = $LINUX_OS ];
24then
25 #Get IP Address
26 IPADDR=`/sbin/ifconfig eth0 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
Michael Blowd6cf6412016-06-30 02:44:35 -040027 if [ "$IPADDR" = "" ]
buyingyia880ed92013-03-14 22:44:32 +000028 then
Michael Blowd6cf6412016-06-30 02:44:35 -040029 IPADDR=`/sbin/ifconfig em1 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
30 fi
31 if [ "$IPADDR" = "" ]
vinayakb5d8a2f22013-01-29 19:45:44 +000032 then
Michael Blowd6cf6412016-06-30 02:44:35 -040033 IPADDR=`/sbin/ifconfig lo | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
34 fi
vinayakb5d8a2f22013-01-29 19:45:44 +000035else
36 IPADDR=`/sbin/ifconfig en1 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
Michael Blowd6cf6412016-06-30 02:44:35 -040037 if [ "$IPADDR" = "" ]
vinayakb5d8a2f22013-01-29 19:45:44 +000038 then
39 IPADDR=`/sbin/ifconfig lo0 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
40 fi
41
42fi
43echo $IPADDR