Add some random scripts in my machine

This commit is contained in:
bt3 2018-06-27 11:20:48 -07:00
parent 69ccfd04d5
commit 8f29682a89
3 changed files with 120 additions and 0 deletions

23
network/check_port.sh Normal file
View file

@ -0,0 +1,23 @@
#!/bin/bash
# Check a whether a port is open or not
#
# then use the script in your tests like
# check_port 9200
function check_port() {
local host=${1} && shift
local port=${1} && shift
local retries=5
local wait=1
until( nc -zv "${host}" "${port}" ); do
((retries--))
if [ $retries -lt 0 ]; then
echo "Service ${host}:${port} didn't become ready in time."
exit 1
fi
sleep "${wait}"
done
}
check_port "localhost" "$@"