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

configure pg_hba.conf after migration

This commit is contained in:
Sylvain 2019-10-09 11:02:43 +02:00
parent 13c730eaad
commit 9577ea6292
2 changed files with 25 additions and 2 deletions

View File

@ -6,8 +6,8 @@ Fab-manager release 4.2.0 has upgraded its dependency to PostgreSQL from version
To keep using fab-manager you need to upgrade your installation with the new version.
We've wrote a script to automate the process while keeping your data integrity, but there's some requirements to understand before running it.
- You need to install *curl* and *GNU awk* on your system before running the script.
Usually, `apt update && apt install curl gawk`, ran as root, will do the trick but this may change, depending upon your system.
- You need to install *curl*, *GNU awk* and *sudo* on your system before running the script.
Usually, `apt update && apt install curl gawk sudo`, ran as root, will do the trick but this may change, depending upon your system.
- A bit of free disk space is also required to perform the data migration.
The amount needed depends on your current database size, the script will check it and tell you if there's not enough available space.
- This script should run on any Linux or MacOS systems if you installed ElasticSearch using docker-compose.

View File

@ -7,6 +7,18 @@ config()
echo "It is not recommended to run this script as root. As a normal user, elevation will be prompted if needed."
read -rp "Continue anyway? (Y/n) " confirm </dev/tty
if [[ "$confirm" = "n" ]]; then exit 1; fi
else
if ! command -v sudo
then
echo "Please install and configure sudo before running this script."
echo "sudo was not found, exiting..."
exit 1
elif ! groups | grep sudo; then
echo "Please add your current user to the sudoers."
echo 'You can run the following as root: "usermod -aG sudo myuser"'
echo "sudo was not configured, exiting..."
exit 1
fi
fi
if ! command -v awk || ! [[ $(awk -W version) =~ ^GNU ]]
then
@ -109,9 +121,20 @@ upgrade_compose()
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
trust_pg_hba_conf
docker-compose up -d
}
trust_pg_hba_conf()
{
if [ "$(whoami)" = "root" ]; then COMMAND="tee"
else COMMAND="sudo tee"; fi
{
echo
echo "host all all all trust"
} | "$COMMAND" -a "$NEW_PATH/pg_hba.conf" > /dev/null
}
clean()
{
read -rp "Remove the previous PostgreSQL data folder? (y/N) " confirm </dev/tty