Opened 16 years ago

Closed 15 years ago

#2904 closed defect (fixed)

RFE: Postgresql8 port should have an rc.d startup script

Reported by: decibel (Jim Nasby) Owned by: mww@…
Priority: Normal Milestone:
Component: ports Version: 1.0
Keywords: Cc:
Port:

Description

I believe it used to have one, or maybe just postgresql7 had one. I can provide one if it would help.

Attachments (2)

PostgreSQL-8 (792 bytes) - added by decibel (Jim Nasby) 15 years ago.
New startup script
StartupParameters.plist (115 bytes) - added by decibel (Jim Nasby) 15 years ago.
New plist

Download all attachments as: .zip

Change History (9)

comment:1 Changed 16 years ago by mww@…

Totally true - I'll happily accept a patch for that; though better than a rc.d-style script, would be to use the "startupitem" commands - a much cleaner approach. (see e. g. the net/squid or net/openssh Portfile)

comment:2 Changed 16 years ago by decibel (Jim Nasby)

Ok, I'll try and hack something together, though it's very possible it won't be until the next time I restart my powerbook and find postgresql not running... :P In the meantime, you might take a gander at http://lnk.nu/freebsd.org/29h.tmpl.

comment:3 Changed 16 years ago by snu@…

Summary: Postgresql8 port should have an rc.d startup scriptRFE: Postgresql8 port should have an rc.d startup script

comment:4 Changed 16 years ago by mww@…

I've added a "server" variant to postgresql8 - please test and report back!

comment:5 Changed 15 years ago by decibel (Jim Nasby)

It's pretty seriously broken on my system...

First... /Library/StartupItems/PostgreSQL-8/PostgreSQL-8: line 8: PGDATA: unbound variable

So I changed it to: PGDATA=${PGDATA:='/opt/local/var/db/postgresql8'} export PGDATA

then I realized I needed to add POSTGRESQL-8 to /etc/hostconfig. Except that generated errors all over the place, because of the -. So I changed the startup script to look for POSTGRESQL8

Now I get... Running command (28441): /Library/StartupItems/PostgreSQL-8/PostgreSQL-8 start Unable to load localization strings for /Library/StartupItems/PostgreSQL-8 Starting PostgreSQL-8 pg_ctl: no database directory specified and environment variable PGDATA unset Try "pg_ctl --help" for more information.

I also pulled NFS as a dependancy out of the plist; I can't think of any reason why it would need to be there.

Also, the sudden change of user and data directory is going to confuse a hell of a lot of people. The port should at least notify the user about it if the old user (postgres) exists. Using a shortname > 8 characters is also a bad idea; ls -la truncates at 8 characters. Is there really any advantage to using a different user? Actually, after trying to cp -R ~postgres/defaultdb ~postgres8 && chown -R postgres8 ~postgres8/defaultdb I still couldn't start the database due to permission errors on ~postgres8/defaultdb.

The port should also let the user know that they need to add POSTGRESQL8=-YES- to /etc/hostconfig. Additionally, using ~postgresql8 as the data directory is a bad idea; you should use a subdirectory of ~postgresql8 instead.

I've finally managed to get it running be using -D with pg_ctl. I'll attach all the relevant files.

Changed 15 years ago by decibel (Jim Nasby)

Attachment: PostgreSQL-8 added

New startup script

Changed 15 years ago by decibel (Jim Nasby)

Attachment: StartupParameters.plist added

New plist

comment:6 Changed 15 years ago by norman@…

hi there, thank you for all your efforts, but still, I ported "postgresql8 +sever" a week ago and I tried it again today, but the server still would not start upon startup. the startup script is there, but the portfile does not install it for some reason. I am not a programmer unfortunately. is there somebody out there who can fix the portfile, please?

cheers

Norman

comment:7 Changed 15 years ago by mww@…

Resolution: fixed
Status: newclosed

ok, now (or if you are on 10.4 with dp v1.2) the startup-code works. I've tested it with startupitem-code from HEAD on a 10.4 system with the StartupItem shell code. Should work on 10.3 out of the box, on 10.4 with the imminent update of port to 1.2.

Note: See TracTickets for help on using tickets.