Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
105 lines (88 loc) · 2.64 KB

File metadata and controls

105 lines (88 loc) · 2.64 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env sh
# install.sh — download and install the forge binary
# Usage: curl -fsSL https://raw.githubusercontent.com/TerrorSquad/forge/main/install.sh | sh
# Or: curl -fsSL https://raw.githubusercontent.com/TerrorSquad/forge/main/install.sh | sh -s -- --version v0.2.0
set -eu
REPO="${FORGE_REPO:-TerrorSquad/forge}"
INSTALL_DIR="${FORGE_INSTALL_DIR:-$HOME/.local/bin}"
VERSION=""
FORGE_URL=""
# Parse flags
while [ $# -gt 0 ]; do
case "$1" in
--version) VERSION="$2"; shift 2 ;;
--dir) INSTALL_DIR="$2"; shift 2 ;;
--url) FORGE_URL="$2"; shift 2 ;;
--repo) REPO="$2"; shift 2 ;;
*) echo "Unknown flag: $1" >&2; exit 1 ;;
esac
done
# Detect OS / arch
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) echo "Unsupported arch: $ARCH" >&2; exit 1 ;;
esac
case "$OS" in
linux|darwin) ;;
*) echo "Unsupported OS: $OS" >&2; exit 1 ;;
esac
# Resolve version
if [ -z "$VERSION" ]; then
echo "Fetching latest release..."
VERSION="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \
| grep '"tag_name"' \
| sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')"
fi
VERSION="${VERSION#v}"
echo "Installing forge ${VERSION} (${OS}/${ARCH}) to ${INSTALL_DIR}"
if [ -n "$FORGE_URL" ]; then
URL="$FORGE_URL"
else
FILENAME="forge_${VERSION}_${OS}_${ARCH}.tar.gz"
URL="https://github.com/${REPO}/releases/download/v${VERSION}/${FILENAME}"
fi
TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT
if [ -n "$FORGE_URL" ]; then
case "$FORGE_URL" in
file://*)
FILE_PATH="${FORGE_URL#file://}"
if [ ! -f "$FILE_PATH" ]; then
echo "Error: local file not found: $FILE_PATH" >&2
exit 1
fi
cp "$FILE_PATH" "$TMP/forge.tar.gz"
;;
*)
if [ -f "$FORGE_URL" ]; then
cp "$FORGE_URL" "$TMP/forge.tar.gz"
else
curl -fsSL "$FORGE_URL" -o "$TMP/forge.tar.gz"
fi
;;
esac
else
curl -fsSL "$URL" -o "$TMP/forge.tar.gz"
fi
tar -xzf "$TMP/forge.tar.gz" -C "$TMP"
BINARY_PATH="$(find "$TMP" -maxdepth 2 -type f -name forge -print -quit)"
if [ -z "$BINARY_PATH" ]; then
echo "Error: could not find forge binary in the archive" >&2
exit 1
fi
DEST="$INSTALL_DIR/forge"
if [ ! -d "$INSTALL_DIR" ]; then
echo "Creating install directory $INSTALL_DIR"
mkdir -p "$INSTALL_DIR"
fi
if [ ! -w "$INSTALL_DIR" ]; then
echo "Error: cannot write to $INSTALL_DIR."
echo "Run with --dir ~/.local/bin or set FORGE_INSTALL_DIR to a writable path."
exit 1
fi
mv "$BINARY_PATH" "$DEST"
chmod +x "$DEST"
echo "Installed: $("$DEST" --version 2>/dev/null || echo "$DEST")"
Morty Proxy This is a proxified and sanitized view of the page, visit original site.