Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Za0Ra-0006tj-9e for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Sep 2015 11:55:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Za0RZ-0003h6-BB for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Sep 2015 11:55:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZZwzk-0004QX-GD for pgsql-bugs@postgresql.org; Thu, 10 Sep 2015 08:14:12 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZZwzb-0004bY-Mi for pgsql-bugs@postgresql.org; Thu, 10 Sep 2015 08:14:10 +0000 MIME-Version: 1.0 Subject: BUG #13612: postgresql94-setup initdb in kickstart fails To: pgsql-bugs@postgresql.org From: allan.kristsensen@schneider-electric.com Date: Thu, 10 Sep 2015 08:13:12 +0000 Message-ID: <20150910081312.2597.31540@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 13612 Logged by: Allan Kristensen Email address: allan.kristsensen@schneider-electric.com PostgreSQL version: 9.4.4 Operating system: Centos 7 Description: Running "/usr/pgsql-9.4/bin/postgresql94-setup initdb" during Kickstart install of a Centos/RHEL 7 will through the following error. failed to find PGDATA setting in postgresql-9.4.service Running in chroot, ignoring request. In bin/postgresql94-setup the problematic lines are: PGDATA=`systemctl show -p Environment "${SERVICE_NAME}.service" | sed 's/^Environment=//' | tr ' ' '\n' | sed -n 's/^PGDATA=//p' | tail -n 1` if [ x"$PGDATA" = x ]; then echo "failed to find PGDATA setting in ${SERVICE_NAME}.service" exit 1 fi systemctl returns an empty result as it won't run in a chroot. Besides the above. What puzzles me is that PGDATA is overwritten further down in the script. # Get data directory from the service file PGDATA=`sed -n 's/Environment=PGDATA=//p' "${SERVICE_FILE}"` I have put things together to the following: # this parsing technique fails for PGDATA pathnames containing spaces, # but there's not much I can do about it given systemctl's output format... PGDATA=`systemctl show -p Environment "${SERVICE_NAME}.service" | sed 's/^Environment=//' | tr ' ' '\n' | sed -n 's/^PGDATAA=//p' | tail -n 1` if [ x"$PGDATA" = x ]; then # Find the unit file for new version. if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ] then SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service" elif [ -f "/lib/systemd/system/${SERVICE_NAME}.service" ] then SERVICE_FILE="/lib/systemd/system/${SERVICE_NAME}.service" else echo "Could not find systemd unit file ${SERVICE_NAME}.service" exit 1 fi # Get data directory from the service file PGDATA=`sed -n 's/Environment=PGDATA=//p' "${SERVICE_FILE}"` if [ x"$PGDATA" = x ]; then echo "Failed to find PGDATA setting in ${SERVICE_NAME}.service" exit 1 fi fi export PGDATA If systemctl does not find a path then try the searching in files and exit if none of the methods provides a valid path. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs