-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
58 lines (45 loc) · 1.28 KB
/
install.sh
File metadata and controls
58 lines (45 loc) · 1.28 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
#!/data/data/com.termux/files/usr/bin/bash
set -e
BINARY_NAME="psh"
VERSION="${VERSION:-latest}"
# Detect if running as root inside Termux
if [ "$(id -u)" -eq 0 ]; then
echo "Error: Do not run this installer as root inside Termux."
exit 1
fi
ARCH=$(uname -m)
case "$ARCH" in
aarch64)
ARCH_DL="arm64-v8a"
;;
armv7l|armv8l)
ARCH_DL="armeabi-v7a"
;;
x86_64)
ARCH_DL="x86_64"
;;
i686)
ARCH_DL="x86"
;;
*)
echo "Error: Unsupported architecture: $ARCH"
exit 1
;;
esac
ONLINE_BINARY="${BINARY_NAME}-${ARCH_DL}"
if [ "$VERSION" = "latest" ]; then
DOWNLOAD_URL="https://github.com/DerGoogler/psh/releases/latest/download/$ONLINE_BINARY"
else
DOWNLOAD_URL="https://github.com/DerGoogler/psh/releases/download/${VERSION}/$ONLINE_BINARY"
fi
DEST_DIR="$PREFIX/bin"
DEST_PATH="${DEST_DIR}/${BINARY_NAME}"
echo "Installing ${BINARY_NAME} version ${VERSION} for architecture ${ARCH_DL}..."
echo "Downloading from: ${DOWNLOAD_URL}"
curl -L --fail "$DOWNLOAD_URL" -o "$DEST_PATH"
chmod 755 "$DEST_PATH"
TERMUX_UID=$(stat -c "%u" "$PREFIX")
TERMUX_GID=$(stat -c "%g" "$PREFIX")
chown "$TERMUX_UID:$TERMUX_GID" "$DEST_PATH"
echo "Installation successful!"
echo "Binary installed at: $DEST_PATH"