endpoint script for postgresql

Hi, I have made a modified version of the endpoints scripts which works with postgresql.
Please pull if you consider it useful.