2

I am currently installing PostgreSQL from source on a RHEL6 system. I have generally been following the official documentation for guidance (http://www.postgresql.org/docs/9.4/static/installation.html).

Unfortunately, there isn't too much information by way of of the init.d/startup scripts. Here's what I'm currently struggling with:

  • the OOB start-up script (https://github.com/postgres/postgres/blob/master/contrib/start-scripts/linux) is copied to /etc/init.d/postgres with slight modifications to reflect my environment (e.g. prefix, data path, etc); file is owned by root and has 755 permissions
  • the following commands are executed as root to ensure execution on boot: chkconfig --add postgresql; chkconfig postgresql on;
  • as root, the script runs without issues (e.g. /etc/init.d/postgresql status)
  • however, the script returns with a password prompt when it is executed as the postgres user (the user that is configured to run PostgreSQL)

This experience is vastly different from how the packaged version (i.e. RPM) of PostgreSQL functions. I am able to execute the script as root and as postgres:

[root@ulvjived80 ~]# /etc/init.d/postgresql-9.4 status
postgresql-9.4 is stopped

[postgres@ulvjived80 ~]$ /etc/init.d/postgresql-9.4  status
postgresql-9.4 is stopped

I've done quite a bit of searching online and the most cited solution I've found relates to permitting the command/script for the relevant user in the /etc/sudoers file. However, the RPM doesn't seem to do that.

A commercial application that we use also behaves in the same way i.e. the startup script can be executed by root and by the relevant non-root user.

Are there any ideas as to how I can mimic the RPMs functionality?

Thank you!

2
  • 1
    Use the init script from the RPM instead? Or just let the thing run as root. Init scripts were never designed or intended to be run by non-root users. Or use RHEL 7 (which you should already be doing), and you can run your own user-private systemd units. Mar 23, 2016 at 22:25
  • @MichaelHampton I've tried with the RPMs init script and receive a similar result -- on my system, the RPMs init script invokes runuser and runuser fails with the following error: runuser: cannot set groups: Operation not permitted (as it should as runuser is non-interactive).
    – R Law
    Mar 23, 2016 at 22:34

0

You must log in to answer this question.

Browse other questions tagged .