mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 11:40:22 +00:00
22 lines
470 B
Bash
Executable File
22 lines
470 B
Bash
Executable File
#!/bin/sh -ux
|
|
# Prints to stdout ETag for given URL.
|
|
# If failed to obtain and $2=optional the particular tag is replaced with a keyword NOTFOUND
|
|
|
|
output=$1
|
|
url=$2
|
|
optional=${3-}
|
|
|
|
ETAG=$(curl -ILf "$url" | grep -i '^etag' | sed 's/.*"\(.*\)".*/\1/')
|
|
if [ "$ETAG" ]; then
|
|
printf '%s=' "$output"
|
|
printf '%s\n' "$ETAG" | sed 's/[^-._A-Za-z0-9]/_/g'
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$optional" = optional ]; then
|
|
echo "$1=NOTFOUND"
|
|
exit 0
|
|
fi
|
|
|
|
exit 1
|