#! /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_charts() { midclt call chart.release.query | jq -r " .[] | select( ${FILTER:-.status == \"STOPPED\"} ) | .id " | sort -u } get_charts_by_category() { local CATEGORY="${1}" midclt call chart.release.query | jq -r ' .[] | select ( .chart_metadata.annotations."truecharts.org/catagories" == "- '"$CATEGORY"'\n" ) | .id ' } start_chart_category() { local CATEGORY="${1}" printf "Starting apps by category: %s\n" "$CATEGORY" get_charts_by_category "$CATEGORY" | while read chart; do start_chart $chart done wait-for_idle_queue } start_chart() { local CHART="${1}" printf 'Starting charts: %s... ' "$CHART" midclt call chart.release.scale "$CHART" '{"replica_count": 1}' printf '\n' } if [[ -z "$1" ]]; then get_charts exit 2 fi ${SCRIPT_DIR}/wait-for-idle-queue.sh start_chart "${1}" ${SCRIPT_DIR}/wait-for-idle-queue.sh