-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·73 lines (59 loc) · 2 KB
/
install.sh
File metadata and controls
executable file
·73 lines (59 loc) · 2 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
70
71
72
73
#!/bin/bash
set -e
# Default to current latest
VERSION="$HTTP_SERVER_RS_VERSION"
if [ "$VERSION" = "" ]; then
VERSION=$(curl --silent "https://api.github.com/repos/alshdavid/http-server-rs/releases/latest" | jq -r '.tag_name')
fi
if [ "$VERSION" = "" ]; then
echo "Unable to fetch version"
exit 1
fi
# Default to home directory
if [ "$OUT_DIR" = "" ]; then
OUT_DIR="$HOME/.local/http-server-rs"
fi
>&2 echo VERSION: $VERSION
>&2 echo OUT_DIR: $OUT_DIR
ARCH=""
case "$(uname -m)" in
x86_64 | x86-64 | x64 | amd64) ARCH="amd64";;
aarch64 | arm64) ARCH="arm64";;
*) ARCH="";;
esac
OS=""
case "$(uname -s)" in
Darwin) OS="macos";;
Linux) OS="linux";;
MINGW64_NT* | Windows_NT) OS="windows";;
*) OS="";;
esac
>&2 echo ARCH: $ARCH
>&2 echo OS: $OS
URL=""
case "$OS-$ARCH" in
linux-amd64) URL="https://github.com/alshdavid/http-server-rs/releases/download/${VERSION}/http-server-linux-amd64.tar.gz";;
linux-arm64) URL="https://github.com/alshdavid/http-server-rs/releases/download/${VERSION}/http-server-linux-arm64.tar.gz";;
macos-amd64) URL="https://github.com/alshdavid/http-server-rs/releases/download/${VERSION}/http-server-macos-amd64.tar.gz";;
macos-arm64) URL="https://github.com/alshdavid/http-server-rs/releases/download/${VERSION}/http-server-macos-arm64.tar.gz";;
windows-amd64) URL="https://github.com/alshdavid/http-server-rs/releases/download/${VERSION}/http-server-windows-amd64.tar.gz";;
windows-arm64) URL="https://github.com/alshdavid/http-server-rs/releases/download/${VERSION}/http-server-windows-arm64.tar.gz";;
esac
if [ "$URL" = "" ]; then
echo "Cannot find archive"
exit 1
fi
>&2 echo URL: $URL
test -d $OUT_DIR && rm -rf $OUT_DIR
mkdir -p $OUT_DIR
if [ -z "${URL##*.tar.gz}" ]; then
curl -s -L --url $URL | tar -xzf - -C $OUT_DIR
chmod +x $OUT_DIR/http-server*
fi
echo "export PATH=\"${OUT_DIR}:\$PATH\""
>&2 echo "======="
>&2 echo "Add this to \$PATH"
>&2 echo " export PATH=\"${OUT_DIR}:\$PATH\""
if [ "$GITHUB_PATH" != "" ]; then
echo "${OUT_DIR}" >> $GITHUB_PATH
fi