aboutsummaryrefslogtreecommitdiffhomepage
path: root/files/fetch_keys.sh
diff options
context:
space:
mode:
Diffstat (limited to 'files/fetch_keys.sh')
-rwxr-xr-xfiles/fetch_keys.sh22
1 files changed, 22 insertions, 0 deletions
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 @@
1#!/usr/bin/env bash
2
3set -euo pipefail
4
5BASE_URL="$1"
6TOKEN="$2"
7BASE_PATH="$3"
8
9list_path_rec() {
10 path="$1"
11 result=$(curl -ks "$BASE_URL/storage/$path?authtoken=$TOKEN")
12
13 case "$(echo "$result" | jq -r .type)" in
14 "file") echo "$result" | jq -r .path | sed -e "s@^$BASE_PATH/@@"
15 ;;
16 "directory")
17 echo "$result" | jq -r ".resources[]|.path" | while read p; do list_path_rec "$p"; done
18 ;;
19 esac
20}
21
22list_path_rec "$BASE_PATH"