From df695525e9a6edd51dd8d5a0aa3f3b2ba33a7f0a Mon Sep 17 00:00:00 2001 From: "Gal@Shefet" Date: Tue, 9 May 2023 00:31:22 -0400 Subject: [PATCH] better handling of startup process --- delete-all-catalogs.sh | 5 +++ setup-catalog.sh | 5 +++ shut-down-procedure.sh | 3 +- start-all-charts.kateryna.sh | 57 ++++++++++++++++++++++++++ start-all-charts.sh | 78 +++++------------------------------- start-all-charts.wolfpack.sh | 29 ++++++++++++++ stop-all-chrats.sh | 5 +++ wait-for-idle-queue.sh | 22 ++++++++++ 8 files changed, 136 insertions(+), 68 deletions(-) create mode 100755 start-all-charts.kateryna.sh create mode 100755 start-all-charts.wolfpack.sh create mode 100755 wait-for-idle-queue.sh diff --git a/delete-all-catalogs.sh b/delete-all-catalogs.sh index bd78df4..036b293 100755 --- a/delete-all-catalogs.sh +++ b/delete-all-catalogs.sh @@ -1,4 +1,9 @@ #! /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_catalogs() { diff --git a/setup-catalog.sh b/setup-catalog.sh index deeb8ac..e5db370 100755 --- a/setup-catalog.sh +++ b/setup-catalog.sh @@ -1,4 +1,9 @@ #! /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 setup_catalog() { diff --git a/shut-down-procedure.sh b/shut-down-procedure.sh index 2445c1d..dd3e94e 100755 --- a/shut-down-procedure.sh +++ b/shut-down-procedure.sh @@ -7,5 +7,6 @@ USER_HOME=$HOME set -e ${SCRIPT_DIR}/delete-all-catalogs.sh +${SCRIPT_DIR}/wait-for-idle-queue.sh ${SCRIPT_DIR}/stop-all-chrats.sh - + \ No newline at end of file diff --git a/start-all-charts.kateryna.sh b/start-all-charts.kateryna.sh new file mode 100755 index 0000000..7534d38 --- /dev/null +++ b/start-all-charts.kateryna.sh @@ -0,0 +1,57 @@ +#! /usr/bin/env bash + +start_chart cloudflareddns +start_chart_category network +start_chart_category networking +start_chart_category authentication +start_chart uptime-kuma + +safe_start_chart plex-pms +safe_start_chart unifi + +start_chart homepage +start_chart it-tools +start_chart haste + +safe_start_chart shlink +start_chart shlink-frontend +safe_start_chart ferdi + +start_chart hammond +start_chart monica +start_chart languagetool +safe_start_chart paperless-ng +safe_start_chart gitea +safe_start_chart immich +safe_start_chart syncthing + +start_chart nzbget +start_chart deluge +start_chart prowlarr +safe_start_chart lunasea +safe_start_chart jdownloader +safe_start_chart calibre +safe_start_chart bazarr +safe_start_chart sonarr +safe_start_chart radarr +safe_start_chart tdarr + +# start_chart deepstack +# start_chart docker-compose +# start_chart firefox-syncserver +# start_chart gerev +# start_chart grocy +# start_chart homarr +# start_chart jellyfin +# start_chart jellyseerr +# start_chart mango +# start_chart plex-auto-languages +# start_chart portainer +# start_chart qbittorrent +# start_chart scratch-map +# start_chart silverbullet +# start_chart stash +# start_chart trilium-notes +# start_chart wger +# start_chart whoami + \ No newline at end of file diff --git a/start-all-charts.sh b/start-all-charts.sh index c980444..8fc5c6d 100755 --- a/start-all-charts.sh +++ b/start-all-charts.sh @@ -1,4 +1,9 @@ #! /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() { @@ -24,7 +29,7 @@ start_chart_category() { get_charts_by_category "$CATEGORY" | while read chart; do start_chart $chart done - wait_for_idle_queue + ${SCRIPT_DIR}/wait-for-idle-queue.sh } start_chart() { @@ -38,74 +43,13 @@ count_unfinished_jobs() { midclt call core.get_jobs | jq -r '.[] | select( .time_finished == null )' | wc -l } -wait_for_idle_queue() { - while [[ "$( count_unfinished_jobs )" -gt 0 ]]; do - printf '.' - sleep 2 - done - printf '\n' -} - safe_start_chart() { - wait_for_idle_queue + ${SCRIPT_DIR}/wait-for-idle-queue.sh start_chart "${1}" } -wait_for_idle_queue -start_chart cloudflareddns -start_chart_category network -start_chart_category networking -start_chart_category authentication -start_chart uptime-kuma - -safe_start_chart plex-pms -safe_start_chart unifi - -start_chart homepage -start_chart it-tools -start_chart haste - -safe_start_chart shlink -start_chart shlink-frontend -safe_start_chart ferdi - -start_chart hammond -start_chart monica -start_chart languagetool -safe_start_chart paperless-ng -safe_start_chart gitea -safe_start_chart immich -safe_start_chart syncthing - -start_chart nzbget -start_chart deluge -start_chart prowlarr -safe_start_chart lunasea -safe_start_chart jdownloader -safe_start_chart calibre -safe_start_chart bazarr -safe_start_chart sonarr -safe_start_chart radarr -safe_start_chart tdarr - -# start_chart deepstack -# start_chart docker-compose -# start_chart firefox-syncserver -# start_chart gerev -# start_chart grocy -# start_chart homarr -# start_chart jellyfin -# start_chart jellyseerr -# start_chart mango -# start_chart plex-auto-languages -# start_chart portainer -# start_chart qbittorrent -# start_chart scratch-map -# start_chart silverbullet -# start_chart stash -# start_chart trilium-notes -# start_chart wger -# start_chart whoami - -wait_for_idle_queue +${SCRIPT_DIR}/wait-for-idle-queue.sh +source "${SCRIPT_DIR}/start-all-charts.$(hostname).sh" +${SCRIPT_DIR}/wait-for-idle-queue.sh + \ No newline at end of file diff --git a/start-all-charts.wolfpack.sh b/start-all-charts.wolfpack.sh new file mode 100755 index 0000000..b9de3a2 --- /dev/null +++ b/start-all-charts.wolfpack.sh @@ -0,0 +1,29 @@ +#! /usr/bin/env bash + +#wireguard +#vaultwarden +#whoami + +safe_start_chart plex + +safe_start_chart cloudflareddns +start_chart_category network +start_chart_category networking +start_chart_category authentication +start_chart uptime-kuma + +safe_start_chart zwavejs2mqtt +safe_start_chart unifi + +start_chart homepage +safe_start_chart organizr + +start_chart deluge +start_chart prowlarr +#safe_start_chart bazarr +safe_start_chart sonarr +safe_start_chart radarr +safe_start_chart lidarr + +safe_start_chart overseerr + \ No newline at end of file diff --git a/stop-all-chrats.sh b/stop-all-chrats.sh index afc89a0..b89eaca 100755 --- a/stop-all-chrats.sh +++ b/stop-all-chrats.sh @@ -1,4 +1,9 @@ #! /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() { diff --git a/wait-for-idle-queue.sh b/wait-for-idle-queue.sh new file mode 100755 index 0000000..b5a9c30 --- /dev/null +++ b/wait-for-idle-queue.sh @@ -0,0 +1,22 @@ +#! /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 + +count_unfinished_jobs() { + midclt call core.get_jobs | jq -r '.[] | select( .time_finished == null )' | wc -l +} + +wait_for_idle_queue() { + while [[ "$( count_unfinished_jobs )" -gt 0 ]]; do + printf '.' + sleep 2 + done + printf '\n' +} + +wait_for_idle_queue + \ No newline at end of file