Skip to content

Commit fc06326

Browse files
author
Samuel Vandamme
committed
Added check for existing configuration
1 parent d345481 commit fc06326

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

install.sh

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,25 @@ echo
1313
echo "## Checking configuration and environment"
1414
echo
1515

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 -r COSCALE_APPID
16+
if [ ! -f "/opt/coscale/cli/api.conf" ]; then
17+
if [ -z ${COSCALE_APPID+x} ] || [ -z ${COSCALE_TOKEN+x} ]; then
18+
echo "### Configuration"
19+
echo
20+
# Check command arguments
21+
if [ -z ${COSCALE_APPID+x} ]; then
22+
echo "Please enter your app id:"
23+
read -e -r COSCALE_APPID
24+
fi
25+
echo
26+
27+
if [ -z ${COSCALE_TOKEN+x} ]; then
28+
echo "Please enter your access token:"
29+
read -e -r COSCALE_TOKEN
30+
fi
31+
echo
2332
fi
24-
echo
25-
26-
if [ -z ${COSCALE_TOKEN+x} ]; then
27-
echo "Please enter your access token:"
28-
read -e -r COSCALE_TOKEN
29-
fi
30-
echo
33+
else
34+
echo "### Configuration detected in /opt/coscale/cli/api.conf"
3135
fi
3236

3337
# Detect operation system
@@ -83,9 +87,11 @@ fi
8387
echo
8488

8589
# Create config
86-
echo "Generating config"
87-
echo "{\"baseurl\":\"https://api.coscale.com\", \"appid\":\"$COSCALE_APPID\", \"accesstoken\":\"$COSCALE_TOKEN\"}" | gzip -c > /opt/coscale/cli/api.conf
88-
echo
90+
if [ ! -f "/opt/coscale/cli/api.conf" ]; then
91+
echo "Generating config"
92+
echo "{\"baseurl\":\"https://api.coscale.com\", \"appid\":\"$COSCALE_APPID\", \"accesstoken\":\"$COSCALE_TOKEN\"}" | gzip -c > /opt/coscale/cli/api.conf
93+
echo
94+
fi
8995

9096
# Test config
9197
echo "Testing configuration"

0 commit comments

Comments
 (0)