diff --git a/dev-db/postgresql/Manifest b/dev-db/postgresql/Manifest index 49f70b4..1afa1aa 100644 --- a/dev-db/postgresql/Manifest +++ b/dev-db/postgresql/Manifest @@ -9,9 +9,10 @@ AUX postgresql-9.5.5-no-server.patch 4498 SHA256 9ecf3ae2b845949579bb59608b9e697 AUX postgresql-9.6-no-server.patch 2104 SHA256 8827022d5db77e770cc020c6b401bc729e18f06f80063910e637c80845cdcead SHA512 18e48ce275854159bd99cd5eaf8ef38cc3cd94d5365976d917f9f6088b3d62ed29f7e16710fa9cf4b08dd1706e539289c3ba33c345ffa47ed22e5f3d17e8fd2f WHIRLPOOL b6bc42d830bcc6106cfbbd8600621b56084aafc3be06d440a3f123f128eaa65897c99312d0372128ebb22158ad1f75b9a6262c3bc17c16562f19e751d469c567 AUX postgresql-9.6.1-no-server.patch 2886 SHA256 6eb915f92ad437a8ca76b5c333b98ccc2b352d31f2cc8c631e6b149bf1ca49b3 SHA512 41e884b8b1bf64df47e735e62fac2275a100c6ceea95861da61c5f6cadb32214d43dff8e6fe5940a7bd069b49c437e3162604e69d041b6b8495231ad6e7730fc WHIRLPOOL cbaf6b9e12ba7d52a953a44d3ece5afe1308ec8f0d5ff1543248a1a38ed94b82cf986b6b8685fe2254aa8f985310660ba1337bb2bc6f2bf50a006c975a989c91 AUX postgresql-check-db-dir 1020 SHA256 db401a5e0a8106619d4912adebc65bdf302dc087ce8e12c4ac049d2917ef29eb SHA512 e5e5ec5c5bc0f195194cd85cc4a8f0a329e4cfe72d6d0a45092c4a345f54483150c8e2175ff37f5e7eced481bbc8dc6a4d2f991fd9dbbb4607cec19b6476edfd WHIRLPOOL 2026f14fd896477a7fc6f058685f080b6f959baeaa8913178fc2b39134f45a98d96710492a1c25975b540cb6eb8dbbaa3f4c26f7070e83cecaf185d53c915ddb -AUX postgresql.confd 2202 SHA256 57c1ad0b14e8458024c713dd8cc2390023b95c27ba4cbd637333b1020f11f398 SHA512 ad4e66196f70d543d396ae72db6b0beb2cf8861f612dceaa1a1333b139475262e84bcf40774155254ed1cda7ada830d76f60b27982d0cb840360cc13fbbcecbc WHIRLPOOL aa012a5f302dccb362e54b6fea1ae6193330cc41c632b132c890f8a578f6f97a7ee9773057ea607b4f4914c97cd845dd4778c1bc29ea62b5ee1ff0e5c56f2211 -AUX postgresql.init 4169 SHA256 df50a446991dd5a087941b2defe89a157997dbe7f4dc6f9a24dabb9aea99df4a SHA512 ad2698df482f0863eac5b9847774564e7c8ae1a2370d544351f4d38647ab238b623d50f6124cf1eb508d309ec0b67cc778e67346221b24779dce47539f5ae904 WHIRLPOOL 4cb510130893415301348b97f2b7dfcffb004a978d9b1550b7d36c3dac3bdc73c3cb5770376755912e518b9d3628b32a0c0b3b518d6b46741f09a8d45c556427 -AUX postgresql.init-9.3 4194 SHA256 ae547732e2e1fd1adac40bd30fd79b83a5ba3bb1de4a553b8d0f09500cb2d082 SHA512 1aa490d336d29dd8837f993413caf4e9df659d7fa22667c2681c875ccb47191b48405dd3a5443f76bf5b872084d60387cf86ba3244a4530d4f34d30389d0a6a2 WHIRLPOOL afdae9a70426ef0261a939456c809d14b5ab7e137417574f0d66af0f2ca9e427ffb20e12dd386b37d15b5a03266f5be49115a52fa541a4ac2b4568049352f6d0 +AUX postgresql.confd 2450 SHA256 550c3d081021aceeba197d3ee4ef597e4be168e6dfa7fd3809d84ba5537d56cd SHA512 a4aae13cc0312707d77d3164da6f573c78360cf039bd81e8e0dccd19cedf701a227315aded0a412531217398426e357bffffcf9d374614bcb5bfa398c946bf0b WHIRLPOOL ccb2878553e6c01a27466bdbf02fe0a1f901d4cba853d8b9dbf144fa7acb61ab8e9b878f6eac36d01f8de4f434bfaee2768c058ca8dc82b887704fdd98166235 +AUX postgresql.confd-9.3 2477 SHA256 1d144dc8c5eb2a9a345823b6b4631f633c2d83e49c5c18ddda1fdc9fd4ace925 SHA512 c928364b2b8a555443db8c1ac2a7336cd5e32ac860f3238a0a791cfcdfdce941837d72dfa44f3f08704d528590f9f3bb479e25b7db9f32cdde76f216819baa9d WHIRLPOOL da42d85f32098b82469d053370bdba68197cdd10eb87ea5adba3c08e1847fd883bfda2cf486a0791d8d751066d45b46ee8d26e178516605f1efa95f9db7ce32d +AUX postgresql.init 4918 SHA256 99e4cdeb6f336e6c27f6548f09585823bfee3a042f16e310ba34b06d02a9be21 SHA512 7a36010f0cbcf14b803e95c9cd758718e376c78be8c0036c347797b294c6d6f695c937891dfcf6df8f861e7ffde708e51ce4bbfc2af0b899358198ab6da8c5c7 WHIRLPOOL b3aa3a9229560585fa577f66212b8cae8c00df7b8223478c2d8484ae1c6d51188310565de7a52cca94767b31943d099fc5f11ad220fec9916d2fbe8504705ef2 +AUX postgresql.init-9.3 5006 SHA256 25801eb3bfebba347fea96630bcf06b2432cde71eecdd28ee00064428f40c4c2 SHA512 07a664cf68f57ea8c63e17a708ce78a887f1e52c2f6284561e0fd241e5821acc6140eba267ba717386f1d16b60169a4d5ad6de0d1a18146f22e02f382cc18782 WHIRLPOOL 894e94192eeee171e801f74e5d3a8b0eb1aa559ad4e71d739bc123c389481b687be10582143e661f79914e4fc28d5f509e46801addadc2a4a752cf66720ba669 AUX postgresql.service 1768 SHA256 a5882f4f4b8d391a1226c5dc514df83342107c94880e32eaf174d152f280de88 SHA512 92c60a21ac87a298742d0aa0f4180218cebfa5644762c32a27b1314d92a581eb4f6cbcf41b20f29509c6eec9f6f236a57d2c944aa1eca35d7f8d29e2865b47d7 WHIRLPOOL 5f58b28a903311b4b59452d44c1cec3dab792bbb59b73eb5ae3926f64f45a5926bbdc7a17f460ea66256c940aefa560c89ffa49999fedfff69f223a63bf33a03 AUX postgresql.tmpfilesd 43 SHA256 a744802238384de29a1ab78a1eba857822be71685ad8d9d8ebf62456417e66f5 SHA512 a35a83d06bd01db5e4251c8d2fed572d62598fbfdddd0167eac918cda4cf520b942e67a54d5cca50d7f753e8b87ca4222024409d0efdb28a3e8ef1a2c5838e70 WHIRLPOOL a787a2c80bc144d88fac860617fd6923aa6fff9f0be8973d83c6ea271cf3f8ed3477de2c928c510903258b034b6d3e2619d1235d0c65b594d7106ad031fd4a74 DIST postgresql-9.2.19.tar.bz2 16466698 SHA256 1d29d73a4f590fcc348280f13ac2ff6a0f72c94908c54e3c20b7ab1560e8dbad SHA512 d3b4c5578bf6d6580028e775bff81a921258cb53b6b06567d96a352d14f3b63063adb480b2f5e2029baf8a034e14b5cd75eebc04f1ed7b16c849e1a5ec1f4867 WHIRLPOOL c13b45fd7aee08ea472557c9f40d79c45abd572fefcc215002b562b8046b1937bf522f6f7f6e280ff1e434c9698734cda9f1c3dacd3c8fee5f33dad0da21f75f @@ -19,10 +20,10 @@ DIST postgresql-9.3.15.tar.bz2 17059932 SHA256 a9fcba1446a93aa95e3e1b6535756f047 DIST postgresql-9.4.10.tar.bz2 17802812 SHA256 7061678bed1981c681ce54c76b98b6ec17743f090a9775104a45e7e1a8826ecf SHA512 2fcf47769b22c69bc82c9d6edc317e18dfcb4a96534e012bae4355e5088afa83da98b21e08a07766794f0a166888acbd16705a806464ea11711ed97c3b4012fb WHIRLPOOL e6ed3c209043cbbacb0698e1be367f20028d649d4cff62b5d6edd162c6ad629a3ec5f55854bd12334a3d3165462fecb34188bd62cd398cfc242a3579810b5b85 DIST postgresql-9.5.5.tar.bz2 18525082 SHA256 02c65290be74de6604c3fed87c9fd3e6b32e949f0ab8105a75bd7ed5aa71f394 SHA512 727ab57796cd393ec3755e9aabf515ebbdc3152b4062c20e64511e866a7e7038ba5c5e2843f13f3a79e2263296451f0e93108346b6f638611fba2449394e338e WHIRLPOOL ec5262fd8cecea20fd12bcec8e6e015817ae8181d9e9ff6d8aca6ed43cadedac1bd5006c3d04262b99b9a79aa02c409920ab3392136f3ff3dc480fe1155cade8 DIST postgresql-9.6.1.tar.bz2 19260568 SHA256 e5101e0a49141fc12a7018c6dad594694d3a3325f5ab71e93e0e51bd94e51fcd SHA512 f27af67f9a96f6327150330bf091a803e10eabbac4e488cf5e4d72907e2eb1dbde7282fe0b89fd75711fd8bdcdb3688b5a9eac1e4d6871f4e8681c9c8b0e7c45 WHIRLPOOL 1ea7933817895ec4ddd531b60eead2c0c3324b90fe48224bd49748d11e76313bb7699670edaf5c8f41b8424026bed59d29aab69208c5ced5161196a4827c78f8 -EBUILD postgresql-9.2.19-r1.ebuild 13154 SHA256 f42876179e8c24d4ce9596af00ab8385a991208ff7dbc9b38363cec494d802cb SHA512 0af49f052e784c4471dbe3c7b137788381268d4ef8373dd25cc7149bdd217a0e4a9508f07c13a7df8a688ad78941c22029e4f60a89e3c0d9750a6da46fc8b554 WHIRLPOOL 7c1cef05a83b44afaabe7fedfaf0d70303d170285be5ea11bd9fe53a70ee87bc4f9bdc7a6f2d51ddd7d7cdc9e6d3c5b9840c22c21dd12479e63efeabfcea4d5a -EBUILD postgresql-9.3.15-r1.ebuild 13409 SHA256 d74e871914ebee25c6897bf16be05024c5eb33c90c9c08920ab1e90cdc0bfa6c SHA512 67e0d6136c8842fb35abda65fba262cfd12cf3284ed3fdb84a026cad33e7ecd6d3ae0c118cc5905f141e91ade8d5cd30ce9b5439b01063247fc331e34bd7b9ff WHIRLPOOL 1f581cdc60d89c69f43845297ffe1e9427fd29d96fb9257b45bd4c662c08be0d9908efff452b92a5463ff886e1fbf3dd71f71344cf3bdfe121a559671456ffe5 -EBUILD postgresql-9.4.10-r1.ebuild 14219 SHA256 458ffb59319f9242b06ae1e8a39ef6afc5ce3ed1c714f4e0795edc8dc8a65655 SHA512 e9b66cab6ed4e72db483427cb9ae996b0559d5f7447f267023606c9c39e0734aa8b62f68d307d51251c2675cf7286af63ef87202c9721cdf55356a9131bef6ff WHIRLPOOL 85fbdb48d575d299640cd2159af38513eed290abf00c5a4af398a25f897cf035f8f7bdecc989b7cdf0183cf29e53854c3bc199382ab2e0b7d113d12e76b36976 -EBUILD postgresql-9.5.5-r1.ebuild 14452 SHA256 dbd503ec12eab46f0b42977ea234d6cb8464070c73eed14cf346eb8904844310 SHA512 97576d1fbe4eec174759042b215d1db511ab3fa79e0c29d6f766733693cd4be327ab92e8f23459aad5f8d1a78ff1ba93774eb752d93ff6cb177d45f90a82e00d WHIRLPOOL dec02822eba6614d5d18b93e940cefecb02fd9609c6b1a59e517ad5c29d540c3c87980162d36a7c930719bd46a3cf6f974fdf8a5ca862ef3d7b1b26af1d6f362 -EBUILD postgresql-9.6.1-r2.ebuild 14294 SHA256 f5bd95018211f43dea4bc0b8a46886be7357c71c177591b6bc065333d3429c3b SHA512 8453b80d7310049e57b25db604448596f5391594e6a4877895ad0a9e23827ace714d973c1b7797c1e40284e0647f917da8e2492623fb73934b46e2a031315572 WHIRLPOOL 3f7a7ed1ac18a895a591c1d7bdd3a0ce7323817975b1b3225e48067ffacc4d05b6043ae889b24341594bb6842b2294898cb4056cb98750030142f8a10b381438 -EBUILD postgresql-9999.ebuild 12692 SHA256 071d20d87e5d9ccb16b86f1114f6aadd8ab0861d4aba53c5aba43828b9adb54c SHA512 2865b8ae7f06343cad930460d2da48f0468e0028f9f2792f0feb0d153d2adedcc6d6c8ef89d6d8a55b85c075030cd7204098f55549e7b53d083fed5b3017270b WHIRLPOOL 8117fc34fb3b768528bdb9b6ec2b34588eae69bec68dc42893d0cc58e897edff49d62a815e7aa15d4379535c8df5ef11202209b236a45842aaf578cc5a7844fe +EBUILD postgresql-9.2.19-r1.ebuild 13320 SHA256 87d1ec952461f236cc00e81204b324ad3a63e0d4f26a497809880a70e325fac3 SHA512 23a1b670bb4ac7ad2314eb710e3d5c2733c4315d9926ca2b992c7fa8a1048e2d5ed377104e693ee4aaa02d59140c95d6b86592f8d3f936f19c8baed32b1312dd WHIRLPOOL 322a2fe13d77ca7df590671a309e4e7cce30744e833e047dedfedfa3b9e19c4019eb1f077a949aa18016698365c5c81ed310631cfdb4fd161b1483a6adaa3b1c +EBUILD postgresql-9.3.15-r1.ebuild 13584 SHA256 7025d7528cda376824c62721ad6a373b81275f369fa404bbbe49ffd4ec015597 SHA512 76b1c7309b3151f6b6532fc93ccf7a825ab6773c32ec9019f015a33fcb86cd96ea2c92892707cd187c324abed8c66b99993c6d07fef1e63de9fcbc1919207bb5 WHIRLPOOL 2943366b076af3b3127697ca542a2bdc3a979e47382aa73286f39cbc466ad48b996640c17fa85b24e2474effc7034ee4e940ca4e6c485947f85b41c1c38a30b7 +EBUILD postgresql-9.4.10-r1.ebuild 14394 SHA256 acaa2393098d456b0ad9940f99678dfe30eec02e9d20171e187928e3c2c8d5df SHA512 d0cfe5d74a022bbda2c06a7bb0b043f1e2a9ed3964884728713197470b1dfa212920a224e88f1fb63d4e4004f6382f56b6ee05bac8e545882fa8430105c22109 WHIRLPOOL c06414879ddf6fb0883a41879edbf8e5819699e2a16bcaa1705e2d4fdadce7d0d4c9a5dea4fe9e2004f3a789abd97a567cdc5f5e4146a414961be0c5d1f4c920 +EBUILD postgresql-9.5.5-r1.ebuild 14627 SHA256 d745ef41e4385d5b66c6b63ec8feefabf08afb67f912a31f8b04d2c4dc2c18cc SHA512 c4a4e34d1671fae48dea9092784635c4a198e281c0948992f4dee3fe6db5516c285b1b50ee139fe02f685ed43a8eb2d4b9518f58f19523c160cfaec62ff191df WHIRLPOOL 17e4f3604e265c800e46cecb710449f353646fa7055e9f31f5f877167a02b1506c89379fd40a3deffd4cab6bf16d59d26e9cd1c91e0dc867af7d0a857d6eb5e7 +EBUILD postgresql-9.6.1-r2.ebuild 14469 SHA256 4ea61a3f2f6e38c6a79c9f6ca1afde557a17e94e06c9ea64303dd795737a4767 SHA512 d48073e981ca268158e574eabd836602bb1d5b8aed27d3a3991e0b7c8e6d2d48530b815f1b5133a13ea2190ec92d8fcb430e8bd79fa5a2f9cd64b0a5f6c7dfff WHIRLPOOL 033292ba1179d655111c10f92c95517cf70d191880499f61611f5ec00f2ba0ddada87cf2110a6689dfc6c9e65bc82bb0e7d55c4d8d3de9c840e4ec569425871d +EBUILD postgresql-9999.ebuild 12867 SHA256 62415f2a7bd2da4d41aa8aa0625f88a804b6858a916b13049de2ba91edb338d4 SHA512 cac7a2a4325b6b61e16d3ac8423e43d0e1a7c24eba04da4c124af7d5e06034a4f21ab1024924be2d2c1c18ebc0dcf4feb2c72d847645621b2e7e85205cc5bd0d WHIRLPOOL 1ed3a0cfa59ef0b2e26be723e79f6d5212e76c31474a5174e041aa8f3ff6392b20307265bc10fea254dd900576bc82a11391b9bb9906d060feba143720137075 MISC metadata.xml 620 SHA256 85335fdf06be777d6fa46902094b666ddd7e0a64d12f03b0ba54c181641822c0 SHA512 00a3f52a73add4922a366534f50decb308254a27c64130c9b4fde4f27fbed318ff65a5065a95e0d99219f5f4c439d502b0b0a3951f4589393617385ad656e003 WHIRLPOOL b0a0bf7d88a585d04cdc7acb7aa46d455fff5508100c3a81485ecb9cf221dbbc13f10501652ff084253eacde019d4c79c7b4f997bc8408ade041edb8a23cb1cd diff --git a/dev-db/postgresql/files/postgresql.confd b/dev-db/postgresql/files/postgresql.confd index 07b465d..7753eea 100644 --- a/dev-db/postgresql/files/postgresql.confd +++ b/dev-db/postgresql/files/postgresql.confd @@ -1,3 +1,10 @@ +# Directory that contains the unix socket. Created and controlled by +# the related initscript. The directory created will be owned +# root:postgres with mode 1775. +# +# /run/postgresql is the default directory. +PG_SOCKET_DIRECTORY="/run/postgresql" + # Which port and socket to bind PostgreSQL PGPORT="5432" diff --git a/dev-db/postgresql/files/postgresql.confd-9.3 b/dev-db/postgresql/files/postgresql.confd-9.3 new file mode 100644 index 0000000..8b6d2a0 --- /dev/null +++ b/dev-db/postgresql/files/postgresql.confd-9.3 @@ -0,0 +1,65 @@ +# Comma-separated list of directories that contain a unix +# socket. Created and controlled by the related initscript. The +# directories created will be owned root:postgres with mode 1775. +# +# /run/postgresql is the default directory. +PG_SOCKET_DIRECTORIES="/run/postgresql" + +# Which port and socket to bind PostgreSQL +PGPORT="5432" + +# How long to wait for server to start in seconds +START_TIMEOUT=10 + +# NICE_QUIT ignores new connections and wait for clients to disconnect from +# server before shutting down. NICE_TIMEOUT in seconds determines how long to +# wait for this to succeed. +NICE_TIMEOUT=60 + +# Forecfully disconnect clients from server and shut down. This is performed +# after NICE_QUIT. Terminated client connections have their open transactions +# rolled back. +# Set RUDE_QUIT to "NO" to disable. RUDE_TIMEOUT in seconds. +RUDE_QUIT="YES" +RUDE_TIMEOUT=30 + +# If the server still fails to shutdown, you can force it to quit by setting +# this to YES and a recover-run will execute on the next startup. +# Set FORCE_QUIT to "YES" to enable. FORCE_TIMEOUT in seconds. +FORCE_QUIT="NO" +FORCE_TIMEOUT=2 + +# Extra options to run postmaster with, e.g.: +# -N is the maximal number of client connections +# -B is the number of shared buffers and has to be at least 2x the value for -N +# Please read the man-page to postmaster for more options. Many of these +# options can be set directly in the configuration file. +#PGOPTS="-N 512 -B 1024" + +# Pass extra environment variables. If you have to export environment variables +# for the database process, this can be done here. +# Don't forget to escape quotes. +#PG_EXTRA_ENV="PGPASSFILE=\"/path/to/.pgpass\"" + +############################################################################## +# +# The following values should not be arbitrarily changed. +# +# `emerge --config dev-db/postgresql:@SLOT@' uses these values to +# determine where to create the data directory, where to place the +# configuration files, and any additional options to pass to initdb. +# +# The initscript also uses these variables to inform PostgreSQL where to find +# its data directory and configuration files. +# +############################################################################## + +# Location of configuration files +PGDATA="/etc/postgresql-@SLOT@/" + +# Where the data directory is located/to be created +DATA_DIR="/var/lib/postgresql/@SLOT@/data" + +# Additional options to pass to initdb. +# See `man initdb' for available options. +PG_INITDB_OPTS="--encoding=UTF8" diff --git a/dev-db/postgresql/files/postgresql.init b/dev-db/postgresql/files/postgresql.init index 0952f1b..0b25704 100755 --- a/dev-db/postgresql/files/postgresql.init +++ b/dev-db/postgresql/files/postgresql.init @@ -1,14 +1,20 @@ #!/sbin/openrc-run -# Copyright 1999-2014 Gentoo Foundation +# Copyright 1999-2017 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ -extra_started_commands="reload" +extra_started_commands="reload promote" + +PG_CTL="/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl" + +description="PostgreSQL @SLOT@ -- the world's most advanced open source database -- +${RC_SERVICE} is a wrapper around pg_ctl with additional administrative checks +and convenience" get_config() { - [ -f ${PGDATA%/}/postgresql.conf ] || return 1 + [ -f "${PGDATA%/}/postgresql.conf" ] || return 1 - eval echo $(sed -e 's:#.*::' ${PGDATA%/}/postgresql.conf \ + eval echo $(sed -e 's:#.*::' "${PGDATA%/}/postgresql.conf" \ | awk '$1 == "'$1'" { print ($2 == "=" ? $3 : $2) }') } @@ -23,19 +29,17 @@ depend() { configured_port=$(get_config port) : ${configured_port:=${PGPORT}} -socket_path=$(get_config unix_socket_directory) -: ${socket_path:=/run/postgresql} checkconfig() { # Check that DATA_DIR has been set - if [ -z ${DATA_DIR} ] ; then + if [ -z "${DATA_DIR}" ] ; then eerror "DATA_DIR not set" eerror "HINT: Perhaps you need to update /etc/conf.d/postgresql-@SLOT@" return 1 fi # Check that DATA_DIR exists - if [ ! -d ${DATA_DIR} ] ; then + if [ ! -d "${DATA_DIR}" ] ; then eerror "Directory not found: ${DATA_DIR}" eerror "HINT: Ensure that DATA_DIR points to the right path." eerror "HINT: Or perhaps you need to create the database cluster:" @@ -50,8 +54,8 @@ checkconfig() { local file for file in postgresql pg_hba pg_ident ; do file="${PGDATA%/}/${file}.conf" - if [ -f ${file} ] ; then - checkpath -f -m 0600 -o postgres:postgres ${file} + if [ -f "${file}" ] ; then + checkpath -f -m 0600 -o postgres:postgres "${file}" else eerror "${file} not found" eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}" @@ -61,11 +65,11 @@ checkconfig() { # Set the proper permission for the socket path and create it if # it doesn't exist. - checkpath -d -m 1775 -o postgres:postgres ${socket_path} - if [ -e ${socket_path%/}/.s.PGSQL.${configured_port} ] ; then + checkpath -d -m 1775 -o root:postgres "${PG_SOCKET_DIRECTORY}" + if [ -e "${PG_SOCKET_DIRECTORY%/}/.s.PGSQL.${configured_port}" ] ; then eerror "Socket conflict." eerror "A server is already listening on:" - eerror " ${socket_path%/}/.s.PGSQL.${configured_port}" + eerror " ${PG_SOCKET_DIRECTORY%/}/.s.PGSQL.${configured_port}" eerror "HINT: Change PGPORT to listen on a different socket." return 1 fi @@ -74,32 +78,25 @@ checkconfig() { start() { checkconfig || return 1 - ebegin "Starting PostgreSQL" + ebegin "Starting PostgreSQL @SLOT@" - rm -f ${DATA_DIR%/}/postmaster.pid + rm -f "${DATA_DIR%/}/postmaster.pid" - local extraenv - local x - for x in ${PG_EXTRA_ENV} ; do - extraenv="${extraenv} --env ${x}" - done + su - postgres -c \ + "PGPORT=${configured_port} ${PG_EXTRA_ENV} ${PG_CTL} start \ + -s -w -t ${START_TIMEOUT} -l ${DATA_DIR%/}/postmaster.log \ + -D ${PGDATA} \ + -o '--data-directory=${DATA_DIR} \ + --unix-socket-directory=${PG_SOCKET_DIRECTORY} \ + ${PGOPTS}'" - start-stop-daemon --start \ - --user postgres \ - --env "PGPORT=${configured_port}" \ - ${extraenv} \ - --pidfile ${DATA_DIR%/}/postmaster.pid \ - --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl \ - -- start -s -w -t ${START_TIMEOUT} -l ${DATA_DIR%/}/postmaster.log \ - -D ${PGDATA} -o "--data-directory=${DATA_DIR} ${PGOPTS}" local retval=$? if [ $retval -ne 0 ] ; then - eerror "Check the log for a possible explanation of the above error. The log may be" + eerror "Check the log for a possible explanation of the above error." + eerror "The log may be located at:" eerror " ${DATA_DIR%/}/postmaster.log" - eerror "Or wherever you configured PostgreSQL @SLOT@ log messages to be sent." - eend $retval - return $retval + eerror "Or wherever you configured PostgreSQL @SLOT@ to log." fi eend $retval @@ -107,32 +104,50 @@ start() { stop() { local seconds=$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT} )) - ebegin "Stopping PostgreSQL (this can take up to ${seconds} seconds)" + ebegin "Stopping PostgreSQL @SLOT@ (this can take up to ${seconds} seconds)" - local retval - local retries=SIGTERM/${NICE_TIMEOUT} + su - postgres -c \ + "${PG_CTL} stop -t ${NICE_TIMEOUT} -s -D ${DATA_DIR} -m smart" + local retval=$? - if [ "${RUDE_QUIT}" != "NO" ] ; then - einfo "RUDE_QUIT enabled." - retries="${retries}/SIGINT/${RUDE_TIMEOUT}" + if [ "${RUDE_QUIT}" != "NO" -a ${retval} -ne 0 ] ; then + einfo "Previous attempt failed. Trying RUDE_QUIT." + su - postgres -c \ + "${PG_CTL} stop -t ${RUDE_TIMEOUT} -s -D ${DATA_DIR} -m fast" + retval=$? fi - if [ "${FORCE_QUIT}" = "YES" ] ; then - einfo "FORCE_QUIT enabled." + + if [ "${FORCE_QUIT}" = "YES" -a ${retval} -ne 0 ] ; then + einfo "Previous step failed. Trying FORCE_QUIT." ewarn "A recover-run might be executed on next startup." - retries="${retries}/SIGQUIT/${FORCE_TIMEOUT}" + su - postgres -c \ + "${PG_CTL} stop -t ${FORCE_TIMEOUT} -s -D ${DATA_DIR} -m immediate" + retval=$? fi - # Loops through nice, rude, and force quit in one go. - start-stop-daemon --stop \ - --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/postgres \ - --retry ${retries} \ - --pidfile ${DATA_DIR%/}/postmaster.pid + eend ${retval} +} - eend +status() { + ebegin "Checking PostgreSQL @SLOT@ status" + su - postgres -c "${PG_CTL} status -D ${DATA_DIR}" + eend $? } +description_reload="Simply sends the postgres process a SIGHUP signal, causing + it to reread its configuration files (postgresql.conf, pg_hba.conf, + etc.). This allows changing of configuration-file options that do not + require a complete restart to take effect." reload() { - ebegin "Reloading PostgreSQL configuration" - kill -HUP $(head -n1 ${DATA_DIR%/}/postmaster.pid) + ebegin "Reloading PostgreSQL @SLOT@ configuration" + su - postgres -c "${PG_CTL} reload -s -D ${DATA_DIR}" + eend $? +} + +description_promote="If the server is in standby, it is commanded to exit + recovery and begin read-write operations." +promote() { + ebegin "Promoting PostgreSQL @SLOT@" + su - postgres -c "${PG_CTL} promote -s -D ${DATA_DIR}" eend $? } diff --git a/dev-db/postgresql/files/postgresql.init-9.3 b/dev-db/postgresql/files/postgresql.init-9.3 index 6a04890..b7a0899 100755 --- a/dev-db/postgresql/files/postgresql.init-9.3 +++ b/dev-db/postgresql/files/postgresql.init-9.3 @@ -1,14 +1,20 @@ #!/sbin/openrc-run -# Copyright 1999-2015 Gentoo Foundation +# Copyright 1999-2017 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$ -extra_started_commands="reload" +extra_started_commands="reload promote" + +PG_CTL="/usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl" + +description="PostgreSQL @SLOT@ -- the world's most advanced open source database -- +${RC_SERVICE} is a wrapper around pg_ctl with additional administrative checks +and convenience" get_config() { - [ -f ${PGDATA%/}/postgresql.conf ] || return 1 + [ -f "${PGDATA%/}/postgresql.conf" ] || return 1 - eval echo $(sed -e 's:#.*::' ${PGDATA%/}/postgresql.conf \ + eval echo $(sed -e 's:#.*::' "${PGDATA%/}/postgresql.conf" \ | awk '$1 == "'$1'" { print ($2 == "=" ? $3 : $2) }') } @@ -23,19 +29,17 @@ depend() { configured_port=$(get_config port) : ${configured_port:=${PGPORT}} -socket_paths=$(get_config unix_socket_directories) -: ${socket_paths:=/run/postgresql} checkconfig() { # Check that DATA_DIR has been set - if [ -z ${DATA_DIR} ] ; then + if [ -z "${DATA_DIR}" ] ; then eerror "DATA_DIR not set" eerror "HINT: Perhaps you need to update /etc/conf.d/postgresql-@SLOT@" return 1 fi # Check that DATA_DIR exists - if [ ! -d ${DATA_DIR} ] ; then + if [ ! -d "${DATA_DIR}" ] ; then eerror "Directory not found: ${DATA_DIR}" eerror "HINT: Ensure that DATA_DIR points to the right path." eerror "HINT: Or perhaps you need to create the database cluster:" @@ -50,8 +54,8 @@ checkconfig() { local file for file in postgresql pg_hba pg_ident ; do file="${PGDATA%/}/${file}.conf" - if [ -f ${file} ] ; then - checkpath -f -m 0600 -o postgres:postgres ${file} + if [ -f "${file}" ] ; then + checkpath -f -m 0600 -o postgres:postgres "${file}" else eerror "${file} not found" eerror "HINT: mv ${DATA_DIR%/}/*.conf ${PGDATA}" @@ -61,50 +65,43 @@ checkconfig() { # Set the proper permission for the socket paths and create it if # it doesn't exist. - set -f; IFS=',' - local s - for s in ${socket_paths}; do - checkpath -d -m 1775 -o postgres:postgres ${s} - if [ -e ${s%/}/.s.PGSQL.${configured_port} ] ; then - eerror "Socket conflict." - eerror "A server is already listening on:" - eerror " ${s%/}/.s.PGSQL.${configured_port}" - eerror "HINT: Change PGPORT to listen on a different socket." - return 1 - fi - done - set +f; unset IFS + set -f; IFS=',' + local s + for s in ${PG_SOCKET_DIRECTORIES}; do + checkpath -d -m 1775 -o root:postgres "${s}" + if [ -e "${s%/}/.s.PGSQL.${configured_port}" ] ; then + eerror "Socket conflict." + eerror "A server is already listening on:" + eerror " ${s%/}/.s.PGSQL.${configured_port}" + eerror "HINT: Change PGPORT to listen on a different socket." + return 1 + fi + done + set +f; unset IFS } start() { checkconfig || return 1 - ebegin "Starting PostgreSQL" + ebegin "Starting PostgreSQL @SLOT@" - rm -f ${DATA_DIR%/}/postmaster.pid + rm -f "${DATA_DIR%/}/postmaster.pid" - local extraenv - local x - for x in ${PG_EXTRA_ENV} ; do - extraenv="${extraenv} --env ${x}" - done + su - postgres -c \ + "PGPORT=${configured_port} ${PG_EXTRA_ENV} ${PG_CTL} start \ + -s -w -t ${START_TIMEOUT} -l ${DATA_DIR%/}/postmaster.log \ + -D ${PGDATA} \ + -o '--data-directory=${DATA_DIR} \ + --unix-socket-directories=${PG_SOCKET_DIRECTORIES} \ + ${PGOPTS}'" - start-stop-daemon --start \ - --user postgres \ - --env "PGPORT=${configured_port}" \ - ${extraenv} \ - --pidfile ${DATA_DIR%/}/postmaster.pid \ - --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/pg_ctl \ - -- start -s -w -t ${START_TIMEOUT} -l ${DATA_DIR%/}/postmaster.log \ - -D ${PGDATA} -o "--data-directory=${DATA_DIR} ${PGOPTS}" local retval=$? if [ $retval -ne 0 ] ; then - eerror "Check the log for a possible explanation of the above error. The log may be" + eerror "Check the log for a possible explanation of the above error." + eerror "The log may be located at:" eerror " ${DATA_DIR%/}/postmaster.log" - eerror "Or wherever you configured PostgreSQL @SLOT@ log messages to be sent." - eend $retval - return $retval + eerror "Or wherever you configured PostgreSQL @SLOT@ to log." fi eend $retval @@ -112,32 +109,50 @@ start() { stop() { local seconds=$(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT} )) - ebegin "Stopping PostgreSQL (this can take up to ${seconds} seconds)" + ebegin "Stopping PostgreSQL @SLOT@ (this can take up to ${seconds} seconds)" - local retval - local retries=SIGTERM/${NICE_TIMEOUT} + su - postgres -c \ + "${PG_CTL} stop -t ${NICE_TIMEOUT} -s -D ${DATA_DIR} -m smart" + local retval=$? - if [ "${RUDE_QUIT}" != "NO" ] ; then - einfo "RUDE_QUIT enabled." - retries="${retries}/SIGINT/${RUDE_TIMEOUT}" + if [ "${RUDE_QUIT}" != "NO" -a ${retval} -ne 0 ] ; then + einfo "Previous attempt failed. Trying RUDE_QUIT." + su - postgres -c \ + "${PG_CTL} stop -t ${RUDE_TIMEOUT} -s -D ${DATA_DIR} -m fast" + retval=$? fi - if [ "${FORCE_QUIT}" = "YES" ] ; then - einfo "FORCE_QUIT enabled." + + if [ "${FORCE_QUIT}" = "YES" -a ${retval} -ne 0 ] ; then + einfo "Previous step failed. Trying FORCE_QUIT." ewarn "A recover-run might be executed on next startup." - retries="${retries}/SIGQUIT/${FORCE_TIMEOUT}" + su - postgres -c \ + "${PG_CTL} stop -t ${FORCE_TIMEOUT} -s -D ${DATA_DIR} -m immediate" + retval=$? fi - # Loops through nice, rude, and force quit in one go. - start-stop-daemon --stop \ - --exec /usr/@LIBDIR@/postgresql-@SLOT@/bin/postgres \ - --retry ${retries} \ - --pidfile ${DATA_DIR%/}/postmaster.pid + eend ${retval} +} - eend +status() { + ebegin "Checking PostgreSQL @SLOT@ status" + su - postgres -c "${PG_CTL} status -D ${DATA_DIR}" + eend $? } +description_reload="Simply sends the postgres process a SIGHUP signal, causing + it to reread its configuration files (postgresql.conf, pg_hba.conf, + etc.). This allows changing of configuration-file options that do not + require a complete restart to take effect." reload() { - ebegin "Reloading PostgreSQL configuration" - kill -HUP $(head -n1 ${DATA_DIR%/}/postmaster.pid) + ebegin "Reloading PostgreSQL @SLOT@ configuration" + su - postgres -c "${PG_CTL} reload -s -D ${DATA_DIR}" + eend $? +} + +description_promote="If the server is in standby, it is commanded to exit + recovery and begin read-write operations." +promote() { + ebegin "Promoting PostgreSQL @SLOT@" + su - postgres -c "${PG_CTL} promote -s -D ${DATA_DIR}" eend $? } diff --git a/dev-db/postgresql/postgresql-9.2.19-r1.ebuild b/dev-db/postgresql/postgresql-9.2.19-r1.ebuild index 3606b15..5740ee4 100644 --- a/dev-db/postgresql/postgresql-9.2.19-r1.ebuild +++ b/dev-db/postgresql/postgresql-9.2.19-r1.ebuild @@ -390,6 +390,10 @@ pkg_config() { ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}" fi + # unix_socket_directory has no effect in postgresql.conf as it's + # overridden in the initscript + sed '/^#unix_socket_directory/d' -i "${PGDATA%/}"/postgresql.conf + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522 # On the off-chance that you might need to work with UTF-8 encoded diff --git a/dev-db/postgresql/postgresql-9.3.15-r1.ebuild b/dev-db/postgresql/postgresql-9.3.15-r1.ebuild index 17c32df..83f097e 100644 --- a/dev-db/postgresql/postgresql-9.3.15-r1.ebuild +++ b/dev-db/postgresql/postgresql-9.3.15-r1.ebuild @@ -210,7 +210,7 @@ src_install() { if use server; then sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT} + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ "${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT} @@ -395,6 +395,10 @@ pkg_config() { ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}" fi + # unix_socket_directory has no effect in postgresql.conf as it's + # overridden in the initscript + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522 # On the off-chance that you might need to work with UTF-8 encoded diff --git a/dev-db/postgresql/postgresql-9.4.10-r1.ebuild b/dev-db/postgresql/postgresql-9.4.10-r1.ebuild index c743a72..0a0f6a0 100644 --- a/dev-db/postgresql/postgresql-9.4.10-r1.ebuild +++ b/dev-db/postgresql/postgresql-9.4.10-r1.ebuild @@ -242,7 +242,7 @@ src_install() { if use server; then sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT} + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ "${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT} @@ -427,6 +427,10 @@ pkg_config() { ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}" fi + # unix_socket_directory has no effect in postgresql.conf as it's + # overridden in the initscript + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522 # On the off-chance that you might need to work with UTF-8 encoded diff --git a/dev-db/postgresql/postgresql-9.5.5-r1.ebuild b/dev-db/postgresql/postgresql-9.5.5-r1.ebuild index 98f2fba..3d83627 100644 --- a/dev-db/postgresql/postgresql-9.5.5-r1.ebuild +++ b/dev-db/postgresql/postgresql-9.5.5-r1.ebuild @@ -243,7 +243,7 @@ src_install() { if use server; then sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT} + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ "${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT} @@ -433,6 +433,10 @@ pkg_config() { ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}" fi + # unix_socket_directory has no effect in postgresql.conf as it's + # overridden in the initscript + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522 # On the off-chance that you might need to work with UTF-8 encoded diff --git a/dev-db/postgresql/postgresql-9.6.1-r2.ebuild b/dev-db/postgresql/postgresql-9.6.1-r2.ebuild index 50b2cf4..4f49105 100644 --- a/dev-db/postgresql/postgresql-9.6.1-r2.ebuild +++ b/dev-db/postgresql/postgresql-9.6.1-r2.ebuild @@ -245,7 +245,7 @@ src_install() { if use server; then sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT} + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ "${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT} @@ -430,6 +430,10 @@ pkg_config() { ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}" fi + # unix_socket_directory has no effect in postgresql.conf as it's + # overridden in the initscript + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522 # On the off-chance that you might need to work with UTF-8 encoded diff --git a/dev-db/postgresql/postgresql-9999.ebuild b/dev-db/postgresql/postgresql-9999.ebuild index 5c9f4ae..527cf9b 100644 --- a/dev-db/postgresql/postgresql-9999.ebuild +++ b/dev-db/postgresql/postgresql-9999.ebuild @@ -178,7 +178,7 @@ src_install() { use static-libs || find "${ED}" -name '*.a' -delete sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ - "${FILESDIR}/${PN}.confd" | newconfd - ${PN}-${SLOT} + "${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT} sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \ "${FILESDIR}/${PN}.init-9.3" | newinitd - ${PN}-${SLOT} @@ -378,6 +378,10 @@ pkg_config() { ln -s "${PGDATA%/}"/{pg_{hba,ident},postgresql}.conf "${DATA_DIR%/}" fi + # unix_socket_directory has no effect in postgresql.conf as it's + # overridden in the initscript + sed '/^#unix_socket_directories/,+1d' -i "${PGDATA%/}"/postgresql.conf + cat <<- EOF >> "${PGDATA%/}"/postgresql.conf # This is here because of https://bugs.gentoo.org/show_bug.cgi?id=518522 # On the off-chance that you might need to work with UTF-8 encoded