fix: create empty file if it does not exist

previously check_etag.sh would not create a blank file if it did
not exist.  The result was that the first time check_etag.sh was
run it would always exit non-zero.
This commit is contained in:
Brian 'Redbeard' Harrington 2014-09-04 14:04:25 -07:00
parent 3e4c29957c
commit 29140526c9

View File

@ -10,7 +10,10 @@
set -e -o pipefail set -e -o pipefail
# Set default release to alpha if not specified
release=${1:-"alpha"} release=${1:-"alpha"}
# If the argument is in the form http* allow for watching an arbitrary location
if [[ $1 != http* ]]; then if [[ $1 != http* ]]; then
url="http://storage.core-os.net/coreos/amd64-usr/$release/version.txt" url="http://storage.core-os.net/coreos/amd64-usr/$release/version.txt"
else else
@ -19,9 +22,16 @@ else
fi fi
tmplocation="/tmp/etagsync" tmplocation="/tmp/etagsync"
# Create location for storage of CoreOS image state
mkdir -p ${tmplocation} mkdir -p ${tmplocation}
pushd ${tmplocation} > /dev/null 2>&1 pushd ${tmplocation} > /dev/null 2>&1
# Create file for release if it does not exist
if [ ! -f ${release}_etag ]; then
touch ${release}_etag
fi
# Retrieve the remote etag header
remote_etag=$(curl -I ${url} -k -s | \ remote_etag=$(curl -I ${url} -k -s | \
gawk '/ETag/ {print gensub("\"", "", "g", $2)}') gawk '/ETag/ {print gensub("\"", "", "g", $2)}')