Till Westmann | 276bbc2 | 2013-06-05 18:56:27 -0700 | [diff] [blame] | 1 | #/* |
| 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 | #*/ |
vinayakb | 5d8a2f2 | 2013-01-29 19:45:44 +0000 | [diff] [blame] | 15 | #get the OS |
| 16 | OS_NAME=`uname -a|awk '{print $1}'` |
| 17 | LINUX_OS='Linux' |
| 18 | |
| 19 | if [ $OS_NAME = $LINUX_OS ]; |
| 20 | then |
| 21 | #Get IP Address |
| 22 | IPADDR=`/sbin/ifconfig eth0 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'` |
buyingyi | a880ed9 | 2013-03-14 22:44:32 +0000 | [diff] [blame] | 23 | if [ "$IPADDR" = "" ] |
| 24 | then |
| 25 | IPADDR=`/sbin/ifconfig em1 | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'` |
| 26 | fi |
vinayakb | 5d8a2f2 | 2013-01-29 19:45:44 +0000 | [diff] [blame] | 27 | if [ "$IPADDR" = "" ] |
| 28 | then |
| 29 | IPADDR=`/sbin/ifconfig lo | grep "inet " | awk '{print $2}' | cut -f 2 -d ':'` |
| 30 | fi |
| 31 | else |
| 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 | |
| 38 | fi |
| 39 | echo $IPADDR |