forked from BIJ12/CDS-Assembly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvagrant-db.sh
71 lines (56 loc) · 2.76 KB
/
vagrant-db.sh
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -e
# Instal PostgreSQL:
apt-get -qy update
apt-get -qy install \
postgresql-9.1 \
postgresql-client-9.1 \
postgresql-9.1-postgis \
unzip \
openjdk-6-jre-headless
# Create template_postgis:
RESULT=$(sudo -u postgres psql -l | grep template_postgis | wc -l)
if [[ $RESULT != 1 ]]; then
echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.1/main/pg_hba.conf
echo "listen_addresses='*'" >> /etc/postgresql/9.1/main/postgresql.conf
sudo -u postgres psql -c "alter user postgres with password 'postgres';"
sudo -u postgres psql --command "CREATE USER inspire WITH PASSWORD 'inspire';"
sudo -u postgres psql --command "CREATE USER nagios;"
sudo -u postgres createdb -l en_US.UTF8 -E UTF8 -T template0 template_postgis
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
sudo -u postgres psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
fi
/etc/init.d/postgresql restart
# Drop the previous databases:
RESULT=$(sudo -u postgres psql -l | grep cds_inspire_unittest | wc -l)
if [[ $RESULT == 1 ]]; then
sudo -u postgres dropdb cds_inspire_unittest
fi
RESULT=$(sudo -u postgres psql -l | grep cds | wc -l)
if [[ $RESULT == 1 ]]; then
sudo -u postgres dropdb cds
fi
# Create and populate the CDS database:
sudo -u postgres createdb -l en_US.UTF8 -O inspire -E UTF8 -T template_postgis cds
sudo -u postgres createdb -l en_US.UTF8 -O inspire -E UTF8 -T template_postgis cds_inspire_unittest
sudo -u postgres psql -d cds -f /vagrant/target/sql/create-database.sql
sudo -u postgres psql -d cds_inspire_unittest -f /vagrant/target/sql/create-database.sql
sudo -u postgres psql -d cds -f /vagrant/target/sql/add-themes.sql
/etc/init.d/postgresql restart
# Setup LDAP server:
if [[ ! -d /opt/OpenDS-2.2.1 ]]; then
unzip -d /opt /vagrant/src/main/docker/cds-ldap/OpenDS-2.2.1.zip
cp /vagrant/src/main/docker/cds-ldap/opends /etc/init.d/opends
chmod +x /opt/OpenDS-2.2.1/setup
chmod +x /opt/OpenDS-2.2.1/bin/*
chmod +x /opt/OpenDS-2.2.1/lib/*
chmod +x /etc/init.d/opends
/opt/OpenDS-2.2.1/setup -i -n -b dc=inspire,dc=idgis,dc=eu -D cn=admin,dc=inspire,dc=idgis,dc=eu -w admin -p 1389 -a
/opt/OpenDS-2.2.1/bin/ldapmodify -p 1389 -h localhost -D cn=admin,dc=inspire,dc=idgis,dc=eu -w admin -a -f /vagrant/src/main/docker/cds-ldap/ldap-init.ldif
update-rc.d opends defaults
/etc/init.d/opends start
fi