| From: | allan(dot)kristsensen(at)schneider-electric(dot)com | 
|---|---|
| To: | pgsql-bugs(at)postgresql(dot)org | 
| Subject: | BUG #13612: postgresql94-setup initdb in kickstart fails | 
| Date: | 2015-09-10 08:13:12 | 
| Message-ID: | 20150910081312.2597.31540@wrigleys.postgresql.org | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-bugs | 
The following bug has been logged on the website:
Bug reference:      13612
Logged by:          Allan Kristensen
Email address:      allan(dot)kristsensen(at)schneider-electric(dot)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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruce Momjian | 2015-09-10 13:11:33 | Re: BUG #13612: postgresql94-setup initdb in kickstart fails | 
| Previous Message | kondo | 2015-09-10 04:15:18 | BUG #13611: test_postmaster_connection failed (Windows, listen_addresses = '0.0.0.0' or '::') |