forked from BretFisher/shpod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper-curl
executable file
·66 lines (60 loc) · 1.01 KB
/
helper-curl
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
#!/bin/sh
# shellcheck disable=SC1083,SC2083,SC2086
set -e
TYPE=$1
BIN_OR_ARGS=$2
URL=$3
case $TARGETARCH in
amd64)
GOARCH=amd64
UARCH=x86_64
WTFARCH=x86_64
;;
arm64)
GOARCH=arm64
UARCH=aarch64
WTFARCH=arm64
;;
arm)
GOARCH=arm
UARCH=armv7
WTFARCH=arm
;;
*)
echo "Unsupported architecture: $TARGETARCH."
GOARCH=$TARGETARCH
UARCH=$TARGETARCH
WTFARCH=$TARGETARCH
;;
esac
mangle() {
echo $1 | sed \
-e s/@GOARCH/$GOARCH/g \
-e s/@UARCH/$UARCH/g \
-e s/@WTFARCH/$WTFARCH/g \
#
}
URL=$(mangle $URL)
BIN_OR_ARGS=$(mangle "$BIN_OR_ARGS")
if ! curl -fsSLI $URL >/dev/null; then
echo "URL not found: $URL"
BIN=${BIN_OR_ARGS##*/}
echo "Installing placeholder: $BIN"
cp /bin/helper-unsupported /usr/local/bin/$BIN
exit 0
fi
case "$TYPE" in
bin)
BIN=$BIN_OR_ARGS
curl -fsSL $URL > /usr/local/bin/$BIN
chmod +x /usr/local/bin/$BIN
;;
tar)
ARGS=$BIN_OR_ARGS
curl -fsSL $URL | tar -zxvf- -C /usr/local/bin $ARGS
;;
*)
echo "Unrecognized download type: $TYPE"
exit 1
;;
esac