LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   rc.dnsmasq restart messages (https://www.linuxquestions.org/questions/slackware-14/rc-dnsmasq-restart-messages-4175694245/)

vineetmehta 04-25-2021 08:06 AM

rc.dnsmasq restart messages
 
Hi friends,

I am using Slackware current, shouldn't the 'rc.dnsmasq' not display stop and start message when we restart the service?

It would be informative and useful to the user.

Thank you.

elcore 04-25-2021 11:11 AM

Yes, very interesting, don't see the benefit personally, but feel free to write the thing and propose a patch.
Problem's that the manual notes different signals doing very different things, for example:

Code:

      When it receives a SIGHUP, dnsmasq clears its cache and then re-loads /etc/hosts and /etc/ethers and any file given by --dhcp-hostsfile, --dhcp-hostsdir,  --dhcp-optsfile,
      --dhcp-optsdir,  --addn-hosts  or  --hostsdir.  The  DHCP  lease  change  script  is  called  for  all  existing  DHCP  leases.  If  --no-poll is set SIGHUP also re-reads
      /etc/resolv.conf.  SIGHUP does NOT re-read the configuration file.

For this reason I don't use the rc functions and just send a SIGHUP, my opinion is that rc.dnsmasq restart should send a SIGHUP, but then someone else may expect it to reload a config file..
Real fix for this situation would be to make multiple new functions in rc.dnsmasq, one for each supported signal, and only then make it echo a different message for each of them.

If rc.dnsmasq restart just kills the server and starts another one, the message is correct.
If you don't agree, just make it echo whatever message you want on restart function, it's easy enough.

Petri Kaukasoina 04-25-2021 11:41 AM

'/etc/rc.d/rc.dnsmasq stop' (or restart) now kills any program called dnsmasq. Let's kill the process with PID in /var/run/dnsmasq.pid, if it's called dnsmasq:

Code:

--- rc.dnsmasq.orig    2006-01-31 22:51:05.000000000 +0200
+++ rc.dnsmasq  2021-04-25 19:31:19.399115050 +0300
@@ -11,7 +11,10 @@
 
 # Stop dnsmasq:
 dnsmasq_stop() {
-  killall dnsmasq
+  if pgrep -l -F /var/run/dnsmasq.pid 2>/dev/null | grep -q dnsmasq; then
+    echo "Stopping dnsmasq."
+    pkill -F /var/run/dnsmasq.pid 2>/dev/null
+  fi
 }
 
 # Restart dnsmasq:



All times are GMT -5. The time now is 11:41 AM.