-
Notifications
You must be signed in to change notification settings - Fork 22
/
install_cli.sh
executable file
·60 lines (46 loc) · 1.25 KB
/
install_cli.sh
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
#!/bin/bash
set -e
set -x
arch="amd64"
if [[ $(uname -m) == "aarch64" ]]; then
arch="arm64"
fi
extract_to="$HOME/.wakatime"
os="unknown"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
os="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
os="darwin"
elif [[ "$OSTYPE" == "cygwin" ]]; then
os="windows"
elif [[ "$OSTYPE" == "msys" ]]; then
os="windows"
elif [[ "$OSTYPE" == "win32" ]]; then
os="windows"
elif [[ "$OSTYPE" == "freebsd"* ]]; then
os="freebsd"
elif [[ "$OSTYPE" == "openbsd"* ]]; then
os="openbsd"
elif [[ "$OSTYPE" == "netbsd"* ]]; then
os="netbsd"
fi
zip_file="$extract_to/wakatime-cli-${os}-${arch}.zip"
symlink="$extract_to/wakatime-cli"
extracted_binary="$extract_to/wakatime-cli-${os}-${arch}"
if [[ "$os" == "windows" ]]; then
extracted_binary="$extracted_binary.exe"
fi
url="https://github.com/wakatime/wakatime-cli/releases/latest/download/wakatime-cli-${os}-${arch}.zip"
# make dir if not exists
mkdir -p "$extract_to"
cd "$extract_to"
echo "Downloading wakatime-cli to $zip_file ..."
curl -L "$url" -o "$zip_file"
echo "Unzipping zip_file ..."
unzip -q -o "$zip_file" || true
ln -fs "$extracted_binary" "$symlink"
chmod a+x "$extracted_binary"
echo "Installed $symlink"
rm "$zip_file"
echo "Finished installing wakatime-cli."
exit 0