#!/bin/bash
echo "Mount encrypted filesystems before running this script."
echo "Unlock scripts is located at nextcloud directory."

CONTAINER_ROOT="/home/laxaurus/docker"
#
#
#### 2023-07-29 disabled synapse and matrix
#CONTAINERS_UP=(jupyter gogs sslwp ftp nu_nc squid transmission transmission-sbt transmission-gm minidlna calibre ampache prometheus guacamole mediawiki torproxy6 samba synapse element jellyfin openvpn wireguard stackedit docker-registry baidu syncthing)
CONTAINERS_UP=(jupyter gogs sslwp ftp nu_nc squid transmission transmission-sbt transmission-gm minidlna calibre ampache prometheus guacamole mediawiki torproxy6 samba jellyfin openvpn wireguard stackedit docker-registry baidu syncthing)
CONTAINERS_DOWN=(jupyter gogs ftpd squid transmission transmission-sbt transmission-gm minidlna calibre calibre-web ampache prometheus nu_nc nu_nc_db nu_nc_redis nu_nc_onlyoffice nu_nc_clamav nu_nc_es monitoring_grafana cadvisor redis node-exporter sslwp_https-portal sslwp_web sslwp_php mwiki mwiki_mysql mwiki_parsoid mwiki_es guaca guaca_db guaca_cd torproxy6 samba element synapse_app_1 synapse_ma1sd_1 jellyfin openvpn openvpn-admin downloader-exporter-bt wireguard stackedit stackedit_couchdb_1 docker-registry docker-registry-ui baidupan syncthing) 


if [[ $1 == "up" ]]
then
	for i in "${CONTAINERS_UP[@]}"
		do
			CONTAINER_DIR="$CONTAINER_ROOT/${i}" 
		        echo "starting container ${i} at $CONTAINER_DIR..."
			env $(cat $CONTAINER_DIR/.env | grep "#" -v) docker-compose -f $CONTAINER_DIR/docker-compose.yml up -d 

		done
elif [[ $1 == "down" ]]
then

	for i in "${CONTAINERS_DOWN[@]}"
		do
			echo "stopping container ${i}..."
			docker stop "${i}"
                        
		done
else
	echo "$0: allowed options: {up|down}"
	exit -1

fi

