install-sharness.sh 1.02 KB
Newer Older
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
1 2 3 4 5 6 7 8 9
#!/bin/sh
# install sharness.sh
#
# Copyright (c) 2014 Juan Batiz-Benet
# MIT Licensed; see the LICENSE file in this repository.
#

# settings
version=50229a79ba22b2f13ccd82451d86570fecbd194c
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
urlprefix=https://raw.githubusercontent.com/mlafeldt/sharness/$version

# files to download
sfile=sharness.sh
shash=eeaf96630fc25ec58fb678b64ef9772d5eb92f64

afile=aggregate-results.sh
ahash=948d6bc03222c5c00a1ed048068508d5ea1cce59

verified_download() {
  file=$1
  hash1=$2
  url=$urlprefix/$file

  # download it
  wget -q $url -O $file.test

  # verify it's the right file
  hash2=`cat $file.test | shasum | cut -c1-40`
  if test "$hash1" != "$hash2"; then
    echo "$file verification failed:"
    echo "  $hash1 != $hash2"
    return -1
  fi
  return 0
}


verified_download "$sfile" "$shash"; sok=$?
verified_download "$afile" "$ahash"; aok=$?
if test "$sok" != 0 || test "$aok" != 0; then
  rm $afile.test
  rm $sfile.test
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
43 44 45
  exit -1
fi

46 47 48
# ok, move things into place
mv $sfile.test $sfile
mv $afile.test $afile
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
49 50
chmod +x $sfile
chmod +x $afile
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
51
exit 0