Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. remove shasum and cosign 2. improve output and help
- Loading branch information
1 parent
99d290e
commit 466fb7e
Showing
2 changed files
with
141 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#!/bin/sh | ||
# shellcheck shell=dash | ||
|
||
set -e | ||
|
||
info() { | ||
local _green='\033[0;32m' | ||
local _no_color='\033[0m' | ||
|
||
echo " ${_green} INFO${_no_color} $1" | ||
} | ||
|
||
error() { | ||
local _red='\033[0;31m' | ||
local _no_color='\033[0m' | ||
|
||
echo | ||
echo " ${_red}ERROR${_no_color} $1" | ||
|
||
echo | ||
echo " If you need help, please start a discussion on Github:" | ||
echo " https://github.com/build-trust/ockam/discussions/new" | ||
echo | ||
|
||
exit 1 | ||
} | ||
|
||
required() { | ||
if ! command -v "$1" > /dev/null 2>&1; then | ||
error "need '$1' (command not found)" | ||
fi | ||
} | ||
|
||
detect_binary_file_name() { | ||
info "Detecting Operating System and Architecture ..." | ||
|
||
local _os_type _cpu_type _file_name | ||
_os_type="$(uname -s)" | ||
_cpu_type="$(uname -m)" | ||
|
||
case "$_os_type" in | ||
Darwin) | ||
if [ "$_cpu_type" = i386 ]; then | ||
# Darwin `uname -m` lies | ||
if sysctl hw.optional.x86_64 | grep -q ': 1'; then | ||
_cpu_type=x86_64 | ||
fi | ||
fi | ||
|
||
case "$_cpu_type" in | ||
x86_64) _file_name="ockam.x86_64-apple-darwin";; | ||
arm64) _file_name="ockam.aarch64-apple-darwin";; | ||
*) error "Unsupported CPU type: ${_cpu_type} on MacOS" | ||
esac | ||
;; | ||
Linux) | ||
case "$_cpu_type" in | ||
x86_64 | aarch64) _file_name="ockam.$_cpu_type-unknown-linux-gnu";; | ||
armv7l) _file_name="ockam.$_cpu_type-unknown-linux-gnueabihf";; | ||
*) error "Unsupported CPU type: ${_cpu_type} on Linux"; | ||
esac | ||
;; | ||
*) error "Unsupported operating system type: ${_os_type}" | ||
esac | ||
|
||
info "Detected Operating System Type: ${_os_type}" | ||
info "Detected CPU Type: ${_cpu_type}" | ||
info "Picked Released File Name: ${_file_name}" | ||
|
||
return_value="$_file_name" | ||
} | ||
|
||
download() { | ||
required curl | ||
required grep | ||
required awk | ||
required sed | ||
|
||
local _version _url | ||
local _download_base_url="https://github.com/build-trust/ockam/releases/download" | ||
local _api='https://api.github.com/repos/build-trust/ockam/releases' | ||
local _binary_file_name="$1" | ||
|
||
if [ "$2" ]; then | ||
_version="$2" | ||
_url="$_download_base_url/ockam_$_version/$_binary_file_name" | ||
else | ||
_url=$(curl --proto '=https' --tlsv1.2 --silent --fail --show-error "$_api") | ||
_url=$(echo "$_url" | grep -i browser_download_url | grep "$_binary_file_name" | head -1 | awk '{print $NF}') | ||
_url=$(echo "$_url" | sed -e 's/^"//' -e 's/"$//') # remove quotes | ||
_version=$(echo "$_url" | awk -F'/' '{print $(NF-1)}' | cut -d '_' -f2) # change "ockam_v0.75.0" to "v0.75.0" | ||
fi | ||
|
||
info "Installing $_version" | ||
|
||
info "Dowloading $_url" | ||
curl --proto '=https' --tlsv1.2 --location --silent --fail --show-error --output "ockam" "$_url" | ||
info "Downloaded ockam command in the current directory $(pwd)" | ||
|
||
info "Granting permission to execute: chmod u+x ockam" | ||
chmod u+x ockam | ||
} | ||
|
||
main() { | ||
echo | ||
local _yellow='\033[0;33m' | ||
local _no_color='\033[0m' | ||
local _version="$1" | ||
|
||
detect_binary_file_name | ||
local _binary_file_name="$return_value" | ||
|
||
download "$_binary_file_name" "$_version" | ||
|
||
echo | ||
echo " ${_yellow}GET STARTED:${_no_color}" | ||
echo " Ockam Command is ready to be executed in the current directory." | ||
echo | ||
echo " You can execute it by running:" | ||
echo " ./ockam" | ||
echo | ||
echo " If you wish to run it from anywhere on your machine ..." | ||
echo | ||
echo " Please copy it to a directory that is in your \$PATH, for example:" | ||
echo " mv ockam /usr/local/bin" | ||
echo | ||
echo " After that, you should be able to execute it anywhere by simply typing:" | ||
echo " ockam" | ||
echo | ||
echo " ${_yellow}LEARN MORE:${_no_color}" | ||
echo " Learn more at https://docs.ockam.io/get-started#command" | ||
echo | ||
echo " ${_yellow}FEEDBACK:${_no_color}" | ||
echo " If you have any questions or feedback, please start a discussion" | ||
echo " on Github https://github.com/build-trust/ockam/discussions/new" | ||
echo | ||
|
||
exit 0 | ||
} | ||
|
||
main "$1" |
This file was deleted.
Oops, something went wrong.