Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: attempt the postgresql update if a stale socket file exists #935

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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