Skip to content

Commit a42b84c

Browse files
author
Samuel Vandamme
committed
* Improved output and added creating a symlink
1 parent f48db79 commit a42b84c

File tree

1 file changed

+51
-24
lines changed

1 file changed

+51
-24
lines changed

install.sh

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,84 @@
11
#!/usr/bin/env bash
22

3-
# COSCALE_APPID=00248f3b-294f-4adc-94eb-33c72b1d0a95 COSCALE_TOKEN=b7672983-078d-4f3d-b8c5-731f76b0786c bash -c "$(curl -L https://raw.githubusercontent.com/CoScale/coscale-cli/feature/install-script/install.sh)"
3+
4+
#
5+
# Show url after getting latest version
6+
# Improve output formatting
7+
#
48

59
set -u
610
set -e
711

12+
echo
13+
echo "## Checking configuration and environment"
14+
echo
815

9-
echo "Preparing to install CoScale CLI"
16+
if [ -z ${COSCALE_APPID+x} ] || [ -z ${COSCALE_TOKEN+x} ]; then
17+
echo "### Configuration"
18+
echo
19+
# Check command arguments
20+
if [ -z ${COSCALE_APPID+x} ]; then
21+
echo "Please enter your app id:"
22+
read -e COSCALE_APPID
23+
fi
24+
echo
1025

11-
# Check command arguments
12-
if [ -z ${COSCALE_APPID+x} ]; then
13-
echo "App id:"
14-
read -e COSCALE_APPID
26+
if [ -z ${COSCALE_TOKEN+x} ]; then
27+
echo "Please enter your access token:"
28+
read -e COSCALE_TOKEN
29+
fi
30+
echo
1531
fi
1632

17-
if [ -z ${COSCALE_TOKEN+x} ]; then
18-
echo "Access token:"
19-
read -e COSCALE_TOKEN
20-
fi
33+
# Detect operation system
34+
echo "### Detecting operating system"
35+
echo
36+
os=`uname -o | awk '{split($0,a,"/"); print tolower(a[2])}'`
37+
echo "Operation system: {{$os}}"
38+
echo
2139

2240
# Fetch latest release list from Github
23-
echo "Getting latest release information"
41+
echo
42+
echo "## Getting latest release information"
43+
echo
2444
github_data=`curl -s -L https://api.github.com/repos/CoScale/coscale-cli/releases/latest | grep "browser_download_url" | awk '{ print $2; }' | sed 's/"//g'`
2545

26-
# Detect operation system
27-
echo "Detecting operation system"
28-
os=`uname -o | awk '{split($0,a,"/"); print tolower(a[2])}'`
29-
3046
# Select correct release
3147
release=`echo "$github_data" | grep $os`
48+
echo "### Latest release: ${{release}}"
49+
50+
# Start install
51+
echo
52+
echo "## Installing CoScale CLI tool"
53+
echo
3254

3355
# Create dirs
34-
echo "Creating directories /opt/coscale/cli"
35-
mkdir -p /opt/coscale/cli
56+
echo "### Creating directories /opt/coscale/cli"
57+
echo
58+
mkdir -v -p /opt/coscale/cli
3659
pushd /opt/coscale/cli
60+
echo
3761

3862
# Install client
39-
echo "Downloading client to /opt/coscale/cli/coscale-cli"
63+
echo "### Downloading client to /opt/coscale/cli/coscale-cli"
4064
curl -L "$release" > coscale-cli
41-
chmod +x coscale-cli
65+
chmod -v +x coscale-cli
66+
echo
4267

43-
# Add to $PATH
44-
echo "Adding coscale-cli to $PATH in /root/.bashrc"
45-
echo "export PATH=\"${PATH}:/opt/coscale/cli\"" >> /root/.bashrc
46-
source /root/.bashrc
68+
# Create symlink from /usr/bin/coscale-cli to /opt/coscale/cli/coscale-cli
69+
echo "### Creating symlink"
70+
ln -v -S /usr/bin/coscale-cli /opt/coscale/cli/coscale-cli
71+
echo
4772

4873
# Create config
49-
echo "Creating config"
74+
echo "Generating config"
5075
echo "{\"baseurl\":\"https://api.coscale.com\", \"appid\":\"$COSCALE_APPID\", \"accesstoken\":\"$COSCALE_TOKEN\"}" | gzip -c > /opt/coscale/cli/api.conf
76+
echo
5177

5278
# Test config
5379
echo "Testing configuration"
5480
coscale-cli event list
81+
echo
5582

5683
# Done
5784
echo "Done, you can now start using the CoScale CLI tool."

0 commit comments

Comments
 (0)