rc.local command for postgres

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

rc.local command for postgres

Incomex
trying to get postgres to start up at boot.  found this at postgresql's site

On OpenBSD, add the following lines to the file /etc/rc.local:

if [ -x /usr/local/pgsql/bin/pg_ctl -a -x /usr/local/pgsql/bin/postmaster ];
then
    su - -c '/usr/local/pgsql/bin/pg_ctl start -l /var/postgresql/log -s'
postgres
    echo -n ' postgresql'
fi

my pg_ctl and postmaster executables are at /usr/local/bin, and have
modified
the script accordingly.  my script reads as follows:

if [ -x /usr/local/bin/pg_ctl -a -x /usr/local/bin/postmaster ]; then
  su - -c '/usr/local/bin/pg_ctl -D /WEBSITE/DATADIRECTORY start' postgres
fi

at boot the error thrown is "No such login class: /usr/local/bin/pg_ctl -D
/WEBSITE/DATADIRECTORY start"

the command I usually use after su'ing into postgres is:

pg_ctl -D /WEBSITE/DATADIRECTORY start

as /usr/local/bin is obviously in my PATH.

Any Ideas?

thanks

_________________________________________________________________
Stay in touch with old friends and meet new ones with Windows Live Spaces
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us

Reply | Threaded
Open this post in threaded view
|

Re: rc.local command for postgres

Antti Harri
On Fri, 20 Oct 2006, David B. wrote:
> trying to get postgres to start up at boot.  found this at postgresql's site

[snip]

> su - -c '/usr/local/bin/pg_ctl -D /WEBSITE/DATADIRECTORY start' postgres

[snip]

> at boot the error thrown is "No such login class: /usr/local/bin/pg_ctl -D
> /WEBSITE/DATADIRECTORY start"

From su(1):

      -c login-class
         Specify a login class.  You may only override the default class
         if you're already root.

Try removing the part that executes su because boot scripts are run by
root anyway.

--
Antti Harri

Reply | Threaded
Open this post in threaded view
|

Re: rc.local command for postgres

Graeme Lee
In reply to this post by Incomex
David B. wrote:

> trying to get postgres to start up at boot.  found this at
> postgresql's site
>
> On OpenBSD, add the following lines to the file /etc/rc.local:
>
> if [ -x /usr/local/pgsql/bin/pg_ctl -a -x
> /usr/local/pgsql/bin/postmaster ]; then
>    su - -c '/usr/local/pgsql/bin/pg_ctl start -l /var/postgresql/log
> -s' postgres
>    echo -n ' postgresql'
> fi
>
> my pg_ctl and postmaster executables are at /usr/local/bin, and have
> modified
> the script accordingly.  my script reads as follows:
>
> if [ -x /usr/local/bin/pg_ctl -a -x /usr/local/bin/postmaster ]; then
>  su - -c '/usr/local/bin/pg_ctl -D /WEBSITE/DATADIRECTORY start' postgres
> fi
>
> at boot the error thrown is "No such login class:
> /usr/local/bin/pg_ctl -D /WEBSITE/DATADIRECTORY start"
You may need to use

su postgres -c '/usr/local/bin/pg_ctl -D <path> start'


g

>
> the command I usually use after su'ing into postgres is:
>
> pg_ctl -D /WEBSITE/DATADIRECTORY start
>
> as /usr/local/bin is obviously in my PATH.
>
> Any Ideas?
>
> thanks
>
> _________________________________________________________________
> Stay in touch with old friends and meet new ones with Windows Live
> Spaces
> http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us 

Reply | Threaded
Open this post in threaded view
|

Re: rc.local command for postgres

Steve Murdoch
In reply to this post by Incomex
David B. wrote:

> trying to get postgres to start up at boot.  found this at
> postgresql's site
>
> On OpenBSD, add the following lines to the file /etc/rc.local:
>
> if [ -x /usr/local/pgsql/bin/pg_ctl -a -x
> /usr/local/pgsql/bin/postmaster ]; then
>    su - -c '/usr/local/pgsql/bin/pg_ctl start -l /var/postgresql/log
> -s' postgres
>    echo -n ' postgresql'
> fi
>
> my pg_ctl and postmaster executables are at /usr/local/bin, and have
> modified
> the script accordingly.  my script reads as follows:
>
> if [ -x /usr/local/bin/pg_ctl -a -x /usr/local/bin/postmaster ]; then
>  su - -c '/usr/local/bin/pg_ctl -D /WEBSITE/DATADIRECTORY start' postgres
> fi
>
> at boot the error thrown is "No such login class:
> /usr/local/bin/pg_ctl -D /WEBSITE/DATADIRECTORY start"
>
> the command I usually use after su'ing into postgres is:
>
> pg_ctl -D /WEBSITE/DATADIRECTORY start
>
> as /usr/local/bin is obviously in my PATH.
>
> Any Ideas?
>
> thanks
>
> _________________________________________________________________
> Stay in touch with old friends and meet new ones with Windows Live
> Spaces
> http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us 
>
>
>
I think the -c before the user specifies a login class not a command. I
use :

su _postgresql -c '/usr/local/bin/pg_ctl start -D /var/postgresql/data
-l /var/postgresql/log -s'

Steve

Reply | Threaded
Open this post in threaded view
|

Re: rc.local command for postgres

