-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
90 additions
and
0 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,90 @@ | ||
#!/bin/bash | ||
|
||
readonly MAGENTA="$(tput setaf 5 2>/dev/null || echo '')" | ||
readonly GREEN="$(tput setaf 2 2>/dev/null || echo '')" | ||
readonly CYAN="$(tput setaf 6 2>/dev/null || echo '')" | ||
readonly NO_COLOR="$(tput sgr0 2>/dev/null || echo '')" | ||
|
||
# Define the release information | ||
RELEASE_URL="https://api.github.com/repos/pocketenv-io/pocketenv/releases/latest" | ||
|
||
# Determine the operating system | ||
OS=$(uname -s) | ||
if [ "$OS" = "Darwin" ]; then | ||
# Determine the CPU architecture | ||
ARCH=$(uname -m) | ||
if [ "$ARCH" = "arm64" ]; then | ||
ASSET_NAME="_aarch64-apple-darwin.tar.gz" | ||
else | ||
ASSET_NAME="_x86_64-apple-darwin.tar.gz" | ||
fi | ||
elif [ "$OS" = "Linux" ]; then | ||
# Determine the CPU architecture | ||
ARCH=$(uname -m) | ||
if [ "$ARCH" = "aarch64" ]; then | ||
ASSET_NAME="_aarch64-unknown-linux-gnu.tar.gz" | ||
elif [ "$ARCH" = "x86_64" ]; then | ||
ASSET_NAME="_x86_64-unknown-linux-gnu.tar.gz" | ||
else | ||
echo "Unsupported architecture: $ARCH" | ||
exit 1 | ||
fi | ||
else | ||
echo "Unsupported operating system: $OS" | ||
exit 1 | ||
fi | ||
|
||
# Retrieve the download URL for the desired asset | ||
DOWNLOAD_URL=$(curl -sSL $RELEASE_URL | grep -o "browser_download_url.*$ASSET_NAME\"" | cut -d ' ' -f 2) | ||
|
||
ASSET_NAME=$(basename $DOWNLOAD_URL) | ||
|
||
# Define the installation directory | ||
INSTALL_DIR="/usr/local/bin" | ||
|
||
DOWNLOAD_URL=`echo $DOWNLOAD_URL | tr -d '\"'` | ||
|
||
# Download the asset | ||
curl -SL $DOWNLOAD_URL -o /tmp/$ASSET_NAME | ||
|
||
# Extract the asset | ||
tar -xzf /tmp/$ASSET_NAME -C /tmp | ||
|
||
# Set the correct permissions for the binary | ||
chmod +x /tmp/pocketenv | ||
|
||
# Move the extracted binary to the installation directory | ||
# use sudo if OS is Linux | ||
if [ "$OS" = "Linux" ]; then | ||
if command -v sudo >/dev/null 2>&1; then | ||
sudo mv /tmp/pocketenv $INSTALL_DIR | ||
else | ||
mv /tmp/pocketenv $INSTALL_DIR | ||
fi | ||
else | ||
mv /tmp/pocketenv $INSTALL_DIR | ||
fi | ||
|
||
# Clean up temporary files | ||
rm /tmp/$ASSET_NAME | ||
|
||
echo "Installation completed! 🎉" | ||
|
||
cat << EOF | ||
${CYAN} | ||
____ __ __ | ||
/ __ \\____ _____/ /_____ / /____ ____ _ __ | ||
/ /_/ / __ \\/ ___/ //_/ _ \\/ __/ _ \\/ __ \\ | / / | ||
/ ____/ /_/ / /__/ ,< / __/ /_/ __/ / / / |/ / | ||
/_/ \\____/\\___/_/|_|\\___/\\__/\\___/_/ /_/|___/ | ||
${NO_COLOR} | ||
Manage your ${GREEN}development environment${NO_COLOR} with ease ✨ | ||
${GREEN}https://github.com/pocketenv-io/pocketenv${NO_COLOR} | ||
Please file an issue if you encounter any problems! | ||
=============================================================================== | ||
EOF |