File: postgresql-setup.sh

package info (click to toggle)
freeradius 3.2.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,400 kB
  • sloc: ansic: 125,473; sh: 5,860; perl: 4,351; sql: 3,072; python: 1,559; makefile: 621; xml: 62; tcl: 35; sed: 23; ruby: 22
file content (26 lines) | stat: -rwxr-xr-x 1,022 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh -e

#
# To initialise on MacOS
#    sudo brew install postgresql
#    pg_ctl -D /usr/local/var/postgres start
#    /usr/local/opt/postgres/bin/createuser -s postgres
#

echo "Dropping existing database"
psql -h "${SQL_POSTGRESQL_TEST_SERVER}" -c 'drop database radius;' -U postgres || true

echo "Dropping existing database"
psql -h "${SQL_POSTGRESQL_TEST_SERVER}" -c 'drop user radius;' -U postgres || true

echo "PostgreSQL - Creating database"
psql -h "${SQL_POSTGRESQL_TEST_SERVER}" -c 'create database radius;' -U postgres || true

echo "PostgreSQL - Execute schema.sql"
psql -h "${SQL_POSTGRESQL_TEST_SERVER}" -U postgres radius < raddb/mods-config/sql/main/postgresql/schema.sql

echo "PostgreSQL - Execute setup.sql"
psql -h "${SQL_POSTGRESQL_TEST_SERVER}" -U postgres radius < raddb/mods-config/sql/main/postgresql/setup.sql

echo "PostgreSQL - Grant radius user permissions"
psql -h "${SQL_POSTGRESQL_TEST_SERVER}" -c 'GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO radius;' -U postgres radius