blob: f1a20d9c87ec4020c6a5ba58a4b952683a01599e [file] [log] [blame]
Till Westmann276bbc22013-06-05 18:56:27 -07001#/*
2# Copyright 2009-2013 by The Regents of the University of California
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# you may obtain a copy of the License from
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#*/
vinayakb5d8a2f22013-01-29 19:45:44 +000015#get the OS
16OS_NAME=`uname -a|awk '{print $1}'`
17LINUX_OS='Linux'
18
19if [ $OS_NAME = $LINUX_OS ];
20then
21 #Get IP Address
22 IPADDR=`/sbin/ifconfig eth0 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
buyingyia880ed92013-03-14 22:44:32 +000023 if [ "$IPADDR" = "" ]
24 then
25 IPADDR=`/sbin/ifconfig em1 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
26 fi
vinayakb5d8a2f22013-01-29 19:45:44 +000027 if [ "$IPADDR" = "" ]
28 then
29 IPADDR=`/sbin/ifconfig lo | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
30 fi
31else
32 IPADDR=`/sbin/ifconfig en1 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
33 if [ "$IPADDR" = "" ]
34 then
35 IPADDR=`/sbin/ifconfig lo0 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'`
36 fi
37
38fi
39echo $IPADDR