From 0174f1652039a2c48980c2826ea70db80afd040f Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sat, 1 Apr 2017 03:18:25 -0600 Subject: [PATCH] Update postgres.sh --- freebsd/resources/postgres.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/freebsd/resources/postgres.sh b/freebsd/resources/postgres.sh index 3c6a31b..965a39a 100755 --- a/freebsd/resources/postgres.sh +++ b/freebsd/resources/postgres.sh @@ -36,12 +36,16 @@ rehash #enable postgres echo 'postgresql_enable=true' >> /etc/rc.conf +#move to /tmp to prevent an error when running sudo with psql +cwd=$(pwd) +cd /tmp + #initialize the database /usr/local/etc/rc.d/postgresql initdb #start postgresql if [ ."$database_version" = ."9.6" ]; then - /usr/local/bin/pg_ctl -D /var/db/postgres/data96 -l logfile start + sudo -u postgres /usr/local/bin/pg_ctl -D /var/db/postgres/data96 -l logfile start fi #restart the service @@ -52,10 +56,6 @@ service postgresql restart #chmod 755 /etc/cron.daily/fusionpbx-backup.sh #sed -i' ' -e "s/zzz/$password/g" /etc/cron.daily/fusionpbx-backup.sh -#move to /tmp to prevent an error when running sudo with psql -cwd=$(pwd) -cd /tmp - #add the databases, users and grant permissions to them #sudo -u postgres psql -d fusionpbx -c "DROP SCHEMA public cascade;"; #sudo -u postgres psql -d fusionpbx -c "CREATE SCHEMA public;";