#!/bin/bash

source /opt/scripts_local/shared_functions.sh

CTRL_MODE=$1
DC_FILE=/opt/appdata/.docker-compose/docker-compose.yml

if [ "$CTRL_MODE" == "start" ]; then
    MY_CONTAINERS=(flaresolverr prowlarr qbt sabnzbd radarr sonarr bazarr)
    for MY_CONTAINER in "${MY_CONTAINERS[@]}"
    do
        cd /opt/appdata/ ; sudo docker-compose -f $DC_FILE up -d --force-recreate "$MY_CONTAINER"
        sleep 2
    done
elif [ "$CTRL_MODE" == "stop" ]; then
    MY_CONTAINERS=(bazarr sonarr radarr qbt sabnzb flaresolverr prowlarr)
    for MY_CONTAINER in "${MY_CONTAINERS[@]}"
    do
        cd /opt/appdata/ ; sudo docker-compose -f $DC_FILE stop "$MY_CONTAINER"
        sleep 2
    done
fi
