- First I Googled and found the documentation about creating the file /boot/ssh
- I never managed to find any official documentation on creating the file /boot/wpa_supplicant.conf (Though I did find lots of references that stated that it did work.)
- Then I studied https://github.com/RPi-Distro/pi-gen extensively.
- But I couldn't find anything that looked for /boot/ssh or /boot/wpa_supplicant.conf
- Then I started looking for packages that may contain the implementation.
Code: Select all
~/src/pi-gen $ cat $(find stage[012] -type f -name '*package*') | tr " " "\n" | grep 'pi' | sort libraspberrypi-bin libraspberrypi-dev libraspberrypi-doc libraspberrypi0 pi-bluetooth python-rpi.gpio raspberrypi-bootloader raspberrypi-net-mods raspberrypi-sys-mods raspi-config raspi-copies-and-fills rpi-update
- I grabbed all the matching packages I could find in https://archive.raspberrypi.org/debian/pool/main/r/
- I got lucky with raspberrypi-net-mods and raspberrypi-sys-mods
raspberrypi-net-mods.service
Code: Select all
[Unit]
Description=Copy user wpa_supplicant.conf
ConditionPathExists=/boot/wpa_supplicant.conf
Before=dhcpcd.service
[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
[Install]
WantedBy=multi-user.target
Similarly, but slightly more clever.
raspberrypi-sys-mods.sshswitch.service
Code: Select all
[Unit]
Description=Turn on SSH if /boot/ssh is present
ConditionPathExistsGlob=/boot/ssh{,.txt}
After=regenerate_ssh_host_keys.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c "update-rc.d ssh enable && invoke-rc.d ssh start && rm -f /boot/ssh ; rm -f /boot/ssh.txt"
[Install]
WantedBy=multi-user.target