|
|
Invoking the Terminal in a StartupItem?
|
|
|
|
Mac Elite
Join Date: Oct 1999
Location: Brooklyn, New York, USA
Status:
Offline
|
|
Hi guys. I'm trying to get PostgreSQL to start up every time my Mac mini does, but that requires Terminal access. Some guy created a utility to do this (which some other guy fixed), and I've ended up with this relevant excerpt in a StartupItem document:
StartService ()
{
if [ "${POSTGRES:=-YES-}" = "-YES-" ]; then
ConsoleMessage "Starting PostgreSQL database server"
su - postgres -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l /usr/local/pgsql/logfile -o -i'
fi
}
However, it doesn't work, and when I test it in the Terminal (sudo /Library/StartupItems/PostgreSQL/PostgreSQL start) I get the error /usr/local/pgsql/logfile - permission denied.
The basic parameters of this are: I am logging in as one user, let's say "thejoshu", and the owner of these folders (/usr/local/postgres/[...]) is another user, "postgres." By hand, in the Terminal, I use Apple's recommendation to start PostgreSQL:
su -l postgres
[password]
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
I expect the problem is that there's no place in this code for me to provide postgres's password before starting postgreSQL?
Any ideas? Thanks!
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Apr 2002
Location: california
Status:
Offline
|
|
If you are root (or using sudo) you should be able to su to any user without giving that user's password. This is how the script can start postgres as the postgres user without having the password in the script.
That said, I don't run postgres on my Mac so I have no idea what your actual problem is.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 1999
Location: Brooklyn, New York, USA
Status:
Offline
|
|
OK, so, is the idea that postgres maybe doesn't - for some reason - own that logfile? If I use sudo to su to that user, it'll give me that issue because it's owned by another user? Maybe the tragedy is that the logfile is owned by someone else. Now, to track down the logfile.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 1999
Location: Brooklyn, New York, USA
Status:
Offline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|