#!/bin/sh

ver_new="$1"
ver_old="$2"

if [ "$(apk version -t "$ver_old" "4.1.0-r0")" = "<" ]; then
	cat >&2 <<-EOF
		*
		* The pgpool's configuration files were moved from /etc to /etc/pgpool.
		* Files /etc/pgpool.conf, /etc/pcp.conf and /etc/pg_hba.conf will be
		* automatically moved to the new location, if exists. However, you should
		* still check your configuration; pay attention to relative paths!
		*
	EOF

	for f in pgpool.conf pcp.conf pg_hba.conf; do
		if [ -f /etc/$f ] && ! [ -f /etc/pgpool/$f.apk-new ]; then
			mv -v /etc/$f /etc/pgpool/
		fi
	done
fi

if [ "$(apk version -t "$ver_old" "4.7.3-r0")" = "<" ]; then
	cat >&2 <<-EOF
		*
		* The new default pgpool.conf moves unix_socket_directories to /run/postgresql
		* (/tmp is kept for now, but will be dropped) and work_dir to /var/lib/pgpool.
		* Before restarting pgpool with the new work_dir, copy /tmp/pgpool_status
		* there, otherwise pgpool may go into split-brain.
		*
		* pgpool now logs to syslog instead of /var/log/pgpool/pgpool.log.
		* To log to a file again, set logfile in /etc/conf.d/pgpool,
		* log_destination = 'stderr' and log_line_prefix in pgpool.conf.
		*
	EOF
fi

exit 0
