pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: allan.kristsensen@schneider-electric.com
To: pgsql-bugs@postgresql.org
Subject: BUG #13612: postgresql94-setup initdb in kickstart fails
Date: Thu, 10 Sep 2015 08:13:12 +0000
Message-ID: <20150910081312.2597.31540@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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



view thread (9+ messages)  latest in thread

Message-ID: <20150910081312.2597.31540@wrigleys.postgresql.org>
Permalink:  ../20150910081312.2597.31540@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20150910081312.2597.31540@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: allan.kristsensen@schneider-electric.com
  Subject: Re: BUG #13612: postgresql94-setup initdb in kickstart fails
  In-Reply-To: <20150910081312.2597.31540@wrigleys.postgresql.org>
  References: <20150910081312.2597.31540@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox