install: improve handling of shared groups.

Inspired by http://blog.strug.de/2012/06/my-homebrew-multi-user-setup/