File: postgresql.config.in

package info (click to toggle)
postgresql 7.4.7-6sarge6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 11,168 kB
  • ctags: 27
  • sloc: sh: 1,903; makefile: 337; ansic: 204; perl: 69; sed: 6; tcl: 1
file content (152 lines) | stat: -rw-r--r-- 4,260 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/sh -e

# Source debconf library.
. /usr/share/debconf/confmodule

check_pg_hba_conf() {
    # Check the format of pg_hba.conf: does it need converting?
    # Uncommented lines used to match
    #  local  [database]   [method]
    # or
    #  host   [database]   [address]  [mask]  [method]
    # and any such must have a [user] field added after [database]
    if grep -qsE '^[ 	]*local[ 	]+[^ 	]*[ 	]+(trust|ident|reject|md5|password|crypt|krb5|pam)' /etc/postgresql/pg_hba.conf
    then
	return 1
    else
	:
    fi
    if grep -qsE '^[ 	]*(host|hostssl)[ 	]+[^ 	]+[ 	]+[^ 	]+[ 	]+[^/ 	]+[ 	]+(trust|ident|reject|md5|password|crypt|krb5|pam)' /etc/postgresql/pg_hba.conf
    then
	return 1
    else
	:
    fi
    return 0
}

#######################################################################
#                       Execution starts here                         #
#######################################################################

if [ "$1" = configure -o "$1" = reconfigure ]
then
    if [ -n "$2" ]
    then
	# this is an upgrade from a previous version or a reinstall
	if dpkg --compare-versions $2 lt 7.2
	then
	    db_input high postgresql/very_old_version_warning || true
	    db_go
	fi
    fi

    # See if pg_hba.conf needs converting
    if ! check_pg_hba_conf
    then
	db_input low postgresql/convert-pg_hba.conf || true
	db_go
    fi

    # on new installs, ask user for database directory $PGDATA
    if [ ! -f /etc/postgresql/postmaster.conf ]
    then
	db_subst postgresql/initdb/location PGDATALOC "${PGDATA:=/var/lib/postgres/data}"
	db_input medium postgresql/initdb/location || true
	db_get postgresql/initdb/location || true
	PGDATA="$RET"
    else
    # we are upgrading from a previous installation, find out PGDATA
        . /etc/postgresql/postmaster.conf
	PGDATA="$POSTGRES_DATA"
    fi
    if [ -z "$PGDATA" ]; then
	PGDATA="/var/lib/postgres/data"
    fi

    db_input medium postgresql/purge_data_too || true
    db_go

    # determine default value of PGLANG
    db_fget postgresql/settings/day_month_order seen || true
    if [ "$RET" = "true" ]; then
	db_get postgresql/settings/locale
	PGLANG="$RET"
    else
	if [ -r "$PGDATA/global/pg_control" -a -x /usr/lib/postgresql/bin/pg_controldata ]
	then
	    PGLANG=`/usr/lib/postgresql/bin/pg_controldata "$PGDATA" | grep LC_COLLATE | awk '{print $2}'`
	else
	    if [ -r /etc/environment ]
	    then
		. /etc/environment
		PGLANG=${LC_COLLATE:-${LC_TYPE:-${LC_ALL:-${LANG}}}}
	    else
		PGLANG=C
	    fi
	fi

	# set default value
	db_set postgresql/settings/locale "$PGLANG"
    fi

    # Available locales
    CHOICES=C
    langs=`locale -a` || true
    if [ -n "$langs" ]
    then
	for lng in $langs
	do
	    if [ "$lng" != C -a "$lng" != POSIX ]; then
		CHOICES="$CHOICES, $lng"
	    fi
	done

	# Ensure that PGLANG is in choices; it might be written differently
	if ! echo "$CHOICES" | grep -Fq "$PGLANG"; then
	    CHOICES="$CHOICES, $PGLANG"
	fi
    fi

    db_subst postgresql/settings/locale CURRENT_LOCALE_LIST "$CHOICES"
    db_input medium postgresql/settings/locale || true
    db_go

    # Guess the postgresql date order from the PGLANG setting if question
    # is new
    db_fget postgresql/settings/day_month_order seen || true
    if [ "$RET" != "true" ]
    then
	db_get postgresql/settings/locale || true
	D=`env LC_TIME=$RET date -d "January 30 2000" +%x | cut -c 1-2` || true
	if [ "$D" = "01" ]
	then
	    db_set postgresql/settings/day_month_order US
	else
	    db_set postgresql/settings/day_month_order European
	fi
	db_input medium postgresql/settings/day_month_order || true
    fi

    db_go

    # when upgrade is needed, ask for policy and paths
    if [ -f "$PGDATA/PG_VERSION" ] && [ "`cat \"${PGDATA}/PG_VERSION\" 2>/dev/null`" != %PG_VERSION% ]
    then
	# ask for upgrading dump directories
	db_set postgresql/upgrade/dump_location "/var/lib/postgres/"
	PARENT="`dirname \"$PGDATA\"`"
	db_set postgresql/upgrade/preserve_location "$PARENT/preserve"

	db_input medium postgresql/upgrade/policy || true
	db_go

	db_get postgresql/upgrade/policy
	if [ "$RET" = true ]
	then
	    db_input medium postgresql/upgrade/dump_location || true
	    db_input medium postgresql/upgrade/preserve_location || true
	    db_go
	fi
    fi
fi