Found and borrowd from the FreeNAS forums. I made some changes to make
it work better.