Sorry if this is a simple question. I want to start my own script after a successful switch. How should I do it? I would like to avoid tampering with udev rule so it get overwritten on next update.
Start script on switch success
Hello,
Sorry if this is a simple question. I want to start my own script after a successful switch. How should I do it? I would like to avoid tampering with udev rule so it get overwritten on next update.
Classee
Sorry if this is a simple question. I want to start my own script after a successful switch. How should I do it? I would like to avoid tampering with udev rule so it get overwritten on next update.
That should not be too hard.
You can easily add your own udev rule file, like 90-my.rules or whatever, to the rules folder; it will never be overwritten.
In the file, check for the target ID, just like the usb_modeswitch rules do for the default IDs.
You can copy the line that says SYSTEM!="usb" ....
Don't use the line that checks the interface class.
Copy the line with the end marker (to the end, obviously).
Both lines make sure that your rule is only tested when a USB device is ADDED or CHANGED.
You should be able to run all kinds of programs with the RUN parameter, but be aware that the environment for programs run by this is very limited. So you have to provide PATH and others in the script.
You can easily add your own udev rule file, like 90-my.rules or whatever, to the rules folder; it will never be overwritten.
In the file, check for the target ID, just like the usb_modeswitch rules do for the default IDs.
You can copy the line that says SYSTEM!="usb" ....
Don't use the line that checks the interface class.
Copy the line with the end marker (to the end, obviously).
Both lines make sure that your rule is only tested when a USB device is ADDED or CHANGED.
You should be able to run all kinds of programs with the RUN parameter, but be aware that the environment for programs run by this is very limited. So you have to provide PATH and others in the script.
Hi,Josh wrote:That should not be too hard.
You can easily add your own udev rule file, like 90-my.rules or whatever, to the rules folder; it will never be overwritten.
In the file, check for the target ID, just like the usb_modeswitch rules do for the default IDs.
You can copy the line that says SYSTEM!="usb" ....
Don't use the line that checks the interface class.
Copy the line with the end marker (to the end, obviously).
Both lines make sure that your rule is only tested when a USB device is ADDED or CHANGED.
You should be able to run all kinds of programs with the RUN parameter, but be aware that the environment for programs run by this is very limited. So you have to provide PATH and others in the script.
That sounds like a good idea. Same structure as your /lib/udev/rules.d/40-usb_modeswitch.rules
Code: Select all
ACTION!="add", GOTO="modeswitch_rules_end"
SUBSYSTEM!="usb", GOTO="modeswitch_rules_end"
LABEL="modeswitch_rules_begin" ## not needed in this simple case...
# Huawei E173
ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1436", RUN+="myscript"
# ... more modems ...
LABEL="modeswitch_rules_end"