So I'm trying to find a way to permanently disable and enable the wifi adapter on demand.
Now most questions regarding this here seem to have the problem of rfkill blocking their wifi by default and have to add a service to unblock it on boot, but I'm having the exact opposite issue.
If I run rfkill block wifi, that does indeed turn off the wifi. Then I reboot the system, and the wifi is up again automatically (wlan0 again listed in ifconfig).
I'd expect some service to be re-enabling it on boot, maybe something networkmanager related perhaps.
If I list all the services that have rfkill somewhere I can only find two:
ubuntu@pi:/lib/systemd/system$ grep -r "rfkill" .
./systemd-rfkill.service:Documentation=man:systemd-rfkill.service(8)
./systemd-rfkill.service:RequiresMountsFor=/var/lib/systemd/rfkill
./systemd-rfkill.service:BindsTo=sys-devices-virtual-misc-rfkill.device
./systemd-rfkill.service:After=sys-devices-virtual-misc-rfkill.device systemd-remount-fs.service
./systemd-rfkill.service:ExecStart=/lib/systemd/systemd-rfkill
./systemd-rfkill.socket:Description=Load/Save RF Kill Switch Status /dev/rfkill Watch
./systemd-rfkill.socket:Documentation=man:systemd-rfkill.socket(8)
./systemd-rfkill.socket:BindsTo=sys-devices-virtual-misc-rfkill.device
./systemd-rfkill.socket:After=sys-devices-virtual-misc-rfkill.device
./systemd-rfkill.socket:ListenSpecial=/dev/rfkill
Doing a systemctl disable/enable of both doesn't seem to change anything. The console command works regardless of them running too, so I'm not sure what's even the point of having them in the first place.
In my setup wlan0 is set as managed by the networkmanager, so I suppose it's possible that there's some service contained in it that sneakily re-enables it on boot, but I'm not sure where to start looking.
I've also attempted to add a new service that runs on boot after everything else and just does rfkill block wifi, but that still somehow doesn't work (if I ssh and run it then it does work though, oddly enough). Besides, that would be too late as the adapter would already be transmitting for the duration of the boot which is undesired.
Any tips on how to make this thing stay dead? This is on Lubuntu 16.04 with lxde.
Thanks :)