PostgreSQL rc.d script outputting fortunes

From TykWiki
Revision as of 11:45, 3 January 2010 by Tykling (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

I've been having a weird problem with the postgresql rc.d script in a FreeBSD jail. I finally figured out today how to fix it and wanted to put it on here so I dont forget.

The problem

Whenever I call the postgresql rc.d script to start/stop/restart/whatever the postgres server I would get a fortune from freebsd-tips like when you log in:

[root@wackbox163 /usr/local/pgsql]# /usr/local/etc/rc.d/postgresql restart
Any user that is a member of the wheel group can use "su -" to simulate
a root login. You can add a user to the wheel group by editing /etc/group.
                -- Konstantinos Konstantinidis <>
server stopped
[root@wackbox163 /usr/local/pgsql]#

The solution

I have been completely unable to figure out why this was happening, until a friend of mine reminded me to check .profile. I opened up /usr/local/pgsql/.profile and commented out the following line:

[ -x /usr/games/fortune ] && /usr/games/fortune freebsd-tips

And now I don't get the any tips when using the postgresql rc.d script:

[root@wackbox163 /usr/local/pgsql]# /usr/local/etc/rc.d/postgresql restart
server stopped
[root@wackbox163 /usr/local/pgsql]#


This happens because the postgresql rc.d script switches user to the postgresql pgsql user before executing the actual start/stop commands. For some reason, and only on this specific machine, the user switch with su called .profile which in turn ran the fortune system. The reason is probably that I always install "minimal" (in sysinstall) FreeBSD machines these days. The machine that had this problem is older and was installed as "standard" (in sysinstall). This means that /usr/games/fortune/ exists on this machine and not on a lot of my newer machines. The fortune line from .profile will only run if the fortunes are installed, of course.