1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

fix upgrade_compose awk script

This commit is contained in:
Sylvain 2019-10-08 16:28:15 +02:00
parent cc55039286
commit a9a89e8ba3

View File

@ -99,11 +99,9 @@ upgrade_compose()
echo -e "\nUpgrading docker-compose installation from $OLD to $NEW..."
docker-compose stop postgres
docker-compose rm -f postgres
local image="postgres:$NEW"
sed -i.bak "s/image: postgres:$OLD/image: postgres:$NEW/g" "$FM_PATH/docker-compose.yml"
# insert configuration directory into docker-compose bindings
awk "BEGIN { FS=\"\n\"; RS=\"\"; } { print gensub(/(image: postgres:$NEW(\n|.)+volumes:)/, \"\\\\1\n - ${NEW_PATH}:/var/lib/postgresql/data\", \"g\") }" "$FM_PATH/docker-compose.yml" > "$FM_PATH/.awktmpfile" && mv "$FM_PATH/.awktmpfile" "$FM_PATH/docker-compose.yml"
# update image tag and data directory into docker-compose file
awk "BEGIN { FS=\"\n\"; RS=\"\"; } { print gensub(/(image: postgres:$OLD(\n|.)+volumes:(\n|.)+(-.*postgresql\/data))/, \"image: postgres:$NEW\n volumes:\n - ${NEW_PATH}:/var/lib/postgresql/data\", \"g\") }" "$FM_PATH/docker-compose.yml" > "$FM_PATH/.awktmpfile" && mv "$FM_PATH/.awktmpfile" "$FM_PATH/docker-compose.yml"
docker-compose pull
docker-compose up -d