How can I run a shell script when some WiFi is connected?
Matthew already pointed to tasker for this task (uh) – an app I already use for years. So let me add the steps to achieve this. Obviously, a pre-condition is the device is rooted – but the su command in the question tells me it is. So here we go:


Condition: State › Net › WiFi Connected
As parameter, include the SSID of your WiFi network, so it doesn't fire on alien networks :)
Task: Script › Run Shell
Here you add the name of the script to run (full path), preceded by an exclamation mark (to indicate it must be run as root)


This should do it. Not tested myself, as I have no routes to add :)