Starting Daemons - Wiki page?

Chris Ricker kaboom at oobleck.net
Sun Apr 17 05:26:16 UTC 2005


On Fri, 15 Apr 2005, Michael Peters wrote:

> A feedback comment I received is that it isn't a good idea to start the
> service from the %post scriplet, as it can cause problems with
> installers.
> 
> What was suggested is that I look at what the openssh-server script
> does. It does not start the service, it only adds it to the chkconfig
> system so it is configured to start at next system boot.

Actually, I'd say doing that is a bad idea as well. Use chkconfig to add 
it, but have it set not to autostart in any run level. The less default-on 
services, the better....

Standard practice is something like

in the spec:

%post
...
chkconfig --add service_name
...

%preun
...
if [ "$1" = 0 ]; then
	service service_name stop
	chkconfig --del service_name
fi
...

%postun
...
if [ "$1" != 0 ]; then
	service service_name condrestart
fi
...

(%post adds to chkconfig, %preun conditionally stops only if running, 
%postun conditionally restarts only if running already)


in the /etc/init.d/service_name file:

# chkconfig: - startnum stopnum

that way it'll register through chkconfig, but not autostart for least 
surprise

I had thought that fedora-rpmdevtools came with a full-blown template spec 
that included something along those lines, but it doesn't seem to be in 
the newest version of that rpm.... Maybe I'm misremembering?

later,
chris




More information about the fedora-extras-list mailing list