#! /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/.pqb.shrc.d}/01_util.functions set -e get_charts() { midclt call chart.release.query | jq -r ' .[] | select( .status == "STOPPED" ) | .id ' } 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 ${SCRIPT_DIR}/wait-for-idle-queue.sh } start_chart() { local CHART="${1}" printf 'Starting charts: %s... ' "$CHART" midclt call chart.release.scale "$CHART" '{"replica_count": 1}' printf '\n' } count_unfinished_jobs() { midclt call core.get_jobs | jq -r '.[] | select( .time_finished == null )' | wc -l } safe_start_chart() { ${SCRIPT_DIR}/wait-for-idle-queue.sh start_chart "${1}" } ${SCRIPT_DIR}/wait-for-idle-queue.sh source "${SCRIPT_DIR}/start-all-charts.$(hostname).sh" ${SCRIPT_DIR}/wait-for-idle-queue.sh