test os and checksum
This commit is contained in:
parent
3f86e60bbe
commit
945291a2a8
24
get.sh
24
get.sh
|
@ -1,20 +1,34 @@
|
|||
#!/usr/bin/env sh
|
||||
# get recent release version
|
||||
uname=$(uname -a)
|
||||
echo $uname|grep -i "debian" && { fn_suffix="linux-amd64.deb"; }
|
||||
echo $uname|grep -i "openbsd" && { fn_suffix="openbsd-amd64.tar.gz"; }
|
||||
echo $uname|grep -i "freebsd" && { fn_suffix="freebsd-amd64.tar.gz"; }
|
||||
test -z $fn_suffix && { echo "operating system not supported."; exit 1; }
|
||||
|
||||
url_effective=$(curl -sLI -o /dev/null -w %{url_effective} https://github.com/gopasspw/gopass/releases/latest)
|
||||
url=$(echo ${url_effective} | sed 's/\/tag\//\/download\//')"/"
|
||||
ver=$(echo -n $url | cut -d'/' -f8 | cut -d"v" -f2)
|
||||
fn1="gopass"
|
||||
fn_deb=${fn1}"-"${ver}"-linux-amd64.deb"
|
||||
fn_package=${fn1}"-"${ver}"-"${fn_suffix}
|
||||
fn_SHA256=${fn1}"_"${ver}"_SHA256SUMS"
|
||||
|
||||
# download files: deb and checksums
|
||||
curl -L $url$fn_deb -o $fn_deb || { echo "download failed"; exit 1; }
|
||||
curl -L $url$fn_package -o $fn_package || { echo "download failed"; exit 1; }
|
||||
curl -L $url$fn_SHA256 -o $fn_SHA256 || { echo "download failed"; exit 1; }
|
||||
|
||||
# test checksums
|
||||
test $(cat ${fn_SHA256} |grep ${fn_deb} |cut -d" " -f1) = $(sha256sum gopass-1.8.6-linux-amd64.deb|cut -d" " -f1) && {
|
||||
# install
|
||||
sudo dpkg -i $fn
|
||||
$(cat ${fn_SHA256} |grep $$(sha256sum $fn_package)) && {
|
||||
# maybe install
|
||||
case $(echo $fn_suffix|cut -d"-" -f1) in
|
||||
linux)
|
||||
sudo dpkg -i ${fn_package}
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "please install manually"
|
||||
;;
|
||||
esac
|
||||
} || {
|
||||
echo "checksum failed"#; exit 1
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue