Hey Guys, new to the forum and straight in with a question.
Basically I’m trying to run a script depending on when a particular type of USB drive is plugged in, so far I have the script running on other distro’s (ubuntu, debian) and it seems to work fine there so it’s probably something to do with my rule syntax. I currently have a rule un udev rules that goes as follows
This script just contains a sudo mount command to mount the USB drive to a particular folder in /mnt/ it works absoloutely fine in other OS’s but doesn’t seem to do anything in osmc, I have asked in the IRC channel but have been advised to post here by @sam_nazarko.
I’ll admit I’m a bit of a noob so go easy on me lol
As suggested in IRC, try adding ACTION=change rule, use udevadm --info to verify your rule, and see Debugging udev rules | under Debian for some pointers.
This is the output of the test, nothing jumps out at me but as I said I am a bit of a noob lol
osmc@osmc:/etc/udev/rules.d$ udevadm test /dev/bus/001/009
calling: test
version 215
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
Righ, just found this here http://www.axllent.org/docs/view/auto-mounting-usb-storage/ and it works, in fact it works really really well, it mounts the drive in media under the drives label name and makes it accessible, however I tried adding my scripts in there and again…nothing, it’s getting really frustrating now as there’s no logical reason they wont run, Any ideas anyone?
I’m basically trying to start openvpn when a “key” drive is inserted, the key drive contains the openvpn .ovpn file and I’m trying to get it to automatically run openvpn, I have two scripts already that work manually triggered and they work really well but it’s just make things a lot easier if I could get it to autorun, I’d have a go at making an addon but as yet thats a bit beyond my abilities/knowledge (unless theres a simple way of doing it?)
I guess that might actually be the answer, a small addon that just fires off the script on one button and fires the disconnect script on another, that way you just load a different ovpn file on the usb and plug it in
Just as a general comment, most time when people had issues running a script it was either that not full path (for the script and in the script) being used or it was a permission problem. As a starting point try a script that just echo text to a file
I’ve tried that @fzinken, tbh that was my first issue and the scripts wouldn’t even run for the osmc user let alone system, I can now call the scripts manually ssh’d in as osmc and they work perfectly, Tried stripping back all function in the script to just create a small txt file via touch and it still does bugger all i’m still leaning towards some kind of permissions issues tbh as theres no other logical reason that the osmc user could run it fine yet udev cant
Just make sure that your udev rule gets detected correctly in the first place been down this path too so i know what your going thru it not always easy btw mind adding code tags too your udev script above or even use the pastebin for it just type this in terminal.
cat your_udev_rule | paste-log
would make it less messy to read for future help purposes.
ps. it is possible it just time and effort to get it just right