adds up and down

This commit is contained in:
Llewellyn van der Merwe 2021-06-20 21:01:18 +02:00
parent 9988d9c3fb
commit 6dc2131558
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C
2 changed files with 45 additions and 0 deletions

18
src/down.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
# check that our enabled containers path is correct
[ -e "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled" ] || {
echo "[error] Enabled containers path ${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled does not exist. This means no container is enabled."
exit 1
}
# the main function
main() {
# get all zip files
for yml in "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/"*/*.yml; do
docker-compose --file "${yml}" down
done
}
# run main
main

27
src/up.sh Normal file
View File

@ -0,0 +1,27 @@
#!/bin/bash
# check that our repository path is correct
[ -e "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled" ] || {
echo "[error] Repository path (${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled) does not exist, first enable some containers."
exit 1
}
# check that our projects path is correct
[ -e "${VDM_PROJECT_PATH}" ] || {
echo "[error] Projects path (${VDM_PROJECT_PATH}) does not exist."
exit 1
}
# the main function
main() {
# get all zip files
for yml in "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/"*/*.yml; do
# get the vdm_container value
vdm_container="${yml%/docker-compose.yml}"
# check if image has its own env file also
[ -f "${vdm_container}/.env" ] && ENV_FILE="${vdm_container}/.env" || ENV_FILE="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env"
docker-compose --env-file "${ENV_FILE}" --file "${yml}" up -d
done
}
# run main
main