verify_digest(){ # $0 method file string case "$1" in *) DIGEST=`echo "$1" | tr a-z A-Z` [ "$DIGEST($2)= $3" = "`openssl $1 $2`" ] ;; esac } verify_signature(){ # $0 [url|id] sig case "$1" in 0x*) gpg --recv-keys "$1" && gpg --verify "$2" ;; http:*|ftp:*) curl "$1" | gpg --import && gpg --verify "$2" ;; *) gpg --import && gpg --verify "$1" ;; esac } error_out(){ # $0 message ... echo "$@" 1>&2 exit 1 } wget -N ftp://core.ring.gr.jp/pub/GNU/gnu-arch/tla-1.3.4.tar.gz wget -N ftp://core.ring.gr.jp/pub/GNU/gnu-arch/tla-1.3.4.tar.gz.sig verify_signature http://www.atai.org/public_key.txt tla-1.3.4.tar.gz.sig || error_out "$0: stopped at line $LINENO" tar xvzf tla-1.3.4.tar.gz