[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Starting Daemons - Wiki page?



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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]