mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
pgSQL upgrade script: check for postmaster.pid
This commit is contained in:
parent
11484d2fcc
commit
cbd93ca7d8
@ -39,10 +39,10 @@ config()
|
|||||||
then
|
then
|
||||||
if [ -f "$FM_PATH/config/application.yml" ]
|
if [ -f "$FM_PATH/config/application.yml" ]
|
||||||
then
|
then
|
||||||
PG_HOST=$(cat "$FM_PATH/config/application.yml" | grep POSTGRES_HOST | awk '{print $2}')
|
PG_HOST=$(grep POSTGRES_HOST "$FM_PATH/config/application.yml" | awk '{print $2}')
|
||||||
elif [ -f "$FM_PATH/config/env" ]
|
elif [ -f "$FM_PATH/config/env" ]
|
||||||
then
|
then
|
||||||
PG_HOST=$(cat "$FM_PATH/config/env" | grep POSTGRES_HOST | awk '{split($0,a,"="); print a[2]}')
|
PG_HOST=$(grep POSTGRES_HOST "$FM_PATH/config/env" | awk '{split($0,a,"="); print a[2]}')
|
||||||
else
|
else
|
||||||
echo "Fab-manager's environment file not found, please run this script from the installation folder"
|
echo "Fab-manager's environment file not found, please run this script from the installation folder"
|
||||||
exit 1
|
exit 1
|
||||||
@ -64,11 +64,11 @@ test_free_space()
|
|||||||
{
|
{
|
||||||
# checking disk space (minimum required = 1.2GB)
|
# checking disk space (minimum required = 1.2GB)
|
||||||
required=$(du -d 0 "$PG_PATH" | awk '{ print $1 }')
|
required=$(du -d 0 "$PG_PATH" | awk '{ print $1 }')
|
||||||
space=$(df $FM_PATH | awk '/[0-9]%/{print $(NF-2)}')
|
space=$(df "$FM_PATH" | awk '/[0-9]%/{print $(NF-2)}')
|
||||||
if [ "$space" -lt "$required" ]
|
if [ "$space" -lt "$required" ]
|
||||||
then
|
then
|
||||||
echo "Not enough free disk space to perform upgrade. Please free at least $required bytes of disk space and try again"
|
echo "Not enough free disk space to perform upgrade. Please free at least $required bytes of disk space and try again"
|
||||||
df -h $FM_PATH
|
df -h "$FM_PATH"
|
||||||
exit 7
|
exit 7
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -77,12 +77,16 @@ test_docker_compose()
|
|||||||
{
|
{
|
||||||
if [[ -f "$FM_PATH/docker-compose.yml" ]]
|
if [[ -f "$FM_PATH/docker-compose.yml" ]]
|
||||||
then
|
then
|
||||||
docker-compose ps | grep postgres
|
if [[ $(docker-compose ps | grep postgres) = 0 ]]
|
||||||
if [[ $? = 0 ]]
|
|
||||||
then
|
then
|
||||||
TYPE="DOCKER-COMPOSE"
|
TYPE="DOCKER-COMPOSE"
|
||||||
local container_id=$(docker-compose ps | grep postgre | awk '{print $1}')
|
local container_id, ip
|
||||||
PG_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container_id")
|
container_id=$(docker-compose ps | grep postgre | awk '{print $1}')
|
||||||
|
ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container_id")
|
||||||
|
if [ "$PG_IP" != "$ip" ]; then
|
||||||
|
puts "IP address is not matching, exiting..."
|
||||||
|
exit 8
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -110,6 +114,26 @@ prepare_path()
|
|||||||
docker_down()
|
docker_down()
|
||||||
{
|
{
|
||||||
docker-compose down
|
docker-compose down
|
||||||
|
ensure_pg_down
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_pg_down()
|
||||||
|
{
|
||||||
|
if [ -f "$PG_PATH/postmaster.pid" ]; then
|
||||||
|
echo 'ERROR: lock file "postmaster.pid" exists'
|
||||||
|
if [[ $(docker-compose ps | grep postgres) = 1 ]]; then
|
||||||
|
read -rp 'docker-compose container is not running. Confirm delete the lock file? (y/N) ' confirm </dev/tty
|
||||||
|
if [ "$confirm" = "y" ]; then
|
||||||
|
if [ "$(whoami)" = "root" ]; then COMMAND="rm"
|
||||||
|
else COMMAND="sudo rm"; fi
|
||||||
|
"$COMMAND" -f "$PG_PATH/postmaster.pid"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo 'docker-compose container is still running, retrying to stop...'
|
||||||
|
sleep 2
|
||||||
|
docker_down
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
pg_upgrade()
|
pg_upgrade()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user