Gentoo Archives: gentoo-commits

From: "Aaron Swenson (titanofold)" <titanofold@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-db/postgresql/files: postgresql.init-pre_9.2 postgresql.service postgresql-check-db-dir postgresql.confd postgresql.init postgresql.tmpfilesd
Date: Sun, 28 Dec 2014 18:07:27
Message-Id: 20141228180722.324C9E5DB@oystercatcher.gentoo.org
1 titanofold 14/12/28 18:07:22
2
3 Added: postgresql.init-pre_9.2 postgresql.service
4 postgresql-check-db-dir postgresql.confd
5 postgresql.init postgresql.tmpfilesd
6 Log:
7 Eliminate the patch, initscript, and systemd tarball maintained out
8 of tree, and:
9 - Fix bug 460956 by changing directory mask to 1775 which allows
10 all to access sockets, users within the group to create a socket,
11 and restricts the deletion or modification to the socket owner or
12 directory owner.
13 - Fix bug 488246 by creating symbolic links to the configuration
14 files when PGDATA and DATADIR differ.
15 - Fix bug 511942 by warning if CONFIG_SYSVIPC is not enabled.
16 - Fix bug 518522 by appending the plperl.on_init workaround to
17 postgresql.conf. (This only affects new installs.)
18 - Fix bug 529680 by removing the autotools inherit, and removing
19 the sed statement. We don't change anything in configure.in, which
20 means we don't need to regenerate the configure script.
21 - Fix bug 530790 by correcting the typo.
22 - Fix bug 531820 by removing the pre-initdb tests.
23
24 (Portage version: 2.2.14/cvs/Linux x86_64, signed Manifest commit with key D1BBFDA0)
25
26 Revision Changes Path
27 1.1 dev-db/postgresql/files/postgresql.init-pre_9.2
28
29 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql.init-pre_9.2?rev=1.1&view=markup
30 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql.init-pre_9.2?rev=1.1&content-type=text/plain
31
32 Index: postgresql.init-pre_9.2
33 ===================================================================
34 #!/sbin/runscript
35 # Copyright 1999-2014 Gentoo Foundation
36 # Distributed under the terms of the GNU General Public License v2
37 # $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql/files/postgresql.init-pre_9.2,v 1.1 2014/12/28 18:07:22 titanofold Exp $
38
39 extra_started_commands="reload"
40
41 get_config() {
42 [ -f ${PGDATA%/}/postgresql.conf ] || return 1
43
44 eval echo $(sed -e 's:#.*::' ${PGDATA%/}/postgresql.conf \
45 | awk '$1 == "'$1'" { print ($2 == "=" ? $3 : $2) }')
46 }
47
48 depend() {
49 use net
50 provide postgresql
51
52 if [ "$(get_config log_destination)" = "syslog" ]; then
53 use logger
54 fi
55 }
56
57 configured_port=$(get_config port)
58 : ${configured_port:=${PGPORT}}
59 socket_path=$(get_config unix_socket_directory)
60 : ${socket_path:=/run/postgresql}
61
62 checkconfig() {
63 # Check that DATA_DIR has been set
64 if [ -z ${DATA_DIR} ] ; then
65 eerror "DATA_DIR not set"
66 eerror "HINT: Perhaps you need to update /etc/conf.d/postgresql-@SLOT@"
67 return 1
68 fi
69
70 # Check that DATA_DIR exists
71 if [ ! -d ${DATA_DIR} ] ; then
72 eerror "Directory not found: ${DATA_DIR}"
73 eerror "HINT: Ensure that DATA_DIR points to the right path."
74 eerror "HINT: Or perhaps you need to create the database cluster:"
75 eerror " emerge --config dev-db/postgresql:@SLOT@"
76 return 1
77 fi
78
79 # Check for the existence of PostgreSQL's config files, and set the
80 # proper mode and ownership.
81 # Only three files should be checked as potentially other files
82 # may be in PGDATA that should not be touched.
83 local file
84 for file in postgresql pg_hba pg_ident ; do
85 file="${PGDATA%/}/${file}.conf"
86 if [ -f ${file} ] ; then
87 checkpath -f -m 0600 -o postgres:postgres ${file}
88 else
89 eerror "${file} not found"
90 eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}"
91 return 1
92 fi
93 done
94
95 # Set the proper permission for the socket path and create it if
96 # it doesn't exist.
97 checkpath -d -m 1775 -o postgres:postgres ${socket_path}
98 if [ -e ${socket_path%/}/.s.PGSQL.${configured_port} ] ; then
99 eerror "Socket conflict."
100 eerror "A server is already listening on:"
101 eerror " ${socket_path%/}/.s.PGSQL.${configured_port}"
102 eerror "HINT: Change PGPORT to listen on a different socket."
103 return 1
104 fi
105 }
106
107 start() {
108 checkconfig || return 1
109
110 ebegin "Starting PostgreSQL"
111
112 rm -f ${DATA_DIR%/}/postmaster.pid
113
114 local extraenv
115 local x
116 for x in ${PG_EXTRA_ENV} ; do
117 extraenv="${extraenv} --env ${x}"
118 done
119
120 start-stop-daemon --start \
121 --user postgres \
122 --env "PGPORT=${configured_port}" \
123 ${extraenv} \
124 --pidfile ${DATA_DIR%/}/postmaster.pid \
125 --wait $((${START_TIMEOUT}*1000)) \
126 --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/postgres \
127 -- -D ${PGDATA} --data-directory=${DATA_DIR} --silent-mode=true \
128 ${PGOPTS}
129
130 local retval=$?
131
132 if [ $retval -ne 0 ] ; then
133 eerror "Check the log for a possible explanation of the above error. The log may be"
134 eerror " ${DATA_DIR%/}/postmaster.log"
135 eerror "Or wherever you configured PostgreSQL @SLOT@ log messages to be sent."
136 eend $retval
137 return $retval
138 fi
139
140 eend $retval
141 }
142
143 stop() {
144 local seconds=$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT} ))
145 ebegin "Stopping PostgreSQL (this can take up to ${seconds} seconds)"
146
147 local retval
148 local retries=SIGTERM/${NICE_TIMEOUT}
149
150 if [ "${RUDE_QUIT}" != "NO" ] ; then
151 einfo "RUDE_QUIT enabled."
152 retries="${retries}/SIGINT/${RUDE_TIMEOUT}"
153 fi
154 if [ "${FORCE_QUIT}" = "YES" ] ; then
155 einfo "FORCE_QUIT enabled."
156 ewarn "A recover-run might be executed on next startup."
157 retries="${retries}/SIGQUIT/${FORCE_TIMEOUT}"
158 fi
159
160 # Loops through nice, rude, and force quit in one go.
161 start-stop-daemon --stop \
162 --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/postgres \
163 --retry ${retries} \
164 --pidfile ${DATA_DIR%/}/postmaster.pid
165
166 eend
167 }
168
169 reload() {
170 ebegin "Reloading PostgreSQL configuration"
171 kill -HUP $(head -n1 ${DATA_DIR%/}/postmaster.pid)
172 eend $?
173 }
174
175
176
177 1.1 dev-db/postgresql/files/postgresql.service
178
179 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql.service?rev=1.1&view=markup
180 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql.service?rev=1.1&content-type=text/plain
181
182 Index: postgresql.service
183 ===================================================================
184 # It's not recommended to modify this file in-place, because it will be
185 # overwritten during package upgrades. If you want to customize, the
186 # best way is to create file
187 # "/etc/systemd/system/postgresql-@SLOT@.service.d/*.conf"
188 # containing your changes
189
190 # For example, if you want to change the server's port number to 5433,
191 # create a file named
192 # "/etc/systemd/system/postgresql-@SLOT@.service.d/port.conf"
193 # containing:
194 # [Service]
195 # Environment=PGPORT=5433
196 # This will override the setting appearing below.
197
198 [Unit]
199 Description=PostgreSQL database server
200 After=network.target
201
202 [Service]
203 Type=forking
204
205 User=postgres
206 Group=postgres
207
208 # Port number for server to listen on
209 Environment=PGPORT=5432
210
211 # Location of configuration files
212 Environment=PGDATA=/etc/postgresql-@SLOT@
213
214 # Where the data directory is located
215 Environment=DATA_DIR=/var/lib/postgresql/@SLOT@/data
216
217 # Where to send early-startup messages from the server (before the logging
218 # options of postgresql.conf take effect)
219 # This is normally controlled by the global default set by systemd
220 # StandardOutput=syslog
221
222 ExecStartPre=/usr/bin/postgresql-@SLOT@-check-db-dir
223 ExecStart=/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl start -D ${DATA_DIR} -s -l ${DATA_DIR}/postmaster.log -o "-p ${PGPORT} -D ${PGDATA} --data-directory=${DATA_DIR}" -w -t 300
224 ExecStop=/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl stop -D ${DATA_DIR} -s -m fast
225 ExecReload=/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl reload -D ${DATA_DIR} -s
226
227 # Give a reasonable amount of time for the server to start up/shut down
228 TimeoutSec=300
229
230 # Disable OOM kill on the postmaster
231 OOMScoreAdjust=-1000
232
233 [Install]
234 WantedBy=multi-user.target
235
236
237
238 1.1 dev-db/postgresql/files/postgresql-check-db-dir
239
240 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql-check-db-dir?rev=1.1&view=markup
241 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql-check-db-dir?rev=1.1&content-type=text/plain
242
243 Index: postgresql-check-db-dir
244 ===================================================================
245 #!/bin/sh
246 # Copyright 1999-2014 Gentoo Foundation
247 # Distributed under the terms of the GNU General Public License v2
248 # $Header: /var/cvsroot/gentoo-x86/dev-db/postgresql/files/postgresql-check-db-dir,v 1.1 2014/12/28 18:07:22 titanofold Exp $
249
250 eerror() {
251 echo "$@" >&2
252 }
253
254 # Check that DATA_DIR has been set
255 if [ -z ${DATA_DIR} ] ; then
256 eerror "DATA_DIR not set"
257 exit 1
258 fi
259
260 # Check that DATA_DIR exists
261 if [ ! -d ${DATA_DIR} ] ; then
262 eerror "Directory not found: ${DATA_DIR}"
263 eerror "HINT: Ensure that DATA_DIR points to the right path."
264 eerror "HINT: Or perhaps you need to create the database cluster:"
265 eerror " emerge --config dev-db/postgresql:@SLOT@"
266 exit 1
267 fi
268
269 # Check for the existence of PostgreSQL's config files, and set the
270 # proper mode and ownership.
271 # Only three files should be checked as potentially other files
272 # may be in PGDATA that should not be touched.
273 for file in postgresql pg_hba pg_ident ; do
274 file="${PGDATA%/}/${file}.conf"
275 if [ ! -f ${file} ] ; then
276 eerror "${file} not found"
277 eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}"
278 exit 1
279 fi
280 done
281
282
283
284 1.1 dev-db/postgresql/files/postgresql.confd
285
286 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql.confd?rev=1.1&view=markup
287 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql.confd?rev=1.1&content-type=text/plain
288
289 Index: postgresql.confd
290 ===================================================================
291 # Which port and socket to bind PostgreSQL
292 PGPORT="5432"
293
294 # How long to wait for server to start in seconds
295 START_TIMEOUT=10
296
297 # NICE_QUIT ignores new connections and wait for clients to disconnect from
298 # server before shutting down. NICE_TIMEOUT in seconds determines how long to
299 # wait for this to succeed.
300 NICE_TIMEOUT=60
301
302 # Forecfully disconnect clients from server and shut down. This is performed
303 # after NICE_QUIT. Terminated client connections have their open transactions
304 # rolled back.
305 # Set RUDE_QUIT to "NO" to disable. RUDE_TIMEOUT in seconds.
306 RUDE_QUIT="YES"
307 RUDE_TIMEOUT=30
308
309 # If the server still fails to shutdown, you can force it to quit by setting
310 # this to YES and a recover-run will execute on the next startup.
311 # Set FORCE_QUIT to "YES" to enable. FORCE_TIMEOUT in seconds.
312 FORCE_QUIT="NO"
313 FORCE_TIMEOUT=2
314
315 # Extra options to run postmaster with, e.g.:
316 # -N is the maximal number of client connections
317 # -B is the number of shared buffers and has to be at least 2x the value for -N
318 # Please read the man-page to postmaster for more options. Many of these
319 # options can be set directly in the configuration file.
320 #PGOPTS="-N 512 -B 1024"
321
322 # Pass extra environment variables. If you have to export environment variables
323 # for the database process, this can be done here.
324 # Don't forget to escape quotes.
325 #PG_EXTRA_ENV="PGPASSFILE=\"/path/to/.pgpass\""
326
327 ##############################################################################
328 #
329 # The following values should not be arbitrarily changed.
330 #
331 # `emerge --config dev-db/postgresql:@SLOT@' uses these values to
332 # determine where to create the data directory, where to place the
333 # configuration files, and any additional options to pass to initdb.
334 #
335 # The initscript also uses these variables to inform PostgreSQL where to find
336 # its data directory and configuration files.
337 #
338 ##############################################################################
339
340 # Location of configuration files
341 PGDATA="/etc/postgresql-@SLOT@/"
342
343 # Where the data directory is located/to be created
344 DATA_DIR="/var/lib/postgresql/@SLOT@/data"
345
346 # Additional options to pass to initdb.
347 # See `man initdb' for available options.
348 PG_INITDB_OPTS="--encoding=UTF8"
349
350
351
352 1.4 dev-db/postgresql/files/postgresql.init
353
354 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql.init?rev=1.4&view=markup
355 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql.init?rev=1.4&content-type=text/plain
356 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql.init?r1=1.3&r2=1.4
357
358
359
360
361 1.1 dev-db/postgresql/files/postgresql.tmpfilesd
362
363 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql.tmpfilesd?rev=1.1&view=markup
364 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-db/postgresql/files/postgresql.tmpfilesd?rev=1.1&content-type=text/plain
365
366 Index: postgresql.tmpfilesd
367 ===================================================================
368 d /run/postgresql 1775 postgres postgres -