-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·94 lines (83 loc) · 2.82 KB
/
install.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
echo "Installing codegame-cli..."
cd /tmp
rm -f "codegame-cli.tar.gz"
os=$(uname)
arch=$(uname -m)
download () {
if hash wget 2>/dev/null; then
wget -q --show-progress https://github.com/code-game-project/codegame-cli/releases/latest/download/codegame-cli-$1-$2.tar.gz -O codegame-cli.tar.gz || exit 1
elif hash curl 2>/dev/null; then
curl -L https://github.com/code-game-project/codegame-cli/releases/latest/download/codegame-cli-$1-$2.tar.gz > codegame-cli.tar.gz || exit 1
else
echo "Please install either wget or curl."
exit 1
fi
}
shopt -s nocasematch
if [[ $os == *"linux"* ]]; then
if [[ $arch == *"x86"* ]]; then
echo "Detected OS: Linux x86_64"
download "linux" "amd64"
elif [[ $arch == *"aarch64"* ]]; then
echo "Detected OS: Linux ARM64"
download "linux" "arm64"
elif [[ $arch == *"arm"* ]]; then
echo "Detected OS: Linux ARM64"
download "linux" "arm64"
else
echo "Detected OS: $os $arch"
echo "Your architecture is not supported by this installer."
exit 1
fi
elif [[ $os == *"darwin"* ]]; then
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
if [[ $arch == *"x86"* ]]; then
echo "Detected OS: macOS x86_64"
download "darwin" "amd64"
elif [[ $arch == *"aarch64"* ]]; then
echo "Detected OS: macOS ARM64"
download "darwin" "arm64"
elif [[ $arch == *"arm"* ]]; then
echo "Detected OS: macOS ARM64"
download "darwin" "arm64"
else
echo "Detected OS: $os $arch"
echo "Your architecture is not supported by this installer."
exit 1
fi
else
echo "Detected OS: $os $arch"
echo "Your OS is not supported by this installer."
exit 1
fi
if [[ :$PATH: == *:"$HOME/.local/bin":* ]] ; then
echo "Installing binaries into ~/.local/bin..."
mkdir -p $HOME/.local/bin || exit 1
if test -f /usr/local/bin/codegame; then
echo "Removing old version in /usr/local/bin..."
sudo rm -f /usr/local/bin/codegame
fi
tar -xzf codegame-cli.tar.gz codegame && mv codegame $HOME/.local/bin || exit 1
else
echo "Installing binaries into /usr/local/bin..."
sudo mkdir -p /usr/local/bin || exit 1
if test -f $HOME/.local/bin/codegame; then
echo "Removing old version in ~/.local/bin..."
rm -f $HOME/.local/bin/codegame
fi
tar -xzf codegame-cli.tar.gz codegame && sudo mv codegame /usr/local/bin || exit 1
fi
rm codegame-cli.tar.gz
if hash code 2>/dev/null; then
echo "Installing CodeGame VS Code extension..."
if hash wget 2>/dev/null; then
wget -q --show-progress https://github.com/code-game-project/vscode-codegame/releases/latest/download/codegame.vsix -O codegame.vsix || exit 1
else
curl -L https://github.com/code-game-project/vscode-codegame/releases/latest/download/codegame.vsix > codegame.vsix || exit 1
fi
code --uninstall-extension code-game-project.codegame &>/dev/null
code --install-extension codegame.vsix || exit 1
rm codegame.vsix
fi
echo "Done."