# copy postgresql.conf
#
# * input
-# Nothing
+# arg1: PostgreSQL major version number
+# arg2: PostgreSQL minor version number
#
# * output
-# 0: Success
-# 1: Failure
+# 0: Success
+# 1: Failure
#
copy_postgresql_conf()
{
+ local major=$1
+ local minor=$2
+
+ # Determine parameter that specifies UNIX domain socket path.
+ local uds
+ if [ "$major" -gt 9 -o \( "$major" -eq 9 -a "$minor" -ge 3 \) ]; then
+ uds="unix_socket_directories"
+ else
+ uds="unix_socket_directory"
+ fi
+
+ # Update postgresql.conf.
+ local tmp="${POSTFILE}_tmp.$$"
+ sed -e "s,%unix_socket_directory%,$uds," $SINGLEPOSTFILE > $tmp
+ if [ $? -ne 0 ]; then
+ rm -f $tmp
+ return 1
+ fi
+
# Install postgresql.conf.
- copy_postgresql_file $SINGLEPOSTFILE $POSTFILE || return 1
+ copy_postgresql_file $tmp $POSTFILE
+ local status=$?
+ rm -f $tmp
+
+ return $status
}
# create_setting_file()
runas_suuser "$PGINST/bin/initdb -D $PGDATA -U $PGUSER \
-E UNICODE --no-locale" > /dev/null 2> $TMPLOGFILE
[ $? -ne 0 ] && db_setup_error initdb
- copy_postgresql_conf 2> $TMPLOGFILE
+ copy_postgresql_conf $PGSQL_MAJOR $PGSQL_MINOR 2> $TMPLOGFILE
[ $? -ne 0 ] && data_copy_error
# Start PostgreSQL.
# 0: Success
# 1: The given command cannot be used.
#
+# Major and minor version are set to PGSQL_MAJOR and PGSQL_MINOR
+# respectively.
+#
check_pgsql_version()
{
[ -x "$1" ] || return 1
[ -z "$vstr" ] && return 1
log_output $$ INFO $0 "$1 --version: $vstr" $LOGFILE
- # Check major version.
- local maj=`echo $vstr |
+ # Determine version.
+ PGSQL_MAJOR=`echo $vstr |
sed -e 's/^.*(PostgreSQL) \([0-9]\{1,\}\)\..*$/\1/'`
- [ -z "$maj" ] && return 1
- [ "$maj" -lt $PGSQL_VERSION_MAJOR ] && return 1
- [ "$maj" -gt $PGSQL_VERSION_MAJOR ] && return 0
- [ -z "$PGSQL_VERSION_MINOR" ] && return 0
+ [ -z "$PGSQL_MAJOR" ] && return 1
+ PGSQL_MINOR=`echo $vstr |
+ sed -e 's/^.*(PostgreSQL) [0-9]\{1,\}\.\([0-9]\{1,\}\)\(\.[0-9]\{1,\}\)\{0,1\}$/\1/'`
+ [ -z "$PGSQL_MINOR" ] && return 1
+
+ # Check major version.
+ [ "$PGSQL_MAJOR" -lt $PGSQL_VERSION_MAJOR ] && return 1
+ [ "$PGSQL_MAJOR" -gt $PGSQL_VERSION_MAJOR ] && return 0
# Check minor version.
- local min=`echo $vstr |
- sed -e 's/^.*(PostgreSQL) [0-9]\{1,\}\.\([0-9]\{1,\}\)\(\.[0-9]\{1,\}\)\{0,1\}$/\1/'`
- [ -z "$min" ] && return 1
- [ "$min" -lt "$PGSQL_VERSION_MINOR" ] && return 1
+ [ -z "$PGSQL_VERSION_MINOR" ] && return 0
+ [ "$PGSQL_MINOR" -lt "$PGSQL_VERSION_MINOR" ] && return 1
return 0
}