truestuff/delete-all-catalogs.sh

25 lines
607 B
Bash
Raw Normal View History

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}")"
. ${SHRC_D:-$USER_HOME/.pqb.shrc.d}/01_util.functions
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