-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathinstall.sh
More file actions
69 lines (55 loc) · 1.9 KB
/
install.sh
File metadata and controls
69 lines (55 loc) · 1.9 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
set -e
# Basic install script for starforge
REPO="Josetic224/StarForge"
# Determine OS and Arch
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) ARCH="x86_64" ;;
aarch64|arm64) ARCH="aarch64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
case "$OS" in
linux|darwin) ;;
*) echo "Unsupported OS: $OS"; exit 1 ;;
esac
TAR_FILE="starforge-${OS}-${ARCH}.tar.gz"
echo "Fetching latest release for starforge..."
API_URL="https://api.github.com/repos/$REPO/releases/latest"
if command -v curl >/dev/null 2>&1; then
TAG=$(curl -s "$API_URL" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
else
echo "curl is required to download starforge"
exit 1
fi
if [ -z "$TAG" ]; then
echo "Failed to fetch latest release version"
exit 1
fi
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$TAG/$TAR_FILE"
CHECKSUM_URL="https://github.com/$REPO/releases/download/$TAG/checksums.txt"
echo "Downloading $DOWNLOAD_URL..."
curl -sL "$DOWNLOAD_URL" -o "$TAR_FILE" || { echo "Download failed"; exit 1; }
echo "Downloading $CHECKSUM_URL..."
curl -sL "$CHECKSUM_URL" -o checksums.txt || { echo "Checksum download failed"; exit 1; }
echo "Verifying checksum..."
if command -v sha256sum >/dev/null 2>&1; then
grep "$TAR_FILE" checksums.txt | sha256sum -c -
elif command -v shasum >/dev/null 2>&1; then
grep "$TAR_FILE" checksums.txt | shasum -a 256 -c -
else
echo "Warning: No sha256 checksum tool found. Skipping verification."
fi
echo "Extracting..."
tar -xzf "$TAR_FILE"
INSTALL_DIR="/usr/local/bin"
echo "Installing to $INSTALL_DIR (might require sudo)..."
if [ -w "$INSTALL_DIR" ]; then
mv -f starforge "$INSTALL_DIR/"
else
sudo mv -f starforge "$INSTALL_DIR/"
fi
chmod +x "$INSTALL_DIR/starforge"
rm -f "$TAR_FILE" checksums.txt
echo "starforge $TAG installed successfully! Run 'starforge --version' to verify."