Skip to content

Commit

Permalink
FIX: attempt the postgresql update if a stale socket file exists (#935)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaniki-wairungu authored Feb 3, 2025
1 parent ad89eb3 commit 98f470f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions templates/postgres.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ run:
chmod: "+x"
contents: |
#!/bin/bash
run_upgrade_postgres() {
if [ -f /root/upgrade_postgres ]; then
unset RETCODE
/root/upgrade_postgres || RETCODE=$?
[ -z "${RETCODE}" ] && rm /root/upgrade_postgres || exit $RETCODE
fi
exit 0
}
sed -i "s/^# $LANG/$LANG/" /etc/locale.gen
locale-gen && update-locale
mkdir -p /shared/postgres_run
Expand All @@ -58,7 +66,7 @@ run:
rm -fr /var/run/postgresql
ln -s /shared/postgres_run /var/run/postgresql
if [ -e /shared/postgres_run/.s.PGSQL.5432 ]; then
socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || exit 0 && echo postgres already running stop container ; exit 1
socat /dev/null UNIX-CONNECT:/shared/postgres_run/.s.PGSQL.5432 || run_upgrade_postgres && echo postgres already running stop container ; exit 1
fi
rm -fr /shared/postgres_run/.s*
rm -fr /shared/postgres_run/*.pid
Expand All @@ -70,11 +78,8 @@ run:
sudo -E -u postgres /usr/lib/postgresql/15/bin/initdb -D /shared/postgres_data
chown -R postgres:postgres /shared/postgres_data
chown -R postgres:postgres /var/run/postgresql
elif [ -f /root/upgrade_postgres ]; then
unset RETCODE
/root/upgrade_postgres || RETCODE=$?
[ -z "${RETCODE}" ] && rm /root/upgrade_postgres || exit $RETCODE
fi
run_upgrade_postgres
# Necessary to enable backups
install -d -m 0755 -o postgres -g postgres /shared/postgres_backup
Expand Down

0 comments on commit 98f470f

Please sign in to comment.