Skip to content

Commit 697a7e9

Browse files
authored
Merge pull request #111 from dimitraz/AEROGEAR-2639-install-script
[AEROGEAR-2639] Add CLI installer script
2 parents 3023554 + 2b3452b commit 697a7e9

File tree

2 files changed

+82
-2
lines changed

2 files changed

+82
-2
lines changed

README.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ mobile get clientconfig <mobileClientID> --namespace=<namespace>
2323
mobile create integration <consumingServiceInstanceID> <providingServiceInstanceID> --namespace=<namespace>
2424
```
2525

26-
## CLI Installation
26+
## Installing the CLI
27+
To quickly get up and running with the CLI for Mac and Linux, simply execute the installer script from inside the `scripts` directory.
28+
```bash
29+
./install.sh
30+
```
31+
Or, to install a specific version:
32+
```bash
33+
./install.sh <version>
34+
```
35+
36+
## Developing the CLI
37+
2738
### Pre-requisites
2839
- Have a local Kubernetes or OpenShift cluster with mobile clients and services available via minikube, [mobile core installer](https://github.com/aerogear/mobile-core/blob/master/docs/walkthroughs/local-setup.adoc) or [minishift](https://github.com/aerogear/minishift-mobilecore-addon).
2940
- Install [glide](https://github.com/Masterminds/glide)
@@ -90,7 +101,7 @@ oc edit clusterrole admin # add the above and save
90101
oc edit clusterrole edit # add the above and save
91102
```
92103

93-
### Setup as Kubectl/OC plugin
104+
## Setup as Kubectl/OC plugin
94105

95106
- have the [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) command line tool or the [oc command line tool](https://docs.openshift.org/latest/cli_reference/get_started_cli.html#installing-the-cli) already installed
96107
- it should be version k8s version 1.8 or OpenShift 3.7 or later

scripts/install.sh

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env bash
2+
3+
function usage {
4+
echo "usage: ${0} [version]"
5+
exit 0
6+
}
7+
8+
function error_msg {
9+
echo "${1}. Exit code: ${2}"
10+
exit ${2}
11+
}
12+
13+
function get_os {
14+
case "$OSTYPE" in
15+
darwin*)
16+
os="darwin" ;;
17+
linux*)
18+
os="linux" ;;
19+
*)
20+
echo "Unsupported OS: $OSTYPE"
21+
exit 1 ;;
22+
esac
23+
}
24+
25+
function get_arch {
26+
case "$(uname -m)" in
27+
x86_64)
28+
arch="amd64" ;;
29+
*)
30+
echo "Unsupported ARCH: $(uname -m)"
31+
exit 1 ;;
32+
esac
33+
}
34+
35+
function install {
36+
echo "Installing the Mobile CLI..."
37+
if [ -n "${1}" ]; then
38+
readonly version=${1}
39+
else
40+
readonly version=$(curl -s "https://api.github.com/repos/aerogear/mobile-cli/releases/latest" | grep '"tag_name":' | sed 's/[^0-9.]*//g')
41+
fi
42+
43+
echo "Downloading version ${version}"
44+
get_os
45+
get_arch
46+
47+
curl -s -f -L -O -J https://github.com/aerogear/mobile-cli/releases/download/v${version}/mobile-cli_${version}_${os}_${arch}.tar.gz
48+
exit_code=${?}
49+
50+
if [ $exit_code -ne 0 ]; then
51+
error_msg "Failed to download binary" ${exit_code}
52+
fi
53+
54+
tar -xf mobile-cli_${version}_${os}_${arch}.tar.gz && sudo cp mobile /usr/local/bin
55+
exit_code=${?}
56+
57+
if [ $exit_code -ne 0 ]; then
58+
error_msg "Failed to unpack binary" ${exit_code}
59+
fi
60+
61+
rm -rf mobile-cli_${version}_${os}_${arch}.tar.gz && rm -rf mobile
62+
echo "Mobile CLI installed. Use 'mobile --help' for more information."
63+
}
64+
65+
if [[ $* == *-h* ]] || [[ $* == *--help* ]]; then
66+
usage
67+
fi
68+
69+
install ${1}

0 commit comments

Comments
 (0)