Compare commits
3 commits
9fd1e1f763
...
1d8dd56e16
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d8dd56e16 | |||
| e6a2a7aa62 | |||
| 688cb97ad5 |
1 changed files with 31 additions and 10 deletions
|
|
@ -2,7 +2,6 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
install_dir="${PREFIX:-/usr/local}/bin"
|
install_dir="${PREFIX:-/usr/local}/bin"
|
||||||
tmp_path="${TMPDIR:-/tmp}"
|
|
||||||
add_alias=${ALIAS:-0}
|
add_alias=${ALIAS:-0}
|
||||||
nightly=${NIGHTLY:-0}
|
nightly=${NIGHTLY:-0}
|
||||||
debug=${DEBUG:-0}
|
debug=${DEBUG:-0}
|
||||||
|
|
@ -152,10 +151,13 @@ i386) arch="x86" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# get latest version tag from github releases api
|
# get latest version tag from github releases api
|
||||||
version=$(curl -s "https://api.github.com/repos/$repo/releases/latest" | grep '"tag_name":' | cut -d'"' -f4)
|
version=$(curl -s "https://api.github.com/repos/$repo/releases/latest" | jq -r .tag_name)
|
||||||
[ -z "$version" ] && {
|
[ -z "$version" ] && {
|
||||||
echo "failed to fetch $title latest version"
|
version=$(curl -s https://git.flow-control.dev/api/v1/repos/$repo/releases/latest | jq -r .tag_name)
|
||||||
|
[ -z "$version" ] && {
|
||||||
|
echo "failed to fetch $title latest version from github or flow-control.dev"
|
||||||
exit 1
|
exit 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
title="$title $version"
|
title="$title $version"
|
||||||
|
|
||||||
|
|
@ -202,7 +204,30 @@ if [ "$debug" -eq 1 ]; then
|
||||||
fi
|
fi
|
||||||
url="https://github.com/$repo/releases/download/$version/$filename.$ext"
|
url="https://github.com/$repo/releases/download/$version/$filename.$ext"
|
||||||
|
|
||||||
echo "downloading $title..."
|
tmp_path="$(mktemp -t -d "$(basename "$0").XXXXX")"
|
||||||
|
|
||||||
|
if [ -z "$tmp_path" ] || [ "$tmp_path" == "/" ]; then
|
||||||
|
echo "failed to create a temporary download directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
rm -Rf "$tmp_path"
|
||||||
|
echo "removed temporary directory $tmp_path"
|
||||||
|
}
|
||||||
|
|
||||||
|
die() {
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
trap die SIGINT
|
||||||
|
trap die SIGHUP
|
||||||
|
trap die SIGTERM
|
||||||
|
trap die SIGQUIT
|
||||||
|
trap die ERR
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
echo "downloading $title... to $tmp_path"
|
||||||
|
|
||||||
curl -fL "$url" -o "$tmp_path/$filename.$ext"
|
curl -fL "$url" -o "$tmp_path/$filename.$ext"
|
||||||
|
|
||||||
|
|
@ -216,14 +241,11 @@ fi
|
||||||
if [ "$verify" -eq 1 ]; then
|
if [ "$verify" -eq 1 ]; then
|
||||||
curl -fL "$url.sig" -o "$tmp_path/$filename.$ext.sig"
|
curl -fL "$url.sig" -o "$tmp_path/$filename.$ext.sig"
|
||||||
curl -fL 'https://flow-control.dev/public.gpg' -o "$tmp_path/flow-control-public.gpg"
|
curl -fL 'https://flow-control.dev/public.gpg' -o "$tmp_path/flow-control-public.gpg"
|
||||||
gpg --no-default-keyring --keyring "$tmp_path/flow-control-public.gpg" --verify "$tmp_path/$filename.$ext.sig" "$tmp_path/$filename.$ext"
|
gpg --homedir "$tmp_path/" --no-options --no-default-keyring --keyring "$tmp_path/flow-control-public.gpg" --verify "$tmp_path/$filename.$ext.sig" "$tmp_path/$filename.$ext"
|
||||||
|
|
||||||
if [ "$local" -eq 1 ]; then
|
if [ "$local" -eq 1 ]; then
|
||||||
gpg --verify "$tmp_path/$filename.$ext.sig" "$tmp_path/$filename.$ext"
|
gpg --verify "$tmp_path/$filename.$ext.sig" "$tmp_path/$filename.$ext"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm "$tmp_path/flow-control-public.gpg"
|
|
||||||
rm "$tmp_path/$filename.$ext.sig"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "installing $title to $install_dir/flow..."
|
echo "installing $title to $install_dir/flow..."
|
||||||
|
|
@ -234,7 +256,6 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$SUDOCMD chmod +x "$install_dir/flow"
|
$SUDOCMD chmod +x "$install_dir/flow"
|
||||||
rm "$tmp_path/$filename.$ext"
|
|
||||||
|
|
||||||
if [ "$add_alias" -eq 1 ]; then
|
if [ "$add_alias" -eq 1 ]; then
|
||||||
if [ "$(readlink "$install_dir/f")" = "$install_dir/flow" ]; then
|
if [ "$(readlink "$install_dir/f")" = "$install_dir/flow" ]; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue