2021-05-28 14:09:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-12-13 09:36:47 +00:00
|
|
|
# The dc command is an alias to docker-compose which also scans the current portal configuration (as defined in .env)
|
|
|
|
# and selects the right docker-compose files to include in the operation. You can use the command in the same way you
|
|
|
|
# would use docker-compose with the only difference being that you don't need to specify compose files. For more
|
|
|
|
# information you can run `./dc` or `./dc help`.
|
|
|
|
|
2022-08-12 19:06:04 +00:00
|
|
|
# get current working directory of this script and prefix all files with it to
|
|
|
|
# be able to call this script from anywhere and not only root directory of
|
|
|
|
# skynet-webportal project
|
2022-08-11 21:29:27 +00:00
|
|
|
cwd="$(dirname -- "$0";)";
|
|
|
|
|
2022-08-12 19:06:04 +00:00
|
|
|
# get portal modules configuration from .env file (if defined more than once, the last one is used)
|
2022-08-16 08:36:54 +00:00
|
|
|
if [[ -f "${cwd}/.env" ]]; then
|
|
|
|
PORTAL_MODULES=$(grep -e "^PORTAL_MODULES=" ${cwd}/.env | tail -1 | sed "s/PORTAL_MODULES=//")
|
|
|
|
fi
|
2021-05-28 14:09:45 +00:00
|
|
|
|
2021-05-28 15:55:15 +00:00
|
|
|
# include base docker compose file
|
2022-08-11 21:29:27 +00:00
|
|
|
COMPOSE_FILES="-f ${cwd}/docker-compose.yml"
|
2021-05-28 15:55:15 +00:00
|
|
|
|
2021-05-28 14:09:45 +00:00
|
|
|
for i in $(seq 1 ${#PORTAL_MODULES}); do
|
|
|
|
# accounts module - alias "a"
|
2021-05-31 12:36:47 +00:00
|
|
|
if [[ ${PORTAL_MODULES:i-1:1} == "a" ]]; then
|
2022-08-11 21:29:27 +00:00
|
|
|
COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.accounts.yml"
|
2021-05-28 14:09:45 +00:00
|
|
|
fi
|
|
|
|
|
2021-12-01 10:02:55 +00:00
|
|
|
# blocker module - alias "b"
|
|
|
|
if [[ ${PORTAL_MODULES:i-1:1} == "b" ]]; then
|
2022-08-11 21:29:27 +00:00
|
|
|
COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.blocker.yml"
|
2021-12-01 10:02:55 +00:00
|
|
|
fi
|
|
|
|
|
2021-05-28 14:09:45 +00:00
|
|
|
# jaeger module - alias "j"
|
2021-05-31 12:36:47 +00:00
|
|
|
if [[ ${PORTAL_MODULES:i-1:1} == "j" ]]; then
|
2022-08-11 21:29:27 +00:00
|
|
|
COMPOSE_FILES+=" -f ${cwd}/docker-compose.jaeger.yml"
|
2021-05-28 14:09:45 +00:00
|
|
|
fi
|
2021-10-07 09:43:09 +00:00
|
|
|
|
2021-11-09 17:04:05 +00:00
|
|
|
# malware-scanner module - alias "s"
|
|
|
|
if [[ ${PORTAL_MODULES:i-1:1} == "s" ]]; then
|
2022-08-11 21:29:27 +00:00
|
|
|
COMPOSE_FILES+=" -f ${cwd}/docker-compose.blocker.yml -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.malware-scanner.yml"
|
2021-11-09 17:04:05 +00:00
|
|
|
fi
|
|
|
|
|
2021-12-14 07:39:46 +00:00
|
|
|
# mongodb module - alias "m"
|
2021-10-07 09:43:09 +00:00
|
|
|
if [[ ${PORTAL_MODULES:i-1:1} == "m" ]]; then
|
2022-08-11 21:29:27 +00:00
|
|
|
COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml"
|
2021-10-07 09:43:09 +00:00
|
|
|
fi
|
2021-12-20 12:15:28 +00:00
|
|
|
|
2022-02-24 12:16:30 +00:00
|
|
|
# abuse-scanner module - alias "u"
|
2021-12-20 12:15:28 +00:00
|
|
|
if [[ ${PORTAL_MODULES:i-1:1} == "u" ]]; then
|
2022-08-11 21:29:27 +00:00
|
|
|
COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.blocker.yml -f ${cwd}/docker-compose.abuse-scanner.yml"
|
2021-12-20 12:15:28 +00:00
|
|
|
fi
|
2022-05-10 15:13:50 +00:00
|
|
|
|
|
|
|
# pinner module - alias "p"
|
|
|
|
if [[ ${PORTAL_MODULES:i-1:1} == "p" ]]; then
|
2022-08-11 21:29:27 +00:00
|
|
|
COMPOSE_FILES+=" -f ${cwd}/docker-compose.mongodb.yml -f ${cwd}/docker-compose.pinner.yml"
|
2022-05-10 15:13:50 +00:00
|
|
|
fi
|
2021-05-28 14:09:45 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# override file if exists
|
2021-05-31 12:36:47 +00:00
|
|
|
if [[ -f docker-compose.override.yml ]]; then
|
2022-08-11 21:29:27 +00:00
|
|
|
COMPOSE_FILES+=" -f ${cwd}/docker-compose.override.yml"
|
2021-05-28 14:09:45 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
docker-compose $COMPOSE_FILES $@
|