source: trunk/data/konvert/postnas_0.5/alkis_datenbank_anlegen.sh @ 49

Revision 26, 2.4 KB checked in by frank.jaeger, 14 years ago (diff)
RevLine 
[26]1#! /bin/sh
2## ------------------------------------------------
3## Konvertierung von ALKIS NAS-Format nach PosGIS -
4## Teil 1: Eine neue PostGIS-Datenbank anlegen    -
5## ------------------------------------------------
6## Stand:
7##  2010-01-11
8##  2010-01-26 postgreSQL 8.3 Port 5432
9##
10## Dialog mit Anwender
11function get_db_config(){
12        # welches Datenbank-Template?
13        echo ""
14        echo "Datenbank-Template fuer die neue ALKIS-Datenbank?"
15        echo " (einfach Enter fuer die Voreinstellung template_postgis)"
16        read DBTEMPLATE
17        : ${DBTEMPLATE:="template_postgis"}
18#
19        # Name der neuen ALKIS-Datenbank
20        until [ -n "$DBNAME" ]
21        do
22                echo ""
23                echo "Name der ALKIS-Datenbank?"
24                read DBNAME
25        done
26        echo ""
27        echo "Datenbank-User?"
28        read DBUSER
29#
30        #echo ""
31        #echo "Datenbank-Passwort?  (wird nicht angezeigt)"
32        #stty -echo
33        #       read DBPASS
34        #stty echo
35#
36        until [ "$JEIN" = "j" -o "$JEIN" = "n" ]
37        do
38                echo ""
39                echo "Datenbank $DBNAME wird GELOESCHT und neu angelegt  - j oder n?"
40                read JEIN
41        done
42}
43#
44## aller Laster  ANFANG
45get_db_config;
46if test $JEIN != "j"
47then
48        echo "Abbruch"
49        exit 1
50fi
51## Datenbank-Connection:
52#con="-h localhost -p 5432 -d ${DBNAME} "
53con="-p 5432 -d ${DBNAME} "
54echo "connection " $con
55echo "******************************"
56echo "**  Neue ALKIS-Datenbank    **"
57echo "******************************"
58echo "** Löschen Datenbank " ${DBNAME}
59#echo "DROP database ${DBNAME};" | psql -h localhost -p 5432 -d ${DBUSER} -U ${DBUSER}
60echo  "DROP database ${DBNAME};" | psql              -p 5432 -d ${DBUSER} -U ${DBUSER}
61echo "** Anlegen (leere) PostGIS-Datenbank"
62#createdb  --host=localhost  --port=5432 --username=${DBUSER} -E utf8  -T ${DBTEMPLATE}  ${DBNAME}
63createdb                     --port=5432 --username=${DBUSER} -E utf8  -T ${DBTEMPLATE}  ${DBNAME}
64echo "** Anlegen der Datenbank-Struktur  (alkis_PostNAS_0.5_schema.sql)"
65psql $con -U ${DBUSER}  < /data/konvert/postnas_0.5/alkis_PostNAS_0.5_schema.sql
66echo "** Definition von Views"
67psql $con -U ${DBUSER}  < /data/konvert/postnas_0.5/alkis_sichten.sql
68#echo "COMMENT ON DATABASE ${DBNAME} IS 'ALKIS - Konverter PostNAS 0.5';" | psql -h localhost -p 5432 -d ${DBNAME} -U ${DBUSER}
69echo  "COMMENT ON DATABASE ${DBNAME} IS 'ALKIS - Konverter PostNAS 0.5';" | psql              -p 5432 -d ${DBNAME} -U ${DBUSER}
70echo "***************************"
71echo "**  Ende Neue Datenbank  **"
72echo "***************************"
Note: See TracBrowser for help on using the repository browser.