From b5636f05aec9cb215b815e111933e0b65740d146 Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Sat, 5 Nov 2022 16:10:19 -0700 Subject: [PATCH] Add boot script --- server/scripts/boot.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 server/scripts/boot.sh diff --git a/server/scripts/boot.sh b/server/scripts/boot.sh new file mode 100644 index 0000000..98ebd6a --- /dev/null +++ b/server/scripts/boot.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Remove existing containers to ensure clean environment +for service in /home/joey/homelab/server/config/* +do + echo "CLEANING UP $service" + cd $service + docker-compose down +done + +# Check for good connection to NAS and shares mounted properly. +SMB_SHARES="/mnt/nas/av +/mnt/nas/backups +/mnt/nas/calibre +/mnt/nas/calibre-web +/mnt/nas/media +/mnt/nas/torrenting" + +for share in $SMB_SHARES; +do + if ! mount | awk -v DIR="$share" '{if ($3 == DIR) { exit 0}} ENDFILE{exit -1}'; then + echo "Share not mounted: $share" + exit 1 + fi +done + +echo "STARTING DOCKER SERVICES" +for service in /home/joey/homelab/server/config/* +do + echo "===== STARTING $service =====" + cd $service + docker-compose up -d +done + +echo "================ ALL DONE =================" +echo "======= List all running containers =======" + +# wish I didn't have to do this +# the exporters boot faster than the servers, and don't seem to retry. +wait 10 +docker container restart monitoring_exporter-plex +docker container restart keycloak_forwardauth \ No newline at end of file