File: install-binary.sh

package info (click to toggle)
nanopub 0.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,240 kB
  • sloc: javascript: 181; sh: 86; python: 64; xml: 60; makefile: 31
file content (43 lines) | stat: -rwxr-xr-x 1,026 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
set -e

# Install nanopub binary for linux and MacOS
BINARY_NAME="np"

# Destination directory
DEST_DIR="/usr/local/bin"

BASE_BINARY_URL="http://github.com/vemonet/nanopub-rs/releases/latest/download/nanopub_x86_64"
# Detect the platform (Linux or macOS)
case "$(uname)" in
    "Linux")
        PLATFORM="linux"
        BINARY_URL="${BASE_BINARY_URL}_linux_gnu"
        ;;
    "Darwin")
        PLATFORM="mac"
        BINARY_URL="${BASE_BINARY_URL}_apple"
        ;;
    *)
        echo "Unsupported platform: $(uname)" >&2
        exit 1
        ;;
esac

echo "Downloading binary from $BINARY_URL"

# Download the binary
curl -sSL -o "$BINARY_NAME" "$BINARY_URL"

# Make binary executable
chmod +x "$BINARY_NAME"

# Move the binary to the destination directory
if [ -w "$DEST_DIR" ]; then
    mv "$BINARY_NAME" "$DEST_DIR"
else
    echo "🔓️ Admin permissions required to install to $DEST_DIR"
    sudo mv "$BINARY_NAME" "$DEST_DIR"
fi

echo "✨ Installation completed. $BINARY_NAME installed to $DEST_DIR"