github.com/zignig/go-ipfs@v0.0.0-20141111235910-c9e5fdf55a52/test/lib/install-sharness.sh (about) 1 #!/bin/sh 2 # install sharness.sh 3 # 4 # Copyright (c) 2014 Juan Batiz-Benet 5 # MIT Licensed; see the LICENSE file in this repository. 6 # 7 8 # settings 9 version=50229a79ba22b2f13ccd82451d86570fecbd194c 10 urlprefix=https://raw.githubusercontent.com/mlafeldt/sharness/$version 11 installpath=lib/sharness 12 13 # files to download 14 sfile=sharness.sh 15 shash=eeaf96630fc25ec58fb678b64ef9772d5eb92f64 16 17 afile=aggregate-results.sh 18 ahash=948d6bc03222c5c00a1ed048068508d5ea1cce59 19 20 die() { 21 echo >&2 $@ 22 exit 1 23 } 24 25 verified_download() { 26 file=$1 27 hash1=$2 28 url=$urlprefix/$file 29 30 # download it 31 wget -q $url -O $file.test 32 33 # verify it's the right file 34 hash2=`cat $file.test | shasum | cut -c1-40` 35 if test "$hash1" != "$hash2"; then 36 echo "$file verification failed:" 37 echo " $hash1 != $hash2" 38 return -1 39 fi 40 return 0 41 } 42 43 mkdir -p $installpath || die "Could not create 'sharness' directory" 44 cd $installpath || die "Could not cd into 'sharness' directory" 45 46 verified_download "$sfile" "$shash"; sok=$? 47 verified_download "$afile" "$ahash"; aok=$? 48 if test "$sok" != 0 || test "$aok" != 0; then 49 rm $afile.test 50 rm $sfile.test 51 exit -1 52 fi 53 54 # ok, move things into place 55 mv $sfile.test $sfile 56 mv $afile.test $afile 57 chmod +x $sfile 58 chmod +x $afile 59 exit 0