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

Re: Init.d script, preventing start of one service



I am redirecting to debian-mentors, imho the more appropriate list.

On Tue, Nov 11, 2003 at 04:27:03PM +0100, Sylvain LE GALL wrote:
> In one of the package i maitain i have a config script which begin by
> asking if the service attached to this package need to be run. I use a
> variable ( stored in /etc/default/mldonkey -- LAUNCH_AT_STARTUP="yes" )
> to determine if i need to run the service or not.

> If the variable is set to yes, the init script launch the service,
> otherwise it does nothing. 

I think that is the best solution currently possible.

> The user ask me if i can use update-rc.d to create/remove symlink
> depending on the former LAUNCH_AT_STARTUP value.

IMHO it is dubious whether you are allowed to do that, it would work
*basically*[1] like this in postinst:
------------------
db_get mldonkey/runservice
runme="$RET"
if [ "$RET" = "true" ]
  update-rc.d -f remove mldonkey
  update-rc.d mldonkey defaults
else
  update-rc.d -f remove mldonkey
  update-rc.d mldonkey stop 20
fi
...
invoke-rc.d mldonkey start
------------------
And invoke-rc.d will only start the service if it has a start-entry in
the sysvinit system for the current runlevel.

The big problem is that you loose user configuration, i.e. if $user
has set up his system to run mldonkey only in runlevel5 you will nuke
it.

And there is no way around it, as it is impossible to query what links
currently exist. (You cannot do ls in the symlink-directories, see
file-rc), you may only interface with the init-stuff with invoke- and
update-rc.d.

> What is the standard solution for doing this in debian?

Afaict the standard solutions are:
- ship daemon and clients in separate packages (ftp, ssh, nfs, ...) to
  circumvent the problem (no option for mldonkey afaict)
- Choose a default and let the user change it by hand instead of via
  dpkg-reconfigure. 

> ps : i know ssh use a file to launch or not sshd, is it a good
> solution?

Imnsho it is worse than using the default-file. - The default file at
least provides a rather standardized location.
         cu andreas
[1] There is lots of sugar-coating necessary, you don't want
remove+(set again) if there was no change.
-- 
"See, I told you they'd listen to Reason," [SPOILER] Svfurlr fnlf,
fuhggvat qbja gur juveyvat tha.
Neal Stephenson in "Snow Crash"



Reply to: