25 lines
606 B
Bash
Executable File
25 lines
606 B
Bash
Executable File
#! /usr/bin/env bash
|
|
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/.sz.shrc.d}/01_util.functions
|
|
|
|
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
|
|
|