Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.68 KB | None | 0 0
  1. # CURRENT PRODUCTION - February 2014
  2. export POSTGRES=postgresql-9.3.4
  3. export POSTGIS=postgis-2.1.2
  4. export PROJ=proj-4.8.0
  5. export PROJ_DATUM=proj-datumgrid-1.5
  6. export GEOS=geos-3.4.2
  7. export GDAL=gdal-1.10.1
  8.  
  9. # LAST
  10. #export POSTGRES=postgresql-9.0.1
  11. #export POSTGIS=postgis-1.5.2
  12. #export PROJ=proj-4.7.0
  13. #export GEOS=geos-3.2.2
  14. #export GDAL=gdal-1.8.0
  15. #export PROJ_DATUM=proj-datumgrid-1.5
  16.  
  17. # ORIGINAL - VERY OLD (here just to track where we started)
  18. #export POSTGRES=postgresql-8.2.4
  19. #export POSTGIS=postgis-1.2.1
  20. #export PROJ=proj-4.5.0
  21. #export GEOS=geos-2.2.3
  22. #export GDAL=gdal-1.5.0
  23.  
  24. function deleter()
  25. {
  26.     cd ~
  27.     rm -rf build/$POSTGRES install/$POSTGRES
  28.     rm -rf build/$POSTGIS  install/$POSTGIS
  29.     rm -rf build/$PROJ     install/$PROJ    
  30.     rm -rf build/$GEOS     install/$GEOS    
  31.     rm -rf build/$GDAL     install/$GDAL
  32.     rm -P ~/postgres ~/install/postgres ~/install/geos ~/install/proj ~/install/gdal ~/build/postgis
  33. }
  34.  
  35. function unziper()
  36. {
  37.     echo ___________ START: UNTAR EVERYTHING _________________
  38.     cd ~/build
  39.     tar xzvf ~/archives/$POSTGRES.tar.gz
  40.     tar xzvf ~/archives/$POSTGIS.tar.gz
  41.     tar xzvf ~/archives/$PROJ.tar.gz
  42.     tar xjvf ~/archives/$GEOS.tar.bz2
  43.     tar xvf  ~/archives/$GDAL.tar
  44.     echo ___________ DONE: UNTAR EVERYTHING _________________
  45. }
  46.  
  47. # builds proj & geos libs
  48. function proj_geos()
  49. {
  50.     # step a: INSTALL datum shifting http://proj.maptools.org/faq.html
  51.     cd ~/build/$PROJ/nad/
  52.     unzip ~/archives/$PROJ_DATUM.zip
  53.     tar xjvf ~/archives/$PROJ_DATUM.tar.bz2
  54.     builder $PROJ 'proj'
  55.     builder $GEOS 'geos'
  56. }
  57.  
  58. #
  59. # builder function
  60. #
  61. function builder()
  62. {
  63.     target=$1
  64.     idir=$2
  65.  
  66.     echo ___________ START: BUILD $target _________________
  67.     cd ~/build/
  68.     cd $target
  69.     configure --prefix=/home/geoserve/install/$target
  70.     make
  71.     make install
  72.     ln -s ~/install/$target ~/install/$idir
  73.     echo ___________ END: BUILD $target _________________
  74.     echo
  75. }
  76.  
  77. function postgis()
  78. {
  79.     echo ___________ START: BUILD POSTGIS _________________
  80.     cd ~/build/$POSTGIS
  81.     configure --with-projdir=/home/geoserve/install/proj --prefix=/home/geoserve/install/$POSTGIS
  82.     make
  83.     make install
  84.     ln -s ~/build/$POSTGIS ~/install/postgis
  85.     echo ___________ START: BUILD POSTGIS _________________
  86.     echo
  87. }
  88.  
  89. deleter;
  90. unziper;
  91. proj_geos;
  92. builder $GDAL     'gdal'
  93. builder $POSTGRES 'postgres'
  94. ln -s ~/install/$POSTGRES ~/postgres
  95. postgis;
  96.  
  97. function init_postgis_old()
  98. {
  99.     echo ___________ ENABLE POSTGIS _________________
  100.     cd ~/postgres
  101.     psql -p $PGPORT -d trimet -f share/contrib/postgis-2.1/postgis.sql
  102.     psql -p $PGPORT -d trimet -f share/contrib/postgis-2.1/spatial_ref_sys.sql
  103.  
  104.     # NOTE: if lwpostgis.sql fails to load, try the following
  105.     # cd ~/postgres/lib
  106.     # ln -s ~/install/geos/lib/* .
  107.     # cd -
  108. }
  109.  
  110. #
  111. # create a new PG database
  112. #
  113. function init_postres()
  114. {
  115.     echo
  116.     echo ___________ INIT POSTGRES _________________
  117.     # initdb on new postgres
  118.     cd ~
  119.     mkdir postgres/log
  120.     initdb -D ~/postgres/data
  121.  
  122.     # 'fix' postgres
  123.     sleep 3
  124.     cd ~/postgres/data
  125.     mkdir old
  126.     mv pg_hba.conf postgresql.conf old/
  127.     ln -s ~/MapConfig/postgres/*conf .
  128.  
  129.     echo
  130.     echo ___________ START POSTGRES _________________
  131.     # start postgres / create trimet db
  132.     pg_ctl -D ~/postgres/data -l ~/postgres/log/logfile.txt -m fast start
  133.     sleep 3
  134.     ps -ef | grep post
  135.     createdb -p $PGPORT trimet
  136.     createlang -p $PGPORT plpgsql trimet
  137. }
  138.  
  139.  
  140.  
  141.  
  142. #
  143. # spatially enable the trimet db with PostGIS
  144. #
  145. function init_postgis()
  146. {
  147.     psql -p $PGPORT -d trimet -c "CREATE EXTENSION postgis;"
  148. }
  149.  
  150. init_postres;
  151. init_postgis;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement