Disable dnsmasq/service through reboot

Hola Fuzon boards,

I’m an older hand at *nix administration, but messing with my first debian-core(ish) distro in forever.

I’ve installed dnsmasq from apt-get - wanted to take DHCP out of the hands of my wireless router, and no desire to revisit BIND. Went as I expected, except… the service starts at every reboot, when I’ve asked nicely for it not to while I monkey with some configuration settings (such as dhcp-authoritative.)

I’ve tried disabling through chkconfig, service, systemctl,insserv dependency, rc.local, then discovered the /DietPi/dietpi/dietpi-services from that file and tried everything(?) there, and manually inspected every /etc/rc?.d directory by hand - even tried setting ENABLED=0 in /etc/dnsmasq.conf. Still get dnsmasq firing on every reboot.

What is the magic option I’m missing? I’ve resorted to apt-get remove just to ensure it wasn’t an installed service by default.

Thanks, and this bump aside, loving this package - especially how lean it is!

Much appreciated,

Hi Erik,

/DietPi/dietpi/dietpi-services controls all program services that are installed with dietpi-software. This allows us to control when each service starts/stops during boot, it also allows us to stop programs during dietpi-backup (for example) and restart them afterwards.

So 2 options:
Option 1
If you want to completely disable dnsmasq service and prevent it from ever running:

systemctl mask dnsmasq
#use systemctl unmask to renable

Option 2
Because /DietPi/dietpi/dietpi-services script checks various methods for available programs (dpkg, init.d or systemd file), we will need to modify its sourcecode to disable dnsmasq being picked up as “available”.
Add the following to this line:

		#Disable dnsmasq control
		for ((i=0; i<${#aSERVICE_NAME[@]}; i++))
			if [ "${aSERVICE_NAME[$i]}" = "dnsmasq" ]; then

Its untested, but let me know if you get any issues. Just remember, when you update DietPi, you will need to add the above code in again. This is because all DietPi scripts get overwritten during the update with the latest versions.

Ah, thanks. If I’m reading your source correctly, it looks like masking may not even take care of it if there’s an init.d entry.

Still that helps me identify the problem. Will give it a go and report back. Or, is there any consequence if I just remove the dnsmasq line in your aSERVICE_NAME array? I know it wouldn’t survive an upgrade - short of something kludgy in rc.local like

 _dietpiver=`cat /DietPi/dietpi/.version`; sed -i".${_dietpiver}.bak" '/^\s*\"dnsmasq\"\s*$/d' /DietPi/dietpi/dietpi-services 2>/dev/null

Speaking of - mind if I ask what you’re probing for dnsmasq for - such that some dietpi software would leverage it if it was there? I’d be interested in looking at some way to determine if the service you wanted it for was installed before adding it to your aSERVICE_NAME list - this is already a thorny enough problem with two startup service locations.