Compare commits
2 commits
8ec3c54b97
...
3f535d15e0
Author | SHA1 | Date | |
---|---|---|---|
3f535d15e0 | |||
ac54438fbe |
1 changed files with 34 additions and 16 deletions
|
@ -8,6 +8,7 @@ nightly=${NIGHTLY:-0}
|
|||
verify=${VERIFY:-0}
|
||||
local=${LOCAL:-0}
|
||||
use_sudo=${USE_SUDO:-0}
|
||||
force_update=${FORCE_UPDATE:-0}
|
||||
|
||||
usage() {
|
||||
echo "Options:"
|
||||
|
@ -17,6 +18,7 @@ usage() {
|
|||
echo " -d <path>, --dest <path> Set install destination (default /usr/local/bin)"
|
||||
echo " -V, --verify Verify gpg signature"
|
||||
echo " -l, --local Verify gpg signature with local keychain"
|
||||
echo " -F, --force Force re-install even if flow is up-to-date"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -31,7 +33,7 @@ while true; do
|
|||
shift 1
|
||||
;;
|
||||
-d | --dest)
|
||||
install_dir=/$2
|
||||
install_dir=$2
|
||||
shift 2
|
||||
;;
|
||||
-V | --verify)
|
||||
|
@ -42,6 +44,10 @@ while true; do
|
|||
local=1
|
||||
shift 1
|
||||
;;
|
||||
-F | --force)
|
||||
force_update=1
|
||||
shift 1
|
||||
;;
|
||||
-h | --help)
|
||||
usage
|
||||
;;
|
||||
|
@ -82,21 +88,6 @@ if [ -z "$need_sudo" ] && [ -e "$install_dir/f" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ "$use_sudo" -eq 0 ] && [ -n "$need_sudo" ]; then
|
||||
printf "%s is not writable. Permissions will be requested with sudo.\n" "$need_sudo"
|
||||
use_sudo=1
|
||||
fi
|
||||
|
||||
SUDOCMD=""
|
||||
if [ -n "$need_sudo" ]; then
|
||||
if [ "$use_sudo" -eq 1 ]; then
|
||||
SUDOCMD=sudo
|
||||
else
|
||||
echo "error: '$need_sudo' is not writable."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# prompt for nightly build option if interactive
|
||||
if [ "$nightly" -eq 0 ] && [ "$have_term" -eq 1 ]; then
|
||||
printf "do you want to install a Nightly build? [y/N]: "
|
||||
|
@ -154,6 +145,33 @@ version=$(curl -s "https://api.github.com/repos/$repo/releases/latest" | grep '"
|
|||
}
|
||||
title="$title $version"
|
||||
|
||||
if [ "$force_update" -eq 0 ] && [ -e "$install_dir/flow" ]; then
|
||||
current_version=$(flow --version 2>/dev/null | grep version: | cut -f2 -d ' ')
|
||||
if [ "$current_version" = "$version" ]; then
|
||||
echo "flow is up-to-date (version $version @ $install_dir/flow)"
|
||||
exit 0
|
||||
else
|
||||
if [ -n "$current_version" ]; then
|
||||
echo "updating flow from $current_version to $version"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$use_sudo" -eq 0 ] && [ -n "$need_sudo" ]; then
|
||||
printf "%s is not writable. Permissions will be requested with sudo.\n" "$need_sudo"
|
||||
use_sudo=1
|
||||
fi
|
||||
|
||||
SUDOCMD=""
|
||||
if [ -n "$need_sudo" ]; then
|
||||
if [ "$use_sudo" -eq 1 ]; then
|
||||
SUDOCMD=sudo
|
||||
else
|
||||
echo "error: '$need_sudo' is not writable."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# construct download url
|
||||
# note: nightly assets are named like "flow-<version>-<os>-<arch>.<ext>"
|
||||
filename="flow-$version-$os-$arch"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue