I have just installed samba 2.2.5-r1 I copied over an old configuration file to get it working. I start samba by using the script /etc/init.d/samba start No errors reported by start script, samba is not running. Check logs for the error, change config file to solve problem. I rerun /etc/init.d/samba start. It says samba is already started, so it will not start it. ok I run /etc/init.d/samba stop It says it cannot kill samba as its pid's arent running. I am stuck. After an hour I removed the link ${svcdir}/started/samba Then I can run /etc/init.d/samba start. BUG: Given that samba fails quietly (which is bad), why does "/etc/init.d/samba stop" not fix the problem. After reading runscripts.sh, I found that at the end of svc_stop(), if stop() has failed, the ${svcdir}/started/samba link is recreated. (Why I am not sure). The comment says that if the stop fails and the system is halting, then recreate the link. It defines "system is halting" as, runlevel as neither in "reboot" or "shutdown". The runlevel "default", not "reboot" or "shutdown" so the statement is true, but the system is not halting. As per the comment, the logic is false.
-------------------------------------------------------------------------------- if [ "${retval}" -ne 0 ] then #did we fail to stop? create symlink to stop multible attempts at #runlevel change if [ -d ${svcdir}/failed ] then ln -sf /etc/init.d/${myservice} ${svcdir}/failed/${myservice} fi #if we are halting the system, do it as cleanly as possible if [ "${SOFTLEVEL}" != "reboot" ] && [ "${SOFTLEVEL}" != "shutdown" ] then ln -sf /etc/init.d/${myservice} ${svcdir}/started/${myservice} fi fi ------------------------------------------------------------------------------- No, its not. If it fails to stop, it means it *could* still be running. The admin should thus intervene, and check what the problem is. This is why the link is recreated. If you also maybe did read a bit more, you would have seen that if you ran: # /etc/init.d/samba zap it would have removed the link. If the system is shutting down, or rebooting, it will set $SOFTLEVEL to either "reboot" or "shutdown", even if there is no such runlevels in /etc/runlevels. Please read the whole /sbin/runscript.sh and /sbin/rc and then comment again.
if you just do /etc/init.d/samba it'll show you the help also, if you just run `runscript` it'll show you the help
I was aware that the link was removed earlier in the function. (which is presumably what I wanted) That is why I knew to see that the link was recreated at the point in question. So if I get this correctly, what that code means is that if the stop has failed and the runlevel is not shutdown or reboot, then recreate the link, as the service may not have been shutdown at all, and may still be running. And that when halting (either reboot or shutdown) don't recreate the link as init will kill the daemon and the system should be clean before we go down. This makes much more sense to me. I read the comment (way) wrong. Maybe the comment could state the above rationale. As for my original problem, I will assume it lies with samba (and its start script), not the rc-scripts. When Samba fails, it can do so quietly without telling its start script (by way of a return value to the start-stop-daemon tool). This puts the rc-scripts system in an incorrect state of thinking the daemon is started when it has not. Should the rc-scripts be able to handle this somehow? If I were to fix the samba start script, without fixing samba, to get around this, what could I do? I had to go through alot of reading to get the one service started. ;) btw, so far this rc system is pretty awesome. I have only played with is for a day or so, but its intuitive, clean (especially for bourne), and well executed. Thanx.
Ditto. Yep, samba have that problem of failing to start without letting start-stop-daemon know about it. Actually, it is in the works to check that the service did stop/start. Just a bit hairy, as I dont want to implement something that I will have to change 20 times again due to design problems. If you have a look at /sbin/functions.sh, you will see there is already some initial code for stop-daemon(), which uses the pid of the service to check if it stopped or not. It is however very alpha code as i havent had time to work on it again. The idea is also to implement a start-daemon(), which uses checkpid() to see if it did start.
*** Bug 7812 has been marked as a duplicate of this bug. ***
*** Bug 9929 has been marked as a duplicate of this bug. ***
*** Bug 15141 has been marked as a duplicate of this bug. ***
I've put code in CVS which will provide a working wrapper to start-stop-daemon which should fix this nicely. Will be in baselayout-1.12.0
should be much better now