From d210f5171a0ef6324979c0556938fa8dd21bdbf3 Mon Sep 17 00:00:00 2001 From: Tenebor <87881021+Tenebor@users.noreply.github.com> Date: Thu, 21 Dec 2023 16:47:39 +0100 Subject: [PATCH] fix: use interactive shell to run psql Using ubuntu "sudo -u postgres psql" returns a permission error --- install.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/install.sh b/install.sh index 1d77ed94..277d9f05 100644 --- a/install.sh +++ b/install.sh @@ -295,25 +295,25 @@ done print_green 'Creating database for trmm' -sudo -u postgres psql -c "CREATE DATABASE tacticalrmm" -sudo -u postgres psql -c "CREATE USER ${pgusername} WITH PASSWORD '${pgpw}'" -sudo -u postgres psql -c "ALTER ROLE ${pgusername} SET client_encoding TO 'utf8'" -sudo -u postgres psql -c "ALTER ROLE ${pgusername} SET default_transaction_isolation TO 'read committed'" -sudo -u postgres psql -c "ALTER ROLE ${pgusername} SET timezone TO 'UTC'" -sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE tacticalrmm TO ${pgusername}" -sudo -u postgres psql -c "ALTER DATABASE tacticalrmm OWNER TO ${pgusername}" -sudo -u postgres psql -c "GRANT USAGE, CREATE ON SCHEMA PUBLIC TO ${pgusername}" +sudo -iu postgres psql -c "CREATE DATABASE tacticalrmm" +sudo -iu postgres psql -c "CREATE USER ${pgusername} WITH PASSWORD '${pgpw}'" +sudo -iu postgres psql -c "ALTER ROLE ${pgusername} SET client_encoding TO 'utf8'" +sudo -iu postgres psql -c "ALTER ROLE ${pgusername} SET default_transaction_isolation TO 'read committed'" +sudo -iu postgres psql -c "ALTER ROLE ${pgusername} SET timezone TO 'UTC'" +sudo -iu postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE tacticalrmm TO ${pgusername}" +sudo -iu postgres psql -c "ALTER DATABASE tacticalrmm OWNER TO ${pgusername}" +sudo -iu postgres psql -c "GRANT USAGE, CREATE ON SCHEMA PUBLIC TO ${pgusername}" print_green 'Creating database for meshcentral' -sudo -u postgres psql -c "CREATE DATABASE meshcentral" -sudo -u postgres psql -c "CREATE USER ${MESHPGUSER} WITH PASSWORD '${MESHPGPWD}'" -sudo -u postgres psql -c "ALTER ROLE ${MESHPGUSER} SET client_encoding TO 'utf8'" -sudo -u postgres psql -c "ALTER ROLE ${MESHPGUSER} SET default_transaction_isolation TO 'read committed'" -sudo -u postgres psql -c "ALTER ROLE ${MESHPGUSER} SET timezone TO 'UTC'" -sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE meshcentral TO ${MESHPGUSER}" -sudo -u postgres psql -c "ALTER DATABASE meshcentral OWNER TO ${MESHPGUSER}" -sudo -u postgres psql -c "GRANT USAGE, CREATE ON SCHEMA PUBLIC TO ${MESHPGUSER}" +sudo -iu postgres psql -c "CREATE DATABASE meshcentral" +sudo -iu postgres psql -c "CREATE USER ${MESHPGUSER} WITH PASSWORD '${MESHPGPWD}'" +sudo -iu postgres psql -c "ALTER ROLE ${MESHPGUSER} SET client_encoding TO 'utf8'" +sudo -iu postgres psql -c "ALTER ROLE ${MESHPGUSER} SET default_transaction_isolation TO 'read committed'" +sudo -iu postgres psql -c "ALTER ROLE ${MESHPGUSER} SET timezone TO 'UTC'" +sudo -iu postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE meshcentral TO ${MESHPGUSER}" +sudo -iu postgres psql -c "ALTER DATABASE meshcentral OWNER TO ${MESHPGUSER}" +sudo -iu postgres psql -c "GRANT USAGE, CREATE ON SCHEMA PUBLIC TO ${MESHPGUSER}" print_green 'Cloning repos'