Skip to content

Commit 3ded65c

Browse files
committed
[CX-2269] Add installation script for *nix users
1 parent 2fd75c0 commit 3ded65c

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ Light Train (SLT)](https://trains.chuniversiteit.nl/#slt).
55
## Installation
66

77
### macOS 10.12+ / Linux (x64, ARM)
8-
Download the latest binary for your platform from the Releases page. Make the
9-
binary executable using `chmod +x $fileName` and move the binary to `/usr/local/bin/slt`.
8+
Paste and execute the following command in a terminal window:
9+
10+
```
11+
/bin/bash -c "$(curl -L https://raw.githubusercontent.com/chunfeilung/slt/main/install.sh)"
12+
```
1013

1114
### Windows
1215
> :warning: slt may not display properly in cmd.exe. Please use Windows Terminal

install.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# Grab base download URL for latest release
6+
BASE_DOWNLOAD_URL=$(curl -Ls https://api.github.com/repos/chunfeilung/slt/releases/latest \
7+
| grep browser_download_url \
8+
| grep linux-x64 \
9+
| sed -re 's/(.+)"(http.+)-linux-x64"/\2/')
10+
11+
# Determine the right postfix for this runtime platform
12+
if [[ "$OSTYPE" == "darwin"* ]]; then
13+
BINARY_DOWNLOAD_URL="${BASE_DOWNLOAD_URL}-osx-x64"
14+
15+
else
16+
if [[ $(uname -m) == *"x86_64"* ]]; then
17+
libc=$(ldd /bin/ls | grep 'musl' | head -1 | cut -d ' ' -f1)
18+
if [ -z $libc ]; then
19+
BINARY_DOWNLOAD_URL="${BASE_DOWNLOAD_URL}-linux-x64"
20+
else
21+
BINARY_DOWNLOAD_URL="${BASE_DOWNLOAD_URL}-linux-musl-x64"
22+
fi
23+
24+
elif [[ $(uname -m) == *"arm64"* ]] || [[ $(uname -m) == *"aarch64"* ]]; then
25+
BINARY_DOWNLOAD_URL="${BASE_DOWNLOAD_URL}-linux-arm64"
26+
27+
else
28+
echo "This runtime platform is currently not supported. :("
29+
exit 1
30+
fi
31+
fi
32+
33+
# Download and install the program
34+
curl -sL $BINARY_DOWNLOAD_URL > /tmp/slt
35+
chmod +x /tmp/slt
36+
mv /tmp/slt /usr/local/bin/slt
37+
/usr/local/bin/slt --speed 10
38+
echo 'Installation is complete! :-)';

0 commit comments

Comments
 (0)