truestuff/start-all-charts.sh

55 lines
1.3 KiB
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_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
2023-05-09 04:31:22 +00:00
${SCRIPT_DIR}/wait-for-idle-queue.sh
2023-05-09 03:08:59 +00:00
}
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() {
2023-05-09 04:31:22 +00:00
${SCRIPT_DIR}/wait-for-idle-queue.sh
2023-05-09 03:08:59 +00:00
start_chart "${1}"
}
2023-05-09 04:31:22 +00:00
${SCRIPT_DIR}/wait-for-idle-queue.sh
source "${SCRIPT_DIR}/start-all-charts.$(hostname).sh"
2023-05-09 03:08:59 +00:00
2023-05-09 04:31:22 +00:00
${SCRIPT_DIR}/wait-for-idle-queue.sh