run shfmt on installer
This commit is contained in:
parent
30d1c9ee11
commit
2844db19a4
1 changed files with 55 additions and 41 deletions
40
install
40
install
|
@ -5,13 +5,24 @@ install_dir="/usr/local/bin"
|
||||||
add_alias=0
|
add_alias=0
|
||||||
nightly=0
|
nightly=0
|
||||||
|
|
||||||
while true
|
while true; do
|
||||||
do
|
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-a|--alias) add_alias=1; shift 1;;
|
-a | --alias)
|
||||||
-n|--nightly) nightly=1; shift 1;;
|
add_alias=1
|
||||||
-p|--prefix) install_dir=/$2; shift 2;;
|
shift 1
|
||||||
--) shift 1; break ;;
|
;;
|
||||||
|
-n | --nightly)
|
||||||
|
nightly=1
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
-p | --prefix)
|
||||||
|
install_dir=/$2
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift 1
|
||||||
|
break
|
||||||
|
;;
|
||||||
*) break ;;
|
*) break ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -39,15 +50,18 @@ fi
|
||||||
|
|
||||||
arch="$(uname -m)"
|
arch="$(uname -m)"
|
||||||
case "$arch" in
|
case "$arch" in
|
||||||
x86_64) arch="x86_64" ;;
|
x86_64) arch="x86_64" ;;
|
||||||
arm64) arch="aarch64" ;;
|
arm64) arch="aarch64" ;;
|
||||||
i686) arch="x86" ;;
|
i686) arch="x86" ;;
|
||||||
i386) arch="x86" ;;
|
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" | grep '"tag_name":' | cut -d'"' -f4)
|
||||||
[ -z "$version" ] && { echo "failed to fetch latest version"; exit 1; }
|
[ -z "$version" ] && {
|
||||||
|
echo "failed to fetch latest version"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# construct download url
|
# construct download url
|
||||||
# note: nightly assets are named like "flow-<version>-<os>-<arch>.<ext>"
|
# note: nightly assets are named like "flow-<version>-<os>-<arch>.<ext>"
|
||||||
|
@ -73,7 +87,7 @@ if [ "$filesize" -lt 100 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "installing $( [ "$nightly" -eq 1 ] && echo 'NIGHTLY build' || echo 'flow')..."
|
echo "installing $([ "$nightly" -eq 1 ] && echo 'NIGHTLY build' || echo 'flow')..."
|
||||||
if [ "$ext" = "tar.gz" ]; then
|
if [ "$ext" = "tar.gz" ]; then
|
||||||
tar -xzf "/tmp/$filename.$ext" -C "$install_dir"
|
tar -xzf "/tmp/$filename.$ext" -C "$install_dir"
|
||||||
else
|
else
|
||||||
|
@ -82,7 +96,7 @@ fi
|
||||||
|
|
||||||
chmod +x "$install_dir/flow"
|
chmod +x "$install_dir/flow"
|
||||||
rm "/tmp/$filename.$ext"
|
rm "/tmp/$filename.$ext"
|
||||||
echo "$( [ "$nightly" -eq 1 ] && echo 'NIGHTLY build' || echo 'flow') installed successfully!"
|
echo "$([ "$nightly" -eq 1 ] && echo 'NIGHTLY build' || echo 'flow') installed successfully!"
|
||||||
|
|
||||||
create_alias() {
|
create_alias() {
|
||||||
if [ -e "$install_dir/f" ]; then
|
if [ -e "$install_dir/f" ]; then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue