2023-05-09 03:08:59 +00:00
|
|
|
#! /usr/bin/env bash
|
2023-05-09 04:31:22 +00:00
|
|
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
|
|
USER_HOME=$HOME
|
|
|
|
[[ -n "${SUDO_USER}" ]] && USER_HOME="$(eval "echo ~${SUDO_USER}")"
|
2023-07-12 03:17:21 +00:00
|
|
|
. ${SHRC_D:-$SCRIPT_DIR}/01_util.functions
|
2023-05-09 04:31:22 +00:00
|
|
|
|
2023-05-09 03:08:59 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
get_catalogs() {
|
|
|
|
midclt call catalog.query | jq -r '.[] | .label' | grep -v 'OFFICIAL'
|
|
|
|
}
|
|
|
|
|
|
|
|
delete_catalog() {
|
|
|
|
local CATALOG="${1}"
|
|
|
|
printf 'Deleting catalog: %s... ' "$CATALOG"
|
|
|
|
midclt call catalog.delete "$CATALOG"
|
|
|
|
printf '\n'
|
|
|
|
}
|
|
|
|
|
|
|
|
get_catalogs | while read catalog; do
|
|
|
|
[[ -n "$catalog" ]] || continue
|
|
|
|
delete_catalog "$catalog"
|
|
|
|
done
|
|
|
|
|