Skip to content

Commit 6083875

Browse files
author
Matthew Fisher
committed
added some error checking for digital ocean
1 parent 3a2841e commit 6083875

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

contrib/digitalocean/provision-digitalocean-controller.sh

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,26 @@ function echo_color {
99
echo -e "\033[1m$1\033[0m"
1010
}
1111

12+
function usage {
13+
echo_color "Usage: provision-digitalocean-controller.sh <region-id>"
14+
}
15+
1216
THIS_DIR=$(cd $(dirname $0); pwd) # absolute path
1317
CONTRIB_DIR=$(dirname $THIS_DIR)
1418

15-
echo_color "Provisioning a deis controller on Digital Ocean!"
19+
if [[ -z $1 ]]; then
20+
usage
21+
exit 1
22+
fi
1623

1724
# check for Deis' general dependencies
1825
if ! $CONTRIB_DIR/check-deis-deps.sh; then
1926
echo 'Deis is missing some dependencies.'
2027
exit 1
2128
fi
2229

30+
echo_color "Provisioning a deis controller on Digital Ocean!"
31+
2332
# connection details for using digital ocean's API
2433
client_id=$DIGITALOCEAN_CLIENT_ID
2534
api_key=$DIGITALOCEAN_API_KEY
@@ -46,12 +55,23 @@ chef_version=11.6.2
4655
##########################
4756

4857
# the name of the location we want to work with
49-
location_id=$1
58+
region_id=$1
5059
# The snapshot that we want to use (deis-base)
5160
image_id=$(knife digital_ocean image list | grep "deis-base" | awk '{print $1}')
5261
# the ID of the size (1GB)
5362
size_id=$(knife digital_ocean size list | grep "2GB" | awk '{print $1}')
5463

64+
if [[ -z $image_id ]]; then
65+
echo "Can't find saved image \"deis-base\" in region $region_id. Please follow the"
66+
echo "instructions in prepare-digitalocean-snapshot.sh before provisioning a Deis controller."
67+
exit 1
68+
fi
69+
70+
if [[ -z $size_id ]]; then
71+
echo "Cannot find a droplet with the size '2GB' in region $region_id."
72+
exit 1
73+
fi
74+
5575
################
5676
# SSH settings #
5777
################

0 commit comments

Comments
 (0)