I have a folder in the pi/home directory with python code. Is there a way to update (replace) these files by using one of the usb ports? I would like to be able to plug in the usb, reboot the pi, if there is a usb drive on boot, copy and replace the files in pi/home folder with the ones on the usb then automatically power back down.
1 Answer
Yes, you can.
First configure your Raspberry Pi to auto-mount USB Storage Devices (guide here).
Then create a script that checks the folders under /media/
where the mounted USB stick would be. If it finds your scripts, replace the old ones with the new ones.
Configure your script to run at boot by editing your /etc/rc.local
(guide here)
-
Please take note that using
/etc/rc.local
has limitations due to Compatibility with SysV. We have seen many problems here on this site using it. Following the recommendation of the developers from systemd you should avoid using it.– IngoCommented Jul 10, 2019 at 10:43