-
-
Save manisnesan/054fba55e8fe6897ffa3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
function isLocalhost { | |
local TEST_IP=$(getent hosts $1 | cut -f1 -d\ | head -1) | |
local ALL_MY_IPS=$(ip addr | grep inet | grep -v link | cut -f2- -de | cut -f2 -d\ | cut -f1 -d/) | |
( echo $ALL_MY_IPS | grep -q $TEST_IP ) && return 0 | |
return 1 | |
} | |
if ( isLocalhost $1 ) ; then | |
echo yes | |
else | |
echo no | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment