Browse Source

simplify vultr scripts for deleting instances by label

tags/v0.14.2
Jonathan Cobb 4 years ago
parent
commit
e87084169d
4 changed files with 28 additions and 4 deletions
  1. +16
    -0
      bin/vultr/vultr_delete_instance_with_label.sh
  2. +0
    -0
      bin/vultr/vultr_delete_instance_with_subid.sh
  3. +3
    -4
      bin/vultr/vultr_list_instances.sh
  4. +9
    -0
      bin/vultr/vultr_subid_for_instance.sh

+ 16
- 0
bin/vultr/vultr_delete_instance_with_label.sh View File

@@ -0,0 +1,16 @@
#!/bin/bash
#
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
LABEL=${1:?no label provided}
THISDIR=$(cd $(dirname ${0}) && pwd)
VCURL=${THISDIR}/vcurl

SUBID=$(${THISDIR}/vultr_subid_for_instance.sh ${LABEL})
if [[ -z "${SUBID}" ]] ; then
echo "No instance found with label ${LABEL}"
exit 1
fi

echo "Deleting instance: ${SUBID}"
${VCURL} server/destroy -X POST -d "SUBID=${SUBID}" || echo "Error deleting instance: ${SUBID}"

bin/vultr/vultr_delete_instance.sh → bin/vultr/vultr_delete_instance_with_subid.sh View File


+ 3
- 4
bin/vultr/vultr_list_instances.sh View File

@@ -4,11 +4,10 @@
#
THISDIR=$(cd $(dirname ${0}) && pwd)
VCURL=${THISDIR}/vcurl
LABEL=${1}

VULTR_OUTPUT=${1}

if [[ -z "${VULTR_OUTPUT}" ]] ; then
if [[ -z "${LABEL}" ]] ; then
${VCURL} server/list | jq .
else
${VCURL} server/list | jq -r .[].${VULTR_OUTPUT}
${VCURL} server/list?label=${LABEL} | jq .
fi

+ 9
- 0
bin/vultr/vultr_subid_for_instance.sh View File

@@ -0,0 +1,9 @@
#!/bin/bash
#
# Copyright (c) 2020 Bubble, Inc. All rights reserved. For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
#
THISDIR=$(cd $(dirname ${0}) && pwd)
VCURL=${THISDIR}/vcurl
LABEL=${1?no label provided}

${VCURL} server/list?label=${LABEL} | jq -r '.[].SUBID'

Loading…
Cancel
Save