Skip to content

Commit d833ad3

Browse files
committed
feat(workflow): add install-cli.sh
1 parent 22b83a5 commit d833ad3

4 files changed

Lines changed: 99 additions & 9 deletions

File tree

_scripts/install-cli.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
set -eo pipefail
3+
shopt -s expand_aliases
4+
5+
checkPlatformArch() {
6+
local supported="darwin-amd64 darwin-arm64 linux-amd64 linux-386 linux-arm linux-arm64 windows-386 windows-amd64"
7+
8+
if ! echo "${supported}" | tr ' ' '\n' | grep -q "${PLATFORM}-${ARCH}"; then
9+
cat <<EOF
10+
11+
The Drycc Workflow CLI (drycc) is not currently supported on ${PLATFORM}-${ARCH}.
12+
13+
See https://github.com/drycc/workflow-cli for more information.
14+
15+
EOF
16+
fi
17+
}
18+
19+
PLATFORM="$(uname | tr '[:upper:]' '[:lower:]')"
20+
if [[ "${INSTALL_DRYCC_MIRROR}" == "cn" ]] ; then
21+
DRYCC_BIN_URL_BASE="https://drycc-mirrors.oss-accelerate.aliyuncs.com/drycc/workflow-cli/releases"
22+
else
23+
DRYCC_BIN_URL_BASE="https://github.com/drycc/workflow-cli/releases"
24+
fi
25+
26+
# initArch discovers the architecture for this system.
27+
initArch() {
28+
ARCH=$(uname -m)
29+
case $ARCH in
30+
armv5*) ARCH="armv5";;
31+
armv6*) ARCH="armv6";;
32+
armv7*) ARCH="arm";;
33+
aarch64) ARCH="arm64";;
34+
x86) ARCH="386";;
35+
x86_64) ARCH="amd64";;
36+
i686) ARCH="386";;
37+
i386) ARCH="386";;
38+
esac
39+
}
40+
41+
initLatestVersion() {
42+
VERSION=$(curl -Ls $DRYCC_BIN_URL_BASE|grep /drycc/workflow-cli/releases/tag/ | grep -v no-underline | head -n 1 | cut -d '"' -f 2| awk '{n=split($NF,a,"/");print a[n]}' | awk 'a !~ $0{print}; {a=$0}')
43+
}
44+
45+
initArch
46+
initLatestVersion
47+
checkPlatformArch
48+
49+
DRYCC_CLI="drycc-${VERSION}-${PLATFORM}-${ARCH}"
50+
DRYCC_CLI_PATH="${DRYCC_CLI}"
51+
if [ "${VERSION}" != 'stable' ]; then
52+
DRYCC_CLI_PATH="${VERSION}/${DRYCC_CLI_PATH}"
53+
fi
54+
55+
echo "Downloading ${DRYCC_CLI} From Google Cloud Storage..."
56+
echo "Downloading binary from here: ${DRYCC_BIN_URL_BASE}/download/${DRYCC_CLI_PATH}"
57+
curl -fsSL -o drycc "${DRYCC_BIN_URL_BASE}/download/${DRYCC_CLI_PATH}"
58+
59+
chmod +x drycc
60+
61+
cat <<EOF
62+
63+
The Drycc Workflow CLI (drycc) is now available in your current directory.
64+
65+
To learn more about Drycc Workflow, execute:
66+
67+
$ ./drycc --help
68+
69+
You can also move it to other directories, such as:
70+
71+
$ mv $PWD/drycc /usr/local/bin
72+
73+
EOF

_scripts/install.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function get_helm {
5252
rm -rf "${tar_name}" "linux-${ARCH}"
5353
}
5454

