Created
May 19, 2014 11:27
-
-
Save anton-rudeshko/ebc5fa4ccc31c93bb988 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env bash | |
function check_access () { | |
host=$1; shift | |
port=$1; shift | |
nc -zw 1 $host $port > /dev/null && echo yes || echo no | |
} | |
function set_property () { | |
filename=$1; shift | |
key=$1; shift | |
value=$1; shift | |
escaped_key=`echo $key | sed 's/\./\\\\./g'` | |
key_regex="^$escaped_key[ :=].*$" | |
new_value="$key = $value" | |
if grep -q "$key_regex" "$filename"; then | |
echo "Updating property '$key'" | |
sed -i '' -e "s/$key_regex/$new_value/g" $filename | |
else | |
echo "Creating property '$key'" | |
echo "$new_value" >> $filename | |
fi | |
} | |
filename="test.properties" | |
set_property $filename "serp.agent.npm.version" `npm -v` | |
set_property $filename "serp.agent.node.version" `node -v` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment