-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
48 lines (37 loc) · 1.48 KB
/
Copy pathinstall.sh
File metadata and controls
48 lines (37 loc) · 1.48 KB
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
44
45
46
47
48
#!/usr/bin/env bash
set -euo pipefail
REPO="EntexInteractive/Parallel"
ASSET_PATTERN="Parallel-.*-cmd-linux-x64.zip"
INSTALL_ROOT="/usr/local/lib/parallel"
BIN_LINK="/usr/local/bin/parallel"
TMP_DIR="$(mktemp -d)"
ZIP_FILE="$TMP_DIR/parallel.zip"
command -v curl >/dev/null || { echo "curl required"; exit 1; }
command -v unzip >/dev/null || { echo "unzip required"; exit 1; }
echo "[1/5] Fetching latest release info..."
RELEASE_INFO=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest")
VERSION=$(echo "$RELEASE_INFO" | jq -r '.tag_name')
DOWNLOAD_URL=$(echo "$RELEASE_INFO" | jq -r --arg pattern "$ASSET_PATTERN" '.assets[] | select(.name | test($pattern)) | .browser_download_url' | head -n 1)
if [[ -z "$DOWNLOAD_URL" || "$DOWNLOAD_URL" == "null" ]]; then
echo "Could not find a valid release."
exit 1
fi
echo "[2/5] Downloading Parallel $VERSION..."
curl -fsSL -o "$ZIP_FILE" "$DOWNLOAD_URL"
echo "[3/5] Installing..."
rm -rf "$INSTALL_ROOT"
mkdir -p "$INSTALL_ROOT"
unzip -q "$ZIP_FILE" -d "$INSTALL_ROOT"
BIN_NAME=$(find "$INSTALL_ROOT" -maxdepth 1 -type f -iname "parallel" -printf '%f\n' | head -n 1)
if [[ -z "$BIN_NAME" ]]; then
echo "Could not find Parallel executable after extraction."
find "$INSTALL_ROOT" -maxdepth 2 -type f -print
exit 1
fi
rm -rf "$BIN_LINK"
chmod 755 "$INSTALL_ROOT/$BIN_NAME"
ln -sf "$INSTALL_ROOT/$BIN_NAME" "$BIN_LINK"
echo "[4/5] Cleaning up..."
rm -rf "$TMP_DIR"
echo "[5/5] Installed Parallel $VERSION"
echo "Binary: $BIN_LINK"