1

I want to change it to copy, rather than move.

OK, some googlefu suggests it's in this service raspberrypi-net-mods.service

https://github.com/RPi-Distro/raspberrypi-net-mods/blob/master/debian/raspberrypi-net-mods.service

An idea how to locate this once installed?

Stretch Lite 2019-04-08

Ghanima
  • 15,855
  • 15
  • 61
  • 119

3 Answers3

7

As Dirk and Ghanima stated in their answers, the service may be overwritten by future updates/upgrades of the system. But systemd has a mechanism to avoid this. You can use a drop in file. An update/upgrade will only modify the main service. The drop in file is not effected by it and will also modify the updated main service. You can simply create a drop in file with:

rpi ~$ sudo systemctl edit raspberrypi-net-mods.service

In the empty editor insert these statements, save them and quit the editor:

[Service]
ExecStart=
ExecStart=/bin/cp /boot/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf

The first empty ExecStart= is important. It will suppress the original ExecStart in the main service.

Check the source of the whole service with:

rpi ~$ systemctl cat raspberrypi-net-mods.service

You will find the drop in at the end.

Ingo
  • 42,107
  • 20
  • 85
  • 197
2

It's a service. In this case it's raspberrypi-net-mods.service.

systemctl status raspberrypi-net-mods.service will give status, including full path of the service file. systemctl cat raspberrypi-net-mods.service will show path and contents.

Be aware that an update/upgrade could modify the service file in the future.

Dirk
  • 3,541
  • 3
  • 18
  • 25
2

As Dirk's answer pointed out the raspberrypi-net-mods.service is responsible for relocating wpa_supplicant.conf. It is located in /etc/systemd/multi-user-target.wants/.

This is the actual code (see here):

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/mv /boot/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf
ExecStartPost=/bin/chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf

You could change that mv to cp and the script would do what you want. However, as Dirk's answer already pointed out, any future updates/upgrades of the system might overwrite that file. See Ingo's answer how to avoid that.

Ghanima
  • 15,855
  • 15
  • 61
  • 119