mtes-geomatique/posttemplate/10-postgres

38 lines
1.0 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
OLD_VERS="10"
NEW_VERS="11"
if ! [ -x /usr/bin/pg_dropcluster ];then
exit 0
fi
NEW_PACKAGES="$(dpkg-query -W -f='${Package}\t${Status}\n' postgresql*-${NEW_VERS} | awk '/ok installed/ {print $1}')"
OLD_PACKAGES="$(dpkg-query -W -f='${Package}\t${Status}\n' postgresql*-${OLD_VERS} | awk '/ok installed/ {print $1}')"
# Si les deux versions (10 et 11) sont présente, on lance la migration et on supprime la version 10
if [ -n "${OLD_PACKAGES}" ] && [ -n "${NEW_PACKAGES}" ]; then
echo "POUET"
exit 0
# Démarrage du service
systemctl start postgresql
# Suppression du cluster 11 créé automatiquement
pg_dropcluster --stop ${NEW_VERS} main
# Mise à niveau du cluster avec pg_upgradecluster 10 main
pg_upgradecluster -v ${NEW_VERS} ${OLD_VERS} main
# suppression du cluster 10
pg_dropcluster --stop ${OLD_VERS} main
# sassurer que postgresql est démarré
systemctl start postgresql
# désintallation de postgresql 10
apt-eole remove ${OLD_PACKAGES}
fi
exit 0