diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ece307cf..d4f3b12f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Next release - Allow inserting hyperlinks in customized info messages +- Improved scripts for mounting volumes +- Increased verbosity of upgrade script +- Fix a bug: mounting the payment-schedules volume in the docker-compose file results in an invalid file ## v4.7.3 2021 March 03 - Improved the setup script diff --git a/scripts/mount-payment-schedules.sh b/scripts/mount-payment-schedules.sh index 7ad7a92e2..2bd354b71 100644 --- a/scripts/mount-payment-schedules.sh +++ b/scripts/mount-payment-schedules.sh @@ -18,9 +18,11 @@ config() add_mount() { - # 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 + 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() diff --git a/scripts/mount-webpack.sh b/scripts/mount-webpack.sh index 5dc9a2b7e..895891d2d 100644 --- a/scripts/mount-webpack.sh +++ b/scripts/mount-webpack.sh @@ -18,8 +18,10 @@ config() change_mount() { - yq -i eval ".services.$SERVICE.volumes.[] | select(. == \"*assets\") |= \"\${PWD}/public/packs:/usr/src/app/public/packs\"" docker-compose.yml - echo "Service volume was replaced for $SERVICE: /assets changed to /packs" + if [[ $(yq eval ".services.$SERVICE.volumes.[] | select (. == \"*assets\")" docker-compose.yml) ]]; then + yq -i eval ".services.$SERVICE.volumes.[] |= select(. == \"*assets\") |= \"\${PWD}/public/packs:/usr/src/app/public/packs\"" docker-compose.yml + echo "Service volume was replaced for $SERVICE: /assets changed to /packs" + fi } proceed() diff --git a/setup/upgrade.sh b/setup/upgrade.sh index 4075e4969..e6a865e46 100644 --- a/setup/upgrade.sh +++ b/setup/upgrade.sh @@ -87,6 +87,7 @@ add_environments() { for ENV in "${ENVIRONMENTS[@]}"; do if [[ "$ENV" =~ ^[A-Z0-9_]+=.*$ ]]; then + printf "Inserting variable %s...\n" "$ENV" printf "# added on %s\n%s\n" "$(date +%Y-%m-%d\ %R)" "$ENV" >> "config/env" else echo "Ignoring invalid option: -e $ENV. Given value is not valid environment variable, please see https://huit.re/environment-doc" @@ -125,6 +126,7 @@ upgrade() BRANCH='master' if yq eval '.services.*.image | select(. == "sleede/fab-manager*")' docker-compose.yml | grep -q ':dev'; then BRANCH='dev'; fi for SCRIPT in "${SCRIPTS[@]}"; do + printf "Running script %s from branch %s...\n" "$SCRIPT" "$BRANCH" if [[ "$YES_ALL" = "true" ]]; then \curl -sSL "https://raw.githubusercontent.com/sleede/fab-manager/$BRANCH/scripts/$SCRIPT.sh" | bash -s -- -y else @@ -134,6 +136,7 @@ upgrade() compile_assets docker-compose run --rm "$SERVICE" bundle exec rake db:migrate for COMMAND in "${COMMANDS[@]}"; do + printf "Running command %s...\n" "$COMMAND" docker-compose run --rm "$SERVICE" bundle exec "$COMMAND" done docker-compose up -d