Skip to content
Permalink
Browse files

Create provision-civo.sh

Signed-off-by: Andy Jeffries <andy@andyjeffries.co.uk>
  • Loading branch information...
andyjeffries authored and alexellis committed Nov 1, 2019
1 parent 770c384 commit 72c0b9b3dccf2a9fd1f794ef676f460cfb3c47aa
Showing with 36 additions and 0 deletions.
  1. +36 −0 hack/provision-civo.sh
@@ -0,0 +1,36 @@
#!/bin/bash

export SUFFIX=$(head -c 16 /dev/urandom | shasum | cut -c1-8)
export INSTANCENAME="inlets$SUFFIX"
export SIZE="g2.xsmall"
export TEMPLATE_ID="811a8dfb-8202-49ad-b1ef-1e6320b20497" # ubuntu-16.04
export REGION="lon1"
export FIELDS="ID,Name,PublicIPv4"
export SCRIPT=`pwd`/hack/userdata.sh

echo "Creating: $INSTANCENAME"

instanceId="$(civo instance create --name=$INSTANCENAME \
--size=$SIZE \
--user=root \
--template-id=$TEMPLATE \
--script=$SCRIPT \
--wait \
--quiet \
)"

if [ $? -eq 0 ];
then

instanceInfo="$(civo instance show $instanceId)"
publicIp="$(echo $instanceInfo | grep "Public IP" | cut -d"=" -f2 | cut -c3-)"
name="$(echo $instanceInfo | grep "Hostname" | cut -d":" -f2 | cut -c2-)"

echo "=============================="
echo "Instance: $name has been created"
echo "IP: $publicIp"
echo "Login: ssh root@$publicIp"
echo "=============================="
echo "To destroy this instance run: civo instance rm $instanceId"

fi

0 comments on commit 72c0b9b

Please sign in to comment.
You can’t perform that action at this time.