Skip to content

Instantly share code, notes, and snippets.

View romash1408's full-sized avatar

Roman Dubinin romash1408

View GitHub Profile
@romash1408
romash1408 / wait-for-http-code.sh
Last active October 4, 2018 06:20
Repeat request to host using curl untill it return specified http code
#/bin/sh
HOST=${1}
ATTEMPTS=${2:-10} # -1 for unlimited
CODE=${3:-200}
OUT=${4:-/dev/null}
DELAY=${5:-1s}
case "$HOST" in
"" | "-h" | "--help")
@romash1408
romash1408 / check-docker-image.sh
Created October 1, 2018 07:30
Checks if docker image exists (in local or remote storage). Prevent image pull if it doesn't exist locally
#!/bin/sh
rm -f /tmp/check-docker-image
{
docker image pull "$@" &> /dev/null
echo "$?" > /tmp/check-docker-image
} &
PULL=$!
sleep 5
if [[ -f /tmp/check-docker-image ]]; then