changing user within a post install.
Dennis Veatch
dveatch at woh.rr.com
Thu Apr 1 14:40:28 GMT 2004
On Thursday 01 April 2004 01:55 pm, Auke Kok wrote:
> Dennis Veatch wrote:
> > I have a POST_INSTALL module for postgresql but can't get one part to
> > work. It looks like this;
> >
> > -------------------------------------------------------------------------
> >---------------------------------------- # Check the default directory
> > exists, if not create and set owner.
> >
> > if [ ! -d "/var/lib/pgsql" ]; then
> > mkdir -p /var/lib/pgsql
> > chown postgres:postgres /var/lib/pgsql
> > fi
> >
> > # login as postgres and intitialize the database, if it does not exist.
> >
> > su postgres &&
> > cd /var/lib/pgsql &&
> > /usr/bin/initdb -D /var/lib/pgsql/data
> >
> > -------------------------------------------------------------------------
> >--------------------------------------------
> >
> > It does create /var/lib/pgsql. It seems to be changing to the postgres
> > user as the prompt changes from "root at driller" to "sh-2.05". But that's
> > all it seems to do at this point. Doing the commands manually, works
> > fine. No clue how to handle this within POST_INSTALL.
>
> su called from a shell script *must* be passed a command to perform. you
> can either perform it as root and do a chown on the files later, or do
> something like:
>
> su postgres -c 'cd /var/lib/pgsql && /usr/bin/initdb -D
> /var/lib/pgsql/data'
>
Thanks sofar, that's the ticket.
Now I just need to add a bit of logic to detect /var/lib/pgsql/data exists so
as not to reinitialize the database if one already exists.
--
Registered Linux user 193414
http://counter.li.org
More information about the Lunar-dev
mailing list