Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit cbfa47d

Browse files
committed
Add install script and readme snippet
1 parent a171882 commit cbfa47d

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ You can find additional Coder Enterprise usage documentation on [https://enterpr
1212

1313
## Install Release
1414

15-
Download the latest [release](https://github.com/cdr/coder-cli/releases):
15+
Shell
16+
17+
```
18+
curl -fsSL https://raw.githubusercontent.com/cdr/coder-cli/master/install.sh | sh
19+
```
20+
21+
Alternatively, manually download the latest [release](https://github.com/cdr/coder-cli/releases):
1622

1723
1. Click a release and download the tar file for your operating system (ex: coder-cli-linux-amd64.tar.gz)
1824
2. Extract the `coder` binary from the tar file, ex:

install.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/sh
2+
# TODO(everyone): Keep this script simple and easily auditable.
3+
4+
set -e
5+
6+
if [ "$(uname -m)" != "x86_64" ]; then
7+
echo "Error: Unsupported architecture $(uname -m). Only x64 binaries are available." 1>&2
8+
exit 1
9+
fi
10+
11+
if [ "$OS" = "Windows_NT" ]; then
12+
target="windows-386"
13+
ext=".zip"
14+
if ! command -v unzip >/dev/null; then
15+
echo "Error: unzip is required to install coder-cli" 1>&2
16+
exit 1
17+
fi
18+
else
19+
if ! command -v tar >/dev/null; then
20+
echo "Error: tar is required to install coder-cli" 1>&2
21+
exit 1
22+
fi
23+
ext=".tar.gz"
24+
case $(uname -s) in
25+
Darwin) target="darwin-amd64" ;;
26+
*) target="linux-amd64" ;;
27+
esac
28+
fi
29+
30+
if [ $# -eq 0 ]; then
31+
coder_asset_path=$(
32+
curl -sSf https://github.com/cdr/coder-cli/releases |
33+
grep -o "/cdr/coder-cli/releases/download/.*/coder-cli-${target}${ext}" |
34+
head -n 1
35+
)
36+
if [ ! "$coder_asset_path" ]; then
37+
echo "Error: Unable to find latest coder-cli release on GitHub." 1>&2
38+
exit 1
39+
fi
40+
cdr_uri="https://github.com${coder_asset_path}"
41+
else
42+
cdr_uri="https://github.com/cdr/coder-cli/releases/download/${1}/coder-cli-${target}${ext}"
43+
fi
44+
45+
coder_install="${CODER_INSTALL:-$HOME/.coder}"
46+
bin_dir="$coder_install/bin"
47+
exe="$bin_dir/coder"
48+
49+
if [ ! -d "$bin_dir" ]; then
50+
mkdir -p "$bin_dir"
51+
fi
52+
53+
curl --fail --location --progress-bar --output "$exe$ext" "$cdr_uri"
54+
if [ "$ext" = ".zip" ]; then
55+
unzip -d "$bin_dir" -o "$exe$ext"
56+
else
57+
tar -xzf "$exe$ext" -C "$bin_dir"
58+
fi
59+
chmod +x "$exe"
60+
rm "$exe$ext"
61+
62+
echo "Coder was installed successfully to $exe"
63+
if command -v coder >/dev/null; then
64+
echo "Run 'coder --help' to get started"
65+
else
66+
case $SHELL in
67+
/bin/zsh) shell_profile=".zshrc" ;;
68+
*) shell_profile=".bash_profile" ;;
69+
esac
70+
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
71+
echo " export CODER_INSTALL=\"$coder_install\""
72+
echo " export PATH=\"\$CODER_INSTALL/bin:\$PATH\""
73+
echo "Run '$exe --help' to get started"
74+
fi

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy