1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-10 21:24:20 +01:00
fab-manager/scripts/mount-payment-schedules.sh
Sylvain 303c0a0ba8 [bug] script to mount payment-schedules volume results in invalid yml file
+ improved scripts for mounting volumes
+ increased verbosity of upgrade script
2021-03-08 12:08:29 +01:00

35 lines
882 B
Bash

#!/usr/bin/env bash
yq() {
docker run --rm -i -v "${PWD}:/workdir" mikefarah/yq:4 "$@"
}
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
SERVICE="$(yq eval '.services.*.image | select(. == "sleede/fab-manager*") | path | .[-2]' docker-compose.yml)"
}
add_mount()
{
if [[ ! $(yq eval ".services.$SERVICE.volumes.[] | select (. == \"*payment_schedules\")" docker-compose.yml) ]]; then
# shellcheck disable=SC2016
# we don't want to expand ${PWD}
yq -i eval ".services.$SERVICE.volumes += [\"\${PWD}/payment_schedules:/usr/src/app/payment_schedules\"]" docker-compose.yml
fi
}
proceed()
{
config
add_mount
}
proceed "$@"