diff options
| author | Philipp Tanlak <philipp.tanlak@gmail.com> | 2024-02-16 22:26:50 +0100 |
|---|---|---|
| committer | Philipp Tanlak <philipp.tanlak@gmail.com> | 2024-02-16 22:41:32 +0100 |
| commit | 76b3fa8be0ccb63f780809011e9a5aecaeba1a83 (patch) | |
| tree | 7d47abcb64aa5a9d3007f3b0535125b3dad6b9cf /install.sh | |
| parent | 66ae586a8294fc6241a12020d2e856e9725934ba (diff) | |
Create curl installer
Diffstat (limited to 'install.sh')
| -rwxr-xr-x | install.sh | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..36e9ca8 --- /dev/null +++ b/install.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +set -e + +error() { + echo -e "error:" "$@" >&2 + exit 1 +} + +if [[ ${OS:-} = Windows_NT ]]; then + error "This installer does not support Windows." +fi + +echo "Installing flyscrape" + +case $(uname -ms) in +'Darwin x86_64') + target=macos_amd64 + ;; +'Darwin arm64') + target=macos_arm64 + ;; +'Linux aarch64' | 'Linux arm64') + target=linux_arm64 + ;; +'Linux x86_64' | *) + target=linux_amd64 + ;; +esac + +dir="$HOME/.flyscrape" + +mkdir -p "$dir" || + error "Failed to create directory: $HOME/.flyscrape" + + +archive="$dir/flyscrape_$target.tar.gz" +url="https://github.com/philippta/flyscrape/releases/latest/download/flyscrape_$target.tar.gz" +curl --fail --location --progress-bar --output "$archive" "$url" || + error "Failed to download flyscrape from: $url" + +tar -xzf "$archive" -C "$dir" || + error "Failed to extract downloaded archive." + +chmod +x "$dir/flyscrape" || + error "Failed to chmod the flyscrape executable." + +rm "$archive" "$dir/README.md" "$dir/LICENSE" || + error "Failed to clean up the downloaded archive." + +case $(basename "$SHELL") in +zsh) + # Add paths to zsh + if [[ ":$PATH:" != *":$HOME/.flyscrape:"* ]]; then + if [[ -w "$HOME/.zshrc" ]]; then + echo "# flyscrape" >> "$HOME/.zshrc" + echo "export PATH=\"$dir:\$PATH\"" >> "$HOME/.zshrc" + else + echo "" + echo "Manually add the directory to ~/.zshrc (or similar):" + echo " export PATH=\"$dir:\$PATH\"" + fi + fi + ;; +bash) + # Add paths to bbash + if [[ ":$PATH:" != *":$HOME/.flyscrape:"* ]]; then + if [[ -w "$HOME/.bashrc" ]]; then + echo "# flyscrape" >> "$HOME/.bashrc" + echo "export PATH=$dir:\$PATH" >> "$HOME/.bashrc" + else + echo "" + echo "Manually add the directory to ~/.bashrc (or similar):" + echo " export PATH=$dir:\$PATH" + fi + fi + ;; +*) + echo "" + echo "Manually add the directory to ~/.bashrc (or similar):" + echo " export PATH=$dir:\$PATH" + ;; +esac + +echo "" +echo "The installation was successfull!" +echo "" +echo "Note:" +echo "Please restart your terminal window. This ensures your system correctly detects flyscrape." +echo "" |