Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 384 fix cli script #391

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions crates/web5_cli/install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/bash

# Clean up files in case of error
clean_up_temp () {
[[ -f "/tmp/$FILENAME" ]] && rm -f "/tmp/$FILENAME"
}

trap clean_up_temp EXIT

if [ -z "$1" ]; then
echo "Usage: $0 <version>"
exit 1
Expand All @@ -11,15 +18,32 @@ ARCH=$(uname -m)

case $OS in
"linux")
echo "Operating System - Architecture: Linux - $ARCH"
case $ARCH in
"x86_64") FILENAME="web5-x86_64-linux-gnu" ;;
"x86_64")
if [[ "$VERSION" == "v0.0.2" || "$VERSION" == "v0.0.3" || "$VERSION" == "v0.0.4" ]]; then
FILENAME="web5-x86_64-linux-gnu.zip"
else
FILENAME="web5_cli-x86_64-unknown-linux-gnu"
fi;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
;;
"darwin")
echo "Operating System - Architecture: macOS - $ARCH"
case $ARCH in
"x86_64") FILENAME="web5-x86_64-apple-darwin" ;;
"arm64") FILENAME="web5-aarch64-apple-darwin" ;;
"x86_64")
if [[ "$VERSION" == "v0.0.2" || "$VERSION" == "v0.0.3" || "$VERSION" == "v0.0.4" ]]; then
FILENAME="web5-x86_64-apple-darwin.zip"
else
FILENAME="web5_cli-x86_64-apple-darwin"
fi;;
"arm64")
if [[ "$VERSION" == "v0.0.2" || "$VERSION" == "v0.0.3" || "$VERSION" == "v0.0.4" ]]; then
FILENAME="web5-aarch64-apple-darwin.zip"
else
FILENAME="web5_cli-aarch64-apple-darwin"
fi;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
;;
Expand All @@ -28,12 +52,24 @@ case $OS in
esac

# Download
curl -L -o /tmp/$FILENAME https://github.com/TBD54566975/web5-rs/releases/download/$VERSION/$FILENAME
echo "Downloading $FILENAME"
curl -L -f -o /tmp/$FILENAME https://github.com/TBD54566975/web5-rs/releases/download/$VERSION/$FILENAME

# Check download errors
if [ $? -ne 0 ] ; then
echo "Error while downloading $FILENAME"
echo "Exiting..."
exit 1
fi

# give it executable permissions
chmod +x /tmp/$FILENAME

# Move the executable to /usr/local/bin
if [ -d "/usr/local/bin" ]; then
echo "Creating /usr/local/bin"
mkdir /usr/local/bin
fi
mushahidq marked this conversation as resolved.
Show resolved Hide resolved
sudo mv /tmp/$FILENAME /usr/local/bin/web5

# Cleanup
Expand Down
Loading