To use this script you will currently need to run it with a role that has super user privileges in postgres as well as having login privileges. You can also use the postgres user: #Change the script ...