55-
if [[ "${INSTALL_K3S_MIRROR}" == "cn" ]] ; then
55+
if [[ "${INSTALL_DRYCC_MIRROR}" == "cn" ]] ; then
5656
mkdir -p /etc/rancher/k3s
5757
cat << EOF > "/etc/rancher/k3s/registries.yaml"
5858
mirrors:
@@ -75,8 +75,10 @@ mirrors:
7575
- "https://k8s-mirror.drycc.cc"
7676
- "https://k8s.gcr.io"
7777
EOF
78+
INSTALL_K3S_MIRROR="${INSTALL_DRYCC_MIRROR}"
79+
export INSTALL_K3S_MIRROR
7880
k3s_install_url="http://rancher-mirror.cnrancher.com/k3s/k3s-install.sh"
79-
addons_url="https://drycc-mirrors.oss-accelerate.aliyuncs.com/addons/latest/index.yaml"
81+
addons_url="https://drycc-mirrors.oss-accelerate.aliyuncs.com/drycc/addons/releases/download/latest/index.yaml"
8082
else
8183
k3s_install_url="https://get.k3s.io"
8284
addons_url="https://github.com/drycc/addons/releases/download/latest/index.yaml"

src/quickstart/install-cli-tools.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,38 @@ Use the CLI to create and configure and manage applications.
55

66
Install the `drycc` client for Linux or Mac OS X with:
77

8-
$ curl -sSL https://raw.githubusercontent.com/drycc/workflow-cli/main/install.tmpl | bash -s v1.1.0
8+
```
9+
$ curl -sfL https://www.drycc.cc/install-cli.sh | bash -
10+
```
11+
12+
!!! important
13+
Users in Chinese mainland can use the following methods to speed up installation:
14+
15+
```
16+
$ curl -sfL https://www.drycc.cc/install-cli.sh | INSTALL_DRYCC_MIRROR=cn bash -
17+
```
918

1019
Others please visit: https://github.com/drycc/workflow-cli/releases
1120

1221
The installer places the `drycc` binary in your current directory, but you
1322
should move it somewhere in your $PATH:
1423

15-
$ sudo ln -fs $PWD/drycc /usr/local/bin/drycc
24+
```
25+
$ sudo ln -fs $PWD/drycc /usr/local/bin/drycc
26+
```
1627

1728
*or*:
1829

19-
$ sudo mv $PWD/drycc /usr/local/bin/drycc
30+
```
31+
$ sudo mv $PWD/drycc /usr/local/bin/drycc
32+
```
2033

2134
Check your work by running `drycc version`:
2235

23-
$ drycc version
24-
v1.1.0
36+
```
37+
$ drycc version
38+
v1.1.0
39+
```
2540

2641
!!! note
2742
Note that version numbers may vary as new releases become available

src/quickstart/install-workflow.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ $ curl -sfL https://www.drycc.cc/install.sh | bash -
129129
Users in Chinese mainland can use the following methods to speed up installation:
130130

131131
```
132-
$ curl -sfL https://www.drycc.cc/install.sh | INSTALL_K3S_MIRROR=cn bash -
132+
$ curl -sfL https://www.drycc.cc/install.sh | INSTALL_DRYCC_MIRROR=cn bash -
133133
```
134134

135135
### Install Options
@@ -144,7 +144,7 @@ DRYCC_ADMIN_PASSWORD | Required item, specify drycc's admin password
144144
CHANNEL | By default, `stable` channel will be installed. You can also specify `testing`
145145
USE_HAPROXY | Haproxy is enabled by default. If you want to turn it off, this value is false
146146
METALLB_ADDRESS_POOLS | IP pool for LoadBalancer. The default is `172.16.0.0/12`
147-
INSTALL_K3S_MIRROR | Specify the accelerated mirror location. Currently, only `cn` is supported
147+
INSTALL_DRYCC_MIRROR | Specify the accelerated mirror location. Currently, only `cn` is supported
148148
MINIO_PERSISTENCE_SIZE | The size of the persistence space allocated to `minio`, which is `5Gi` by default
149149
MONITOR_PERSISTENCE_SIZE | The size of the persistence space allocated to `monitor`, which is `5Gi` by default
150150
INFLUXDB_PERSISTENCE_SIZE | The size of the persistence space allocated to `influxdb`, which is `5Gi` by default

0 commit comments

Comments
 (0)