OpenBSD-9
In reply to this post by Incomex
David B. wrote:

> trying to get postgres to start up at boot.  found this at postgresql's
> site
>
> On OpenBSD, add the following lines to the file /etc/rc.local:
>
> if [ -x /usr/local/pgsql/bin/pg_ctl -a -x
> /usr/local/pgsql/bin/postmaster ]; then
>    su - -c '/usr/local/pgsql/bin/pg_ctl start -l /var/postgresql/log -s'
> postgres
>    echo -n ' postgresql'
> fi
>
> my pg_ctl and postmaster executables are at /usr/local/bin, and have
> modified
> the script accordingly.  my script reads as follows:
>
> if [ -x /usr/local/bin/pg_ctl -a -x /usr/local/bin/postmaster ]; then
>  su - -c '/usr/local/bin/pg_ctl -D /WEBSITE/DATADIRECTORY start' postgres
> fi
>
> at boot the error thrown is "No such login class: /usr/local/bin/pg_ctl
> -D /WEBSITE/DATADIRECTORY start"
>
> the command I usually use after su'ing into postgres is:
>
> pg_ctl -D /WEBSITE/DATADIRECTORY start
>
> as /usr/local/bin is obviously in my PATH.
>
> Any Ideas?
>
> thanks

Hi,

My rc.local has this:

# PostgreSQL DB
if [ -x /usr/local/bin/pg_ctl ]; then
        su -l _postgresql -c "nohup /usr/local/bin/pg_ctl start \
                -D /var/postgresql/data -l /var/postgresql/logfile \
                -o '-D /var/postgresql/data'"
        echo ' postgresql '
fi

and I have created the user _postgresql to run the RDBMS.

HTH

Fred
--
OpenBSD on the Zaurus C3200
http://www.crowsons.net/puters/zaurus.php

Reply | Threaded
Open this post in threaded view
|

Re: rc.local command for postgres

Stuart Henderson
In reply to this post by Incomex
On 2006/10/20 00:44, David B. wrote:
> trying to get postgres to start up at boot.  found this at postgresql's
> site
>
> On OpenBSD, add the following lines to the file /etc/rc.local:

...there is more to do than just that.

please, follow the instructions displayed when the package was
installed -

$ pkg_info -M postgresql-server                        
Information for postgresql-server-8.1.4

Install notice:
For more information on using PostgreSQL in an OpenBSD environment,
please see /usr/local/share/doc/postgresql/README.OpenBSD.

Reply | Threaded
Open this post in threaded view
|

Re: rc.local command for postgres

John Wright-6
In reply to this post by Incomex
If you've installed postgres from the package you can find what to add to
rc.local in /usr/local/share/doc/postgresql/README.OpenBSD

Reply | Threaded
Open this post in threaded view
|

Re: rc.local command for postgres

Craig Skinner
In reply to this post by Incomex
On Fri, Oct 20, 2006 at 12:44:46AM -0600, David B. wrote:
> trying to get postgres to start up at boot.  found this at postgresql's site
>

The postgresql package has some suggestions.

I use:

/etc/rc.local

echo -n ' postgresql'
su -l _postgresql -c "nohup /usr/local/bin/pg_ctl start -D /var/postgresql/data"


/etc/rc.shutdown

echo -n ' postgresql '
su -l _postgresql -c "/usr/local/bin/pg_ctl stop -m fast -D /var/postgresql/data"
rm -f /var/postgresql/data/postmaster.pid /tmp/.s.PGSQL.5432 /tmp/.s.PGSQL.5432.lock
echo

Reply | Threaded
Open this post in threaded view
|

Re: rc.local command for postgres

Fco. Valladolid Hdez.
In reply to this post by Incomex
Hi

Maybe you need do a sleep 1 before close the if .. fi  loop for let to
pg_ctl go to background.

regards.


On 10/20/06, David B. <[hidden email]> wrote:

>
> trying to get postgres to start up at boot.  found this at postgresql's
> site
>
> On OpenBSD, add the following lines to the file /etc/rc.local:
>
> if [ -x /usr/local/pgsql/bin/pg_ctl -a -x /usr/local/pgsql/bin/postmaster
> ];
> then
>    su - -c '/usr/local/pgsql/bin/pg_ctl start -l /var/postgresql/log -s'
> postgres
>    echo -n ' postgresql'
> fi
>
> my pg_ctl and postmaster executables are at /usr/local/bin, and have
> modified
> the script accordingly.  my script reads as follows:
>
> if [ -x /usr/local/bin/pg_ctl -a -x /usr/local/bin/postmaster ]; then
> su - -c '/usr/local/bin/pg_ctl -D /WEBSITE/DATADIRECTORY start' postgres
> fi
>
> at boot the error thrown is "No such login class: /usr/local/bin/pg_ctl -D
> /WEBSITE/DATADIRECTORY start"
>
> the command I usually use after su'ing into postgres is:
>
> pg_ctl -D /WEBSITE/DATADIRECTORY start
>
> as /usr/local/bin is obviously in my PATH.
>
> Any Ideas?
>
> thanks
>
> _________________________________________________________________
> Stay in touch with old friends and meet new ones with Windows Live Spaces
>
> http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
>
>


--
---
BSD - Unix simplicity.
Francisco Valladolid Hdez.
[hidden email]