From 59381e52931e65c6c4398b9defbbb07e8a588474 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Wed, 7 Apr 2021 19:49:49 +0200 Subject: [PATCH] Use vendored JQ --- README.md | 2 ++ abra-hetzner | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fef4ca8..ef6c4f5 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ The script can be run on its own like so. $ ./abra-hetzner my-new-vps cx11 debian-10 --ssh-keys foo@example.com ``` +It assumes a `$ABRA_DIR/vendor/jq` binary installation of [jq](https://stedolan.github.io/jq/tutorial/). + ## Hacking You can read the Hetzner Cloud API docs (e.g. [locations endpoint](https://docs.hetzner.cloud/#locations)). diff --git a/abra-hetzner b/abra-hetzner index 36f290a..32fed3e 100755 --- a/abra-hetzner +++ b/abra-hetzner @@ -108,6 +108,10 @@ declare -p "${prefix}__ssh_keys" "${prefix}__location" "${prefix}_name_" \ "${prefix}_type_" "${prefix}_image_"; done; } # docopt parser above, complete command for generating this parser is `docopt.sh abra-hetzner` +ABRA_DIR="${ABRA_DIR:-$HOME/.abra}" +ABRA_VENDOR_DIR="$ABRA_DIR/vendor" +JQ=$ABRA_VENDOR_DIR/jq" + abra_hetzner() { declare abra_hetzner__name_ abra_hetzner__type_ abra_hetzner__image_ \ abra_hetzner___ssh_keys abra_hetzner___location @@ -146,7 +150,7 @@ abra_hetzner() { }" \ 'https://api.hetzner.cloud/v1/servers') - ip=$(echo "$response" | jq -r ".server .public_net .ipv4 .ip") + ip=$(echo "$response" | $JQ -r ".server .public_net .ipv4 .ip") if [[ -n "$ip" ]]; then error_msg=$(echo "$response" | jq -r ".error .message")