2020-12-22 16:39:37 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
yq() {
|
2021-03-01 11:34:02 +01:00
|
|
|
docker run --rm -i -v "${PWD}:/workdir" mikefarah/yq:4 "$@"
|
2020-12-22 16:39:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
config()
|
|
|
|
{
|
|
|
|
echo -ne "Checking user... "
|
|
|
|
if [[ "$(whoami)" != "root" ]] && ! groups | grep docker
|
|
|
|
then
|
|
|
|
echo "Please add your current user to the docker group OR run this script as root."
|
|
|
|
echo "current user is not allowed to use docker, exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-03-01 11:34:02 +01:00
|
|
|
SERVICE="$(yq eval '.services.*.image | select(. == "sleede/fab-manager*") | path | .[-2]' docker-compose.yml)"
|
2021-05-18 09:40:35 +02:00
|
|
|
echo -e "\n"
|
2020-12-22 16:39:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
add_mount()
|
|
|
|
{
|
2021-03-08 12:08:17 +01:00
|
|
|
if [[ ! $(yq eval ".services.$SERVICE.volumes.[] | select (. == \"*payment_schedules\")" docker-compose.yml) ]]; then
|
|
|
|
# shellcheck disable=SC2016
|
|
|
|
# we don't want to expand ${PWD}
|
2022-05-16 18:08:20 +02:00
|
|
|
# change docker-compose.yml permissions for fix yq can't modify file issue
|
|
|
|
chmod 666 docker-compose.yml
|
2021-03-08 12:08:17 +01:00
|
|
|
yq -i eval ".services.$SERVICE.volumes += [\"\${PWD}/payment_schedules:/usr/src/app/payment_schedules\"]" docker-compose.yml
|
2022-05-16 18:08:20 +02:00
|
|
|
chmod 644 docker-compose.yml
|
2021-03-08 12:08:17 +01:00
|
|
|
fi
|
2020-12-22 16:39:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
proceed()
|
|
|
|
{
|
|
|
|
config
|
|
|
|
add_mount
|
|
|
|
}
|
|
|
|
|
|
|
|
proceed "$@"
|