Created
July 22, 2024 18:31
-
-
Save PBillingsby/4cd61bc97158c67884767639d91010c7 to your computer and use it in GitHub Desktop.
A script that removes the current Lilypad version and adds the binary pasted
This file contains hidden or 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
| install_lilypad() { | |
| local BASE_URL=$1 | |
| # Extract the version from the URL | |
| VERSION=$(echo $BASE_URL | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+') | |
| if [[ -z "$VERSION" ]]; then | |
| echo "Failed to extract version from URL." | |
| return 1 | |
| fi | |
| # Detect your machine's architecture and set it as $OSARCH | |
| OSARCH=$(uname -m | awk '{if ($0 ~ /arm64|aarch64/) print "arm64"; else if ($0 ~ /x86_64|amd64/) print "amd64"; else print "unsupported_arch"}') | |
| export OSARCH | |
| # Detect your operating system and set it as $OSNAME | |
| OSNAME=$(uname -s | awk '{if ($1 == "Darwin") print "darwin"; else if ($1 == "Linux") print "linux"; else print "unsupported_os"}') | |
| export OSNAME | |
| echo "https://github.com/Lilypad-Tech/lilypad/releases/download/$VERSION/lilypad-$OSNAME-$OSARCH-cpu" | |
| # Check for supported OS and architecture | |
| if [[ "$OSNAME" == "unsupported_os" || "$OSARCH" == "unsupported_arch" ]]; then | |
| echo "Unsupported OS or architecture" | |
| return 1 | |
| fi | |
| # Construct the download URL for CPU only | |
| URL="https://github.com/Lilypad-Tech/lilypad/releases/download/$VERSION/lilypad-$OSNAME-$OSARCH-cpu" | |
| # Remove current Lilypad installation | |
| sudo rm -rf /usr/local/bin/lilypad /tmp/lilypad | |
| # Download the specified version build to /tmp/lilypad using wget or curl | |
| if command -v wget > /dev/null; then | |
| wget $URL -O /tmp/lilypad | |
| elif command -v curl > /dev/null; then | |
| curl -L $URL -o /tmp/lilypad | |
| else | |
| echo "Neither wget nor curl is installed." | |
| return 1 | |
| fi | |
| # Check if the downloaded file is an HTML document | |
| if head -n 1 /tmp/lilypad | grep -q '<!DOCTYPE html>'; then | |
| echo "Failed to download the binary. The URL might be incorrect." | |
| rm /tmp/lilypad | |
| return 1 | |
| fi | |
| # Make Lilypad executable | |
| chmod +x /tmp/lilypad | |
| # Move Lilypad to /usr/local/bin | |
| sudo mv /tmp/lilypad /usr/local/bin/lilypad | |
| echo "Lilypad installed successfully." | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment