Unattended update after plug in USB memory

My platform: iris+imx8x

I found some interesting differences between Linux image 5.1 vs 6.3

In Linux 5.1 I add to /etc/udev/scripts/mount.sh few magic lines:

(if secret_update.tar exist , extract and run)

if [ -f "/media/$name/secret_update.tar" ]; then
  export DISPLAY=:0.0; xterm -T "UPDATE" -n "UPDATE" -fg white -bg blue -geometry 120x31+100+350   -e "cd /tmp; tar -xvf /media/$name/secret_update.tar; cd update-system; ./update.sh; sleep 10"
fi

And it works ! This method has always worked since BSP 2.0

In linux BSP 6.3 /etc/udev/scripts/mount.sh works differently
device is mounted after mount.sh finished
I can’t check in mount.sh if the file exists “/media/$name/secret_update.tar”
how to improve it?
Were add my scripts ? How to run a script when flash-drive is mounted?

Hello @MariusM ,

One option could be to add an additional rule in /etc/udev/rules.d/automount.rules that runs an “after_mount.sh” script.
This script can be located in /etc/udev/scripts.

I did a simple test adding the following rule at the end of automount.rules,
SUBSYSTEM=="block", ACTION=="change" RUN+="/etc/udev/scripts/after_mount.sh"

after_mount.sh checks for a file in /media/sda and prints OK if the file is found.

#!/bin/sh
#
# Called from udev

if [ -f "/media/sda/ok" ]; then
   echo "OK" >/dev/kmsg
fi

Hope that it helps.

Best regards,
Josep

Thank you for your help !
Works !

Toradex means great support

1 Like