Thread: Starting postmaster on startup in Mac OS X 10.2.4 via shell script
Colleagues, I recently installed PostgreSQL 7.3.2 from source on Mac OS X 10.2.4, and I am wanting to have the server start automatically when the OS starts up. However, I am having trouble with the shell script to start postmaster. I can manually su into the user account under which postmaster runs (named 'pgsql', surprisingly I am sure) and execute the following command line successfully: #: /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l logfile -i -o The shell script equivalent which I am trying to use is as follows: su -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l logfile - i -o' pgsql Upon login, I open a terminal and run 'pg_ctl status' and it confirms that postmaster is not running. I have also tried the following permutations for the shell script command line: su - pgsql -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l logfile -i -o' su -l pgsql -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l logfile -i -o' su -m pgsql -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l logfile -i -o' I am quite new to PostgreSQL, but its feature set seems unparalleled in open source database platforms, so I really want to get this thing running. Since I am prompted for the password when I run 'su -l pgsql' manually, I can't help but think that I am failing to acquire the appropriate context under which postmaster must run. My logfile also seems to indicate that. I am sure this is some neophyte error on my part, but if one of the sages would be so kind as to direct me, I would be most grateful. Regards, -- Barry C. Hawkins Systems Consultant All Things Computed barry.hawkins@allthingscomputed.com 404-795-9147 voice/fax
There is a startup item listed on Marc Liyanage's page http://www.entropy.ch/software/macosx/postgresql/ Look for pgsql-startupitem-1.2.pkg.tar.gz Never tried it myself though..... adam > Colleagues, > I recently installed PostgreSQL 7.3.2 from source on Mac OS X 10.2.4, and I > am wanting to have the server start automatically when the OS starts up. > However, I am having trouble with the shell script to start postmaster. > I can manually su into the user account under which postmaster runs > (named 'pgsql', surprisingly I am sure) and execute the following command line > successfully: > > #: /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l logfile -i -o > > The shell script equivalent which I am trying to use is as follows: > > su -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l logfile - > i -o' pgsql > > Upon login, I open a terminal and run 'pg_ctl status' and it confirms that > postmaster is not running. I have also tried the following permutations for > the shell script command line: > > su - pgsql -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l > logfile -i -o' > > su -l pgsql -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l > logfile -i -o' > > su -m pgsql -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l > logfile -i -o' > > I am quite new to PostgreSQL, but its feature set seems unparalleled in > open source database platforms, so I really want to get this thing running. > Since I am prompted for the password when I run 'su -l pgsql' manually, I > can't > help but think that I am failing to acquire the appropriate context under > which > postmaster must run. My logfile also seems to indicate that. I am sure this > is some neophyte error on my part, but if one of the sages would be so kind as > to direct me, I would be most grateful. > > Regards, -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
> I recently installed PostgreSQL 7.3.2 from source on Mac OS X 10.2.4, > and I > am wanting to have the server start automatically when the OS starts > up. The simple way is to download and install this package: http://www2.entropy.ch/download/pgsql-startupitem-1.2.pkg.tar.gz The main page: http://www.entropy.ch/software/macosx/postgresql/ Jeff
Re: Starting postmaster on startup in Mac OS X 10.2.4 via shell script
From
"Barry C. Hawkins"
Date:
Adam and Jeff, Thank you for your replies. I actually tried using Marc Liyanage's startup item prior to attempting to write my own. In fact, Marc uses the following syntax, which is the same as one of the ones I tried, except that his pg_ctl path and unprivileged account name differ from mine and the order of the two switches -i and -o are reversed: su - postgres -c '/usr/local/bin/pg_ctl start -D /usr/local/pgsql/data -l logfile -o -i' The only difference between what Liyanage does and what I did is the method for creating the user account to run postmaster. I used NetInfo manager much in the way described on Apple's web article for the setup of MySQL (http://developer.apple.com/internet/macosx/osdb.html - see "Adding a User with NetInfo Manager"). This worked fine for installing MySQL from source and configuring it to start automatically; of course, the user account for starting mysqld can be passed as a command line argument. In an effort to test my hypothesis of the user creation method being an issue, I deleted user pgsql in NetInfo Manager and recreated it through the Accounts tool in System Preferences in OS X. I then installed Marc Liyanage's startup item package over my own and modified the user account and path to pg_ctl. I then issued 'sudo chmod -R pgsql /usr/local/pgsql'. As before, I am able to su into pgsql and start postmaster, but the startup item fails. Creating a user in NetInfo Manager foregoes the creation of a home directory and a few other minor tasks. The home directory for a user created in NetInfo manager is /dev/null by default, so I thought that perhaps this was causing a hiccup with the su directive passed in the script. I have now eliminated that possibility. Any other ideas? Regards, -- Barry C. Hawkins Systems Consultant All Things Computed barry.hawkins@allthingscomputed.com 404-795-9147 voice/fax Quoting Adam Witney <awitney@sghms.ac.uk>: > > There is a startup item listed on Marc Liyanage's page > > http://www.entropy.ch/software/macosx/postgresql/ > > Look for pgsql-startupitem-1.2.pkg.tar.gz > > Never tried it myself though..... > > adam > > > > Colleagues, > > I recently installed PostgreSQL 7.3.2 from source on Mac OS X 10.2.4, and > I > > am wanting to have the server start automatically when the OS starts up. > > However, I am having trouble with the shell script to start postmaster. > > I can manually su into the user account under which postmaster runs > > (named 'pgsql', surprisingly I am sure) and execute the following command > line > > successfully: > > > > #: /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l logfile -i > -o > > > > The shell script equivalent which I am trying to use is as follows: > > > > su -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l > logfile - > > i -o' pgsql > > > > Upon login, I open a terminal and run 'pg_ctl status' and it confirms > that > > postmaster is not running. I have also tried the following permutations > for > > the shell script command line: > > > > su - pgsql -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data > -l > > logfile -i -o' > > > > su -l pgsql -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data > -l > > logfile -i -o' > > > > su -m pgsql -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data > -l > > logfile -i -o' > > > > I am quite new to PostgreSQL, but its feature set seems unparalleled in > > open source database platforms, so I really want to get this thing > running. > > Since I am prompted for the password when I run 'su -l pgsql' manually, I > > can't > > help but think that I am failing to acquire the appropriate context under > > which > > postmaster must run. My logfile also seems to indicate that. I am sure > this > > is some neophyte error on my part, but if one of the sages would be so kind > as > > to direct me, I would be most grateful. > > > > Regards, > > > -- > This message has been scanned for viruses and > dangerous content by MailScanner, and is > believed to be clean. > >