-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcreate_database_freebsd
executable file
·26 lines (19 loc) · 1.45 KB
/
create_database_freebsd
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
#!/usr/bin/env bash
createdb -E UTF8 template_postgis # Create the template spatial database.
createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
psql -d template_postgis -f `pg_config --sharedir`/lwpostgis.sql # Loading the PostGIS SQL routines
psql -d template_postgis -f `pg_config --sharedir`/spatial_ref_sys.sql
psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;" # Enabling users to alter spatial tables.
psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
echo -n "Pick a database name: "
read -e DBNAME
createdb -U pgsql -T template_postgis $DBNAME
echo -n "Pick a username: "
read -e USERNAME
echo -n "Pick a password: "
read -e PASSWORD
psql -c "create user $USERNAME with password '$PASSWORD';" $DBNAME
psql -c "grant all privileges on database $DBNAME to $USERNAME;" $DBNAME
echo "DATABASE_NAME = '$DBNAME'" >> local_settings.py
echo "DATABASE_USER = '$USERNAME'" >> local_settings.py
echo "DATABASE_PASSWORD = '$PASSWORD'" >> local_settings.py