I've seen that flawed method around the webs and it's too generic in scope, as previous answer mentioned. It's also not dynamic enough, what if multiple USB devices were plugged in? This problem is common and solutions are around. You did not mention your distro, so I can't tell you which scripts are available packaged. I will mention them anyway, as they will show you a better method, you could always just borrow the applicable sections.
First you should really consider looking at udisks
, If you use a full DE You might only need it alone. For a WM only... A great project which replaces the deprecated HAL, and uses udisks
is called udisks-glue
.
If you still decide to go without udisks
, then have a look at udev
scripts called uam
.
Gentoo has an ebuild, otherwise check out the source code at GitHub Bitbucket.
It's worth mentioning, Arch also has a bunch of great USB automount udev
examples in their Wiki
Any of these options would be a lightweight way to do this, and are complete in implementation, specific in scope and tested for side effects.