ef10d52745
Both Jason Schoon and Giuseppe Ciotta deserve credit for this, I used elements of both. It's been upgraded so that you can specify that a given command should run at create, at delete, or at both using different special characters (@, $, and * respectively). It uses the system() method of running command lines which means you can use environment variables on the command line (it sets $MDEV to the name of the current device being created/deleted, which is useful if you matched it via regex), and the documentation warns that you need a /bin/sh to make that work, so you probably want to pick a default shell.