From d58fd11546cd378ff4eba6227adc10f8c06c386a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Fri, 25 Feb 2022 18:14:29 +0100 Subject: Add an option to remove existing keys that are not declared in ansible --- files/fetch_keys.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 files/fetch_keys.sh (limited to 'files') diff --git a/files/fetch_keys.sh b/files/fetch_keys.sh new file mode 100755 index 0000000..e15dc12 --- /dev/null +++ b/files/fetch_keys.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -euo pipefail + +BASE_URL="$1" +TOKEN="$2" +BASE_PATH="$3" + +list_path_rec() { + path="$1" + result=$(curl -ks "$BASE_URL/storage/$path?authtoken=$TOKEN") + + case "$(echo "$result" | jq -r .type)" in + "file") echo "$result" | jq -r .path | sed -e "s@^$BASE_PATH/@@" + ;; + "directory") + echo "$result" | jq -r ".resources[]|.path" | while read p; do list_path_rec "$p"; done + ;; + esac +} + +list_path_rec "$BASE_PATH" -- cgit v1.2.3