Installation unter debian
Aktuell empfehlen wir die Installation von kvwmap auf einem dem Debian Betriebssystem. Wir haben derzeit kein Bundle mit dem eine One-Step installation möglich wäre. Dazu verwenden wir zu viele verschiedene Komponenten die voneinander abhängig sind und außerdem solche, die vielleicht auch auf existierenden Systemen schon für andere Zwecke laufen oder sonstige Präferenzen, z.B. für welche Zwecke der MapServer verwendet werden soll.
Im folgendem Shell-Script sollte man jedoch alles finden was man zur Installation der Komponenten von kvwmap benötigt.
Dieses Script sollte aber nicht einfach so ausgeführt werden. Zum einen sind am Anfang einige Konstanten zu setzen und zum anderen wird auch nicht alles benötigt. Manche Bestandteile sind auch voneinander abhängig. Wer also kvwmap selber installieren möchte sollte sich vielleicht Schrittweise da rantasten und die Installation Stück für Stück durchgehen. Die entsprechenden Code-Schnipsel können rauskopiert werden oder Eintragungen in Konfigurationsdateien auch manuell vorgenommen werden. Gerade wenn in Konfigurationsskripte geschrieben wird oder durch das Script Ersetzungen vorgenommen werden, sollte man vielleicht vorher mal reinschauen was da vorher drin steht. Dieses Script wird nicht so fortgeführt, dass es immer zur aktuellsten Version der Komponenten passen. Es wird empfohlen bei der Installation Schritt für Schritt vorzugehen und jeweils zu prüfen ob die Schritte erfolgreich durchgeführt wurden. Manche Sachen wie z.B. HDF braucht man nicht unbedingt, nur wenn man NetCDF lesen möchte. Auch andere Einstellungen sind optional.
#!/bin/bash
# Settings
#HDF4_VERSION=4.2.10
#HDF5_VERSION=1.8.13
#NETCDF_VERSION=4.3.2
GDAL_VERSION=1.12.0
POSTGIS_VERSION=2.1.2
POSTGIS_CONTRIB_PATH=/usr/share/postgresql/9.1/contrib/postgis-2.1
MAPSERVER_VERSION=6.4.1
MYUSER=root
MYPASSWORD=Root1
KVWMAPUSER=kvwmap
KVWMAPPASSWORD=kvwmap
#HTTP_PROXY="http://x.y.z.a:800/"
#HTTPS_PROXY="https://x.y.z.b:800/"
OS_USER="osuser"
PGUSER=$OS_USER
PGPASSWORD="osuserpassword"
IP=x.y.z.c
echo "--------------------------------------------------------"
echo "Set http and https proxy"
if [ ! -z "$HTTP_PROXY" ]; then
echo "------------------------------------------------------"
echo "Set http_proxy to: $HTTP_PROXY"
echo "export http_proxy=$HTTP_PROXY" >> ~/.bashrc
export http_proxy=$HTTP_PROXY
echo "------------------------------------------------------"
echo "Set https_proxy to: $HTTPS_PROXY"
echo "export https_proxy=$HTTPS_PROXY" >> ~/.bashrc
export https_proxy=$HTTPS_PROXY
fi
echo "------------------------------------------------------"
echo "set some settings in bashrc for root"
sed -i "s/# alias ll='ls/alias ll='ls/g" ~/.bashrc
sed -i "s/alias rm='rm -i'/# alias rm='rm -i'/g" ~/.bashrc
echo "------------------------------------------------------"
echo "update system"
apt-get update
# install compiler software
echo "------------------------------------------------------"
echo "install gcc"
apt-get install -y gcc
echo "------------------------------------------------------"
echo "install g++"
apt-get install -y g++
echo "------------------------------------------------------"
echo "install make"
apt-get install -y make
echo "------------------------------------------------------"
echo "install cmake"
apt-get install -y cmake
echo "------------------------------------------------------"
echo "install autoconf for configure scripts"
apt-get install -y autoconf
echo "------------------------------------------------------"
echo "install libtool"
apt-get install -y libtool
echo "------------------------------------------------------"
# install time server to synchronize time of the server with other servers
echo "------------------------------------------------------"
echo "install ntp for automated server time synchronization"
apt-get install -y ntp
# install some necessary libraries
echo "install png"
apt-get install -y libpng12-0
apt-get install -y libpng12-dev
echo "------------------------------------------------------"
echo "install freetype"
apt-get install -y libfreetype6
apt-get install -y libfreetype6-dev
echo "-------------------------------------------------------"
echo "install jpeg"
apt-get install -y libjpeg
apt-get install -y libjpeg-dev
echo "------------------------------------------------------"
echo "install gif"
apt-get install -y libgif4
apt-get install -y libgif-dev
echo "------------------------------------------------------"
echo "install zlib"
apt-get install -y zlib-bin
apt-get install -y zlib1g
apt-get install -y zlib1g-dev
echo "------------------------------------------------------"
echo "install proj"
apt-get install -y libproj0
apt-get install -y libproj-dev
echo "------------------------------------------------------"
echo "Add missing projections and set towgs correctly in epsg file of proj"
sed -i "s%<25832> +proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs <>%<25832> +proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs +towgs84=0,0,0 <>%g" /usr/share/proj/epsg
sed -i "s%<25833> +proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs <>%<25833> +proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs +towgs84=0,0,0 <>%g" /usr/share/proj/epsg
sed -i "s%<2397> +proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=krass +units=m +no_defs <>%<2397> +proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=krass +towgs84=24,-123,-94,0.02,-0.25,-0.13,1.1 +units=m +no_defs <>%g" /usr/share/proj/epsg
sed -i "s%<2398> +proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +units=m +no_defs <>%<2398> +proj=tmerc +lat_0=0 +lon_0=12 +k=1 +x_0=4500000 +y_0=0 +ellps=krass +towgs84=24,-123,-94,0.02,-0.25,-0.13,1.1 +units=m +no_defs <>%g" /usr/share/proj/epsg
sed -i "s%<2399> +proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=5500000 +y_0=0 +ellps=krass +units=m +no_defs <>%<2399> +proj=tmerc +lat_0=0 +lon_0=15 +k=1 +x_0=5500000 +y_0=0 +ellps=krass +towgs84=24,-123,-94,0.02,-0.25,-0.13,1.1 +units=m +no_defs <>%g" /usr/share/proj/epsg
echo "# ETRS89 / UTM zone 33N mit fuehrenden 33" >> /usr/share/proj/epsg
echo "<35833> +proj=tmerc +lat_0=0 +towgs84=0,0,0 +lon_0=15 +k=0.9996 +x_0=33500000 +y_0=0 +ellps=GRS80 +units=m +no_defs <>" >> /usr/share/proj/epsg
echo "# ETRS89 / UTM zone 33N (zE-N)" >> /usr/share/proj/epsg
echo "<5650> +proj=tmerc +lat_0=0 +towgs84=0,0,0,0,0,0,0 +lon_0=15 +k=0.9996 +x_0=33500000 +y_0=0 +ellps=GRS80 +units=m +no_defs <>" >> /usr/share/proj/epsg
echo "# ETRS89 / UTM zone 33N mit fuehrenden 3" >> /usr/share/proj/epsg
echo "<325833> +proj=tmerc +lat_0=0 +towgs84=0,0,0 +lon_0=15 +k=0.9996 +x_0=3500000 +y_0=0 +ellps=GRS80 +units=m +no_defs <>" >> /usr/share/proj/epsg
echo "# ETRS89 / LCC Germany (N-E)" >> /usr/share/proj/epsg
echo "<4839> +proj=lcc +lat_1=48.66666666666666 +lat_2=53.66666666666666 +lat_0=51 +lon_0=10.5 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs" >> /usr/share/proj/epsg
echo "------------------------------------------------------"
echo "install curl"
apt-get install -y curl
apt-get install -y libcurl3
apt-get install -y libcurl4-gnutls-dev
apt-get install -y libcurl4-openssl-dev
echo "------------------------------------------------------"
echo "install geos"
apt-get install -y libgeos-3.3.3
apt-get install -y libgeos-dev
echo "------------------------------------------------------"
echo "install xml2"
apt-get install -y libxml2
apt-get install -y libxml2-dev
echo "------------------------------------------------------"
echo "install xerces-c"
apt-get install -y libxerces-c3.1
apt-get install -y libxerces-c-dev
echo "------------------------------------------------------"
echo "install fcgi"
apt-get install -y libfcgi0ldbl
apt-get install -y libfcgi-dev
echo "------------------------------------------------------"
echo "install cairo"
apt-get install -y libcairo2
apt-get install -y libcairo2-dev
#apt-get install -y libpixman-1-dev=0.24.0-1~bpo60+1
echo "------------------------------------------------------"
echo "install rsvg"
apt-get install -y librsvg2-2
apt-get install -y librsvg2-dev
echo "------------------------------------------------------"
echo "install gobject"
apt-get install -y gir1.2-rsvg-2.0 # wheezy
apt-get install -y gir-repository-dev # squeezy
echo "------------------------------------------------------"
echo "install fribidi"
apt-get install -y libfribidi0
apt-get install -y libfribidi-bin
apt-get install -y libfribidi-dev
echo "------------------------------------------------------"
echo "install subversion"
apt-get install -y subversion
echo "------------------------------------------------------"
echo "install PostgreSQL Database"
apt-get install -y libpq5
apt-get install -y libpq-dev
apt-get install -y postgresql
apt-get install -y postgresql-server-dev-9.1
apt-get install -y postgresql-client-9.1
apt-get install -y postgresql-contrib
apt-get install -y postgresql-contrib-9.1
if [ ! -z "$NETCDF_VERSION" ]; then
echo "install bison and byacc for yacc- and flex for lex-library"
echo "it will be used by netCDF"
apt-get install -y bison
apt-get install -y byacc
apt-get install -y flex
if [ ! -z "$HDF4_VERSION" ]; then
echo "------------------------------------------------------"
echo "install HDF4 library from source in /usr/local to support netCDF4"
echo "see: http://www.unidata.ucar.edu/software/netcdf/docs/getting_and_building_netcdf.html#build_classic"
cd /usr/local
wget "http://www.hdfgroup.org/ftp/HDF/HDF_Current/src/hdf-$HDF4_VERSION.tar.gz"
tar xvfz hdf4-$HDF4_VERSION.tar.gz
rm -f hdf4-$HDF4_VERSION.tar.gz
ln -s hdf4-$HDF4_VERSION hdf
cd hdf4-$HDF4_VERSION
./configure --enable-shared --disable-netcdf --disable-fortran
make
make install
H4DIR=/usr/local/hdf5-$HDF4_VERSION
fi
if [ ! -z "$HDF5_VERSION" ]; then
echo "------------------------------------------------------"
echo "install HDF5 library from source in /usr/local to support netCDF4"
echo "see: http://www.unidata.ucar.edu/software/netcdf/docs/getting_and_building_netcdf.html#build_classic"
cd /usr/local
wget "http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-$HDF5_VERSION.tar.gz"
tar xvfz hdf5-$HDF5_VERSION.tar.gz
rm -f hdf5-$HDF5_VERSION.tar.gz
ln -s hdf5-$HDF5_VERSION hdf
cd hdf5-$HDF5_VERSION
./configure --enable-shared --disable-netcdf --disable-fortran
make
make install
H5DIR=/usr/local/hdf5-$HDF5_VERSION
fi
echo "------------------------------------------------------"
echo "install NetCDF c library from source in /usr/local to support netCDF converter of gdal"
echo "see: http://www.unidata.ucar.edu/software/netcdf/docs/getting_and_building_netcdf.html#build_classic"
cd /usr/local
wget "ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-$NETCDF_VERSION.tar.gz"
tar xvfz netcdf-$NETCDF_VERSION.tar.gz
rm -f netcdf-$NETCDF_VERSION.tar.gz
ln -s netcdf-$NETCDF_VERSION netcdf
cd netcdf-$NETCDF_VERSION
./configure --disable-hdf4
make
make install
fi;
echo "------------------------------------------------------"
echo "install gdal from source in /usr/local"
#cd /usr/local
#wget "http://download.osgeo.org/gdal/$GDAL_VERSION/gdal-$GDAL_VERSION.tar.gz"
#tar xvfz gdal-$GDAL_VERSION.tar.gz
#rm -f gdal-$GDAL_VERSION.tar.gz
#[ -d /usr/local/gdal ] && rm /usr/local/gdal
#ln -s gdal-$GDAL_VERSION gdal
#cd gdal-$GDAL_VERSION
echo "------------------------------------------------------"
echo "install gdal from svn trunk of osgeo"
cd /usr/local
mkdir gdal-$GDAL_VERSION
cd gdal-$GDAL_VERSION
svn checkout http://svn.osgeo.org/gdal/trunk/gdal
mv gdal gdal-$GDAL_VERSION
cd ..
mv gdal-$GDAL_VERSION gdal-${GDAL_VERSION}_
cd gdal-${GDAL_VERSION}_
mv gdal-$GDAL_VERSION ..
cd ..
rm -R gdal-${GDAL_VERSION}_
cd gdal-${GDAL_VERSION}
if [ ! -z "$NETCDF_VERSION" ]; then
./configure --with-pg --with-netcdf
else
./configure --with-pg --with-xerces=yes --with-static-proj4
fi
#./configure --with-xerces=yes --with-xerces-inc=/usr/include/xercesc/ --with-static-proj4 --with-xerces-lib="-L/usr/include/xercesc -lxerces-c -lpthread" > configure.log
make
make install
echo "------------------------------------------------------"
echo "download PostGIS source from osgeo.org"
cd /usr/local
wget http://download.osgeo.org/postgis/source/postgis-$POSTGIS_VERSION.tar.gz
tar xvfz postgis-$POSTGIS_VERSION.tar.gz
rm postgis-$POSTGIS_VERSION.tar.gz
ln -s postgis-$POSTGIS_VERSION postgis
cd postgis-$POSTGIS_VERSION
echo "------------------------------------------------------"
echo "compile PostGIS from Source"
./configure
make
make install
ldconfig
make comments-install
echo "------------------------------------------------------"
echo "enable the command-line tools of PostGIS to work from shell"
ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/shp2pgsql
ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/pgsql2shp
ln -sf /usr/share/postgresql-common/pg_wrapper /usr/local/bin/raster2pgsql
echo "------------------------------------------------------"
echo "install Apache2 mit php"
apt-get install -y apache2
apt-get install -y php5
apt-get install -y php5-pgsql
apt-get install -y php5-mysql
apt-get install -y php5-ming
apt-get install -y php5-curl
apt-get install -y php5-dev
echo "------------------------------------------------------"
echo "Install MapServer from source in /usr/localmake install"
cd /usr/local
wget http://download.osgeo.org/mapserver/mapserver-$MAPSERVER_VERSION.tar.gz
tar xvfz mapserver-$MAPSERVER_VERSION.tar.gz
rm mapserver-$MAPSERVER_VERSION.tar.gz
ln -s mapserver-$MAPSERVER_VERSION mapserver
cd mapserver-$MAPSERVER_VERSION
# build mapserver make file
echo "------------------------------------------------------"
echo "create build directory in /usr/local/mapserver"
mkdir build
cd build
echo "------------------------------------------------------"
echo "create Makefile"
cmake .. -DWITH_FRIBIDI=0 -DWITH_CLIENT_WMS=1 -DWITH_CLIENT_WFS=1 -DWITH_SOS=1 -DWITH_PHP=1 -DPHP5_EXTENSION_DIR="/usr/lib/php5/20100525" -DWITH_CURL=1 -DWITH_CAIRO=1 -DWITH_SVGCAIRO=1 -DWITH_RSVG=0
echo "------------------------------------------------------"
echo "compile with Makefile"
make > make.log 2> make.err
echo "------------------------------------------------------"
echo "install mapserver components"
make install > make_install.log
cd
echo "------------------------------------------------------"
echo "set link to cgi-bin"
ln -s /usr/local/bin/mapserv /usr/lib/cgi-bin/mapserv
echo "------------------------------------------------------"
echo "install php_mapscript modul for php"
cd /etc/php5/mods-available
echo "------------------------------------------------------"
echo "; configuration for php MapScrip module" > php_mapscript.ini
echo "------------------------------------------------------"
echo "extension=php_mapscript.so" >> php_mapscript.ini
cd /etc/php5/conf.d
ln -s ../mods-available/php_mapscript.ini 20-php_mapscript.ini
service apache2 reload
echo "------------------------------------------------------"
echo "install MySQL Database"
# input of the root password is necessary
apt-get install -y mysql-server
echo "------------------------------------------------------"
echo "install phpMyAdmin Modul for Apache"
# input of webserver and root password
apt-get install -y phpmyadmin
echo "------------------------------------------------------"
echo "Download PDFClass"
cd /home/$OS_USER/apps
wget "http://gdi-service.de/public/kvwmap_resources/PDFClass.tar.gz"
tar xvfz PDFClass.tar.gz
rm PDFClass.tar.gz
echo "------------------------------------------------------"
echo "add the user $OS_USER"
adduser $OS_USER
if [ ! -z "$HTTP_PROXY" ]; then
echo "export http_proxy=$HTTP_PROXY" >> /home/$OS_USER/.bashrc
echo "export https_proxy=$HTTPS_PROXY" >> /home/$OS_USER/.bashrc
fi
echo "------------------------------------------------------"
echo "Create directories for $OS_USER"
mkdir /home/$OS_USER/apps
mkdir /home/$OS_USER/apps/kvwmap
mkdir /home/$OS_USER/cache
mkdir /home/$OS_USER/data
mkdir /home/$OS_USER/data/alb
mkdir /home/$OS_USER/data/bilder
mkdir /home/$OS_USER/data/druckrahmen
mkdir /home/$OS_USER/data/mapfiles
mkdir /home/$OS_USER/data/nachweise
mkdir /home/$OS_USER/data/festpunkte
mkdir /home/$OS_USER/data/festpunkte/archiv
mkdir /home/$OS_USER/data/nas
mkdir /home/$OS_USER/data/recherchierte_auftraege
mkdir /home/$OS_USER/data/referencemaps
mkdir /home/$OS_USER/data/templates
mkdir /home/$OS_USER/data/upload
mkdir /home/$OS_USER/data/wms
mkdir /home/$OS_USER/logs
mkdir /home/$OS_USER/tmp
mkdir /home/$OS_USER/tmp/ms_tmp
echo "------------------------------------------------------"
echo "Download default data files for kvwmap"
cd /home/$OS_USER/data/druckrahmen
wget "http://gdi-service.de/public/kvwmap_resources/A4-quer.jpg"
wget "http://gdi-service.de/public/kvwmap_resources/A4-hoch.jpg"
cd /home/$OS_USER/data/mapfiles
wget "http://gdi-service.de/public/kvwmap_resources/defaultmapfile.map"
wget "http://gdi-service.de/public/kvwmap_resources/refmapfile.map"
cd /home/$OS_USER/data/referencemaps
wget "http://gdi-service.de/public/kvwmap_resources/uebersicht_mv.png"
echo "------------------------------------------------------"
echo "Set user rights to folder of $OS_USER"
chown -R $OS_USER.users /home/$OS_USER/*
chmod a+w /home/$OS_USER/data/bilder
chmod a+w /home/$OS_USER/data/recherchierte_auftraege
chmod a+w /home/$OS_USER/data/upload
chmod a+w /home/$OS_USER/logs
chmod -R a+w /home/$OS_USER/tmp
echo "------------------------------------------------------"
echo "forbid permission for root access via ssh"
echo "PermitRootLogin no" >> /etc/ssh/sshd_config
echo "------------------------------------------------------"
echo "einrichten einer Postgis-Template Datenbank"
su postgres -c "/usr/bin/createuser -s -P $PGUSER << EOF
$PGPASSWORD
$PGPASSWORD
EOF"
su $PGUSER
createdb template_postgis_$POSTGIS_VERSION -U $PGUSER
createlang plpgsql template_postgis_$POSTGIS_VERSION -U $PGUSER
psql -U $PGUSER -d template_postgis_$POSTGIS_VERSION -c "UPDATE pg_database SET datistemplate=true WHERE datname='template_postgis_${POSTGIS_VERSION}'"
psql -U $PGUSER -d template_postgis_$POSTGIS_VERSION -f $POSTGIS_CONTRIB_PATH/postgis.sql
exit
sed -i "s%26,-121,-78,0,0,0,0%24,-123,-94,0.02,-0.25,-0.13,1.1%g" $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "---" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "---" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "--- EPSG 5650 : ETRS89 / UTM zone 33N (zE-N)" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "---" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "INSERT INTO \"spatial_ref_sys\" (\"srid\",\"auth_name\",\"auth_srid\",\"srtext\",\"proj4text\") VALUES (5650,'EPSG',5650,'PROJCS[\"ETRS89 / UTM zone 33N (zE-N)\",GEOGCS[\"ETRS89\",DATUM[\"European_Terrestrial_Reference_System_1989\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6258\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4258\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",15],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",33500000],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH],AUTHORITY[\"EPSG\",\"5650\"]]','+proj=tmerc +lat_0=0 +towgs84=0,0,0,0,0,0,0 +lon_0=15 +k=0.9996 +x_0=33500000 +y_0=0 +ellps=GRS80 +units=m +no_defs');" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "---" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "---" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "--- EPSG 35833 : ETRS89 / UTM zone 33N mit fuehrenden 33" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "---" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "INSERT INTO \"spatial_ref_sys\" (\"srid\",\"auth_name\",\"auth_srid\",\"srtext\",\"proj4text\") VALUES (35833,'EPSG',35833,'PROJCS[\"ETRS89 / UTM zone 33N (zE-N)\",GEOGCS[\"ETRS89\",DATUM[\"European_Terrestrial_Reference_System_1989\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6258\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4258\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",15],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",33500000],PARAMETER[\"false_northing\",0],AUTHORITY[\"EPSG\",\"35833\"],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]','+proj=tmerc +lat_0=0 +towgs84=0,0,0,0,0,0,0 +lon_0=15 +k=0.9996 +x_0=33500000 +y_0=0 +ellps=GRS80 +units=m +no_defs');" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "---" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "--- EPSG 325833 : ETRS89 / UTM zone 33N mit fuehrenden 33" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "---" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "INSERT INTO \"spatial_ref_sys\" (\"srid\",\"auth_name\",\"auth_srid\",\"srtext\",\"proj4text\") VALUES (325833,'EPSG',325833,'PROJCS[\"ETRS89 / UTM zone 33N mit fuehrenden 3\",GEOGCS[\"ETRS89\",DATUM[\"European_Terrestrial_Reference_System_1989\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6258\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4258\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",15],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",3500000],PARAMETER[\"false_northing\",0],AUTHORITY[\"EPSG\",\"325833\"],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]','+proj=tmerc +lat_0=0 +towgs84=0,0,0,0,0,0,0 +lon_0=15 +k=0.9996 +x_0=3500000 +y_0=0 +ellps=GRS80 +units=m +no_defs');" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "---" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "--- EPSG 4839 : ETRS89 / LCC Germany (N-E)" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "---" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
echo "INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) values ( 4839, 'EPSG', 4839, '+proj=lcc +lat_1=48.66666666666666 +lat_2=53.66666666666666 +lat_0=51 +lon_0=10.5 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ', 'PROJCS[\"ETRS89 / LCC Germany (N-E)\",GEOGCS[\"ETRS89\",DATUM[\"European_Terrestrial_Reference_System_1989\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6258\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4258\"]],PROJECTION[\"Lambert_Conformal_Conic_2SP\"],PARAMETER[\"standard_parallel_1\",48.66666666666666],PARAMETER[\"standard_parallel_2\",53.66666666666666],PARAMETER[\"latitude_of_origin\",51],PARAMETER[\"central_meridian\",10.5],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"4839\"]]');" >> $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
psql -U $PGUSER -d template_postgis_$POSTGIS_VERSION -f $POSTGIS_CONTRIB_PATH/spatial_ref_sys.sql
psql -U $PGUSER -d template_postgis_$POSTGIS_VERSION -f $POSTGIS_CONTRIB_PATH/postgis_comments.sql
psql -U $PGUSER -d template_postgis_$POSTGIS_VERSION -f $POSTGIS_CONTRIB_PATH/rtpostgis.sql
psql -U $PGUSER -d template_postgis_$POSTGIS_VERSION -f $POSTGIS_CONTRIB_PATH/raster_comments.sql
psql -U $PGUSER -d template_postgis_$POSTGIS_VERSION -f $POSTGIS_CONTRIB_PATH/topology.sql
psql -U $PGUSER -d template_postgis_$POSTGIS_VERSION -f $POSTGIS_CONTRIB_PATH/topology_comments.sql
echo "--------------------------------------------------------"
echo "Einrichten der Rechte fuer den Zugang zur PG-Datenbank"
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" /etc/postgresql/9.1/main/postgresql.conf
sed -i "s/local all all peer/local all all md5/g" /etc/postgresql/9.1/main/pg_hba.conf
sed -i "s/# IPv4 local connections:/# IPv4 local connections:\nhost all all ${IP}\/32 md5/g" /etc/postgresql/9.1/main/pg_hba.conf
service postgresql restart
echo "------------------------------------------------------"
echo "install further helper software with apt-get install"
echo "------------------------------------------------------"
echo "install zip and unzip"
apt-get install -y zip
apt-get install -y unzip
echo "------------------------------------------------------"
echo "install image magick"
apt-get install -y imagemagick
echo "------------------------------------------------------"
echo "install git"
apt-get install -y git
echo "------------------------------------------------------"
echo "Download latest kvwmap"
cd /home/$OS_USER/apps
git clone https://github.com/srahn/kvwmap.git --branch develop --single-branch kvwmap
mkdir /home/$OS_USER/apps/kvwmap/layouts/custom
mkdir /home/$OS_USER/apps/kvwmap/layouts/snippets/custom
echo "------------------------------------------------------"
echo "Create web alias for kvwmap"
echo "Alias /kvwmap/ \"/home/$OS_USER/apps/kvwmap/\"" > /etc/apache2/sites-available/kvwmap
echo "<Directory /"home/$OS_USER/apps/kvwmap/">" >> /etc/apache2/sites-available/kvwmap
echo " AllowOverride None" >> /etc/apache2/sites-available/kvwmap
echo " Options Indexes FollowSymLinks Multiviews" >> /etc/apache2/sites-available/kvwmap
echo " Order allow,deny" >> /etc/apache2/sites-available/kvwmap
echo " Allow from all" >> /etc/apache2/sites-available/kvwmap
echo "</Directory>" >> /etc/apache2/sites-available/kvwmap
ln -s /etc/apache2/sites-available/kvwmap /etc/apache2/sites-enabled/010-kvwmap
echo "------------------------------------------------------"
echo "Create web alias for mapserver tmp files"
echo "Alias /tmp/ \"/home/$OS_USER/tmp/\"" > /etc/apache2/sites-available/mapserver
echo "<Directory \"/home/$OS_USER/tmp/\">" >> /etc/apache2/sites-available/mapserver
echo " Options None" >> /etc/apache2/sites-available/mapserver
echo " AllowOverride None" >> /etc/apache2/sites-available/mapserver
echo " Order allow,deny" >> /etc/apache2/sites-available/mapserver
echo " Allow from all" >> /etc/apache2/sites-available/mapserver
echo "</Directory>" >> /etc/apache2/sites-available/mapserver
ln -s /etc/apache2/sites-available/mapserver /etc/apache2/sites-enabled/005-mapserver
echo "------------------------------------------------------"
echo "switch on php display errors in php.ini"
sed -i "s/display_errors = Off/display_errors = On/g" /etc/php5/apache2/php.ini
sed -i "s/session.auto_start = 0/session.auto_start = 1/g" /etc/php5/apache2/php.ini
sed -i "s/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 3600/g" /etc/php5/apache2/php.ini
sed -i "s/max_execution_time = 30/max_execution_time = 60/g" /etc/php5/apache2/php.ini
sed -i "s/memory_limit = 128M/memory_limit = 256M/g" /etc/php5/apache2/php.ini
sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 20M/g" /etc/php5/apache2/php.ini
sed -i "s%error_reporting = E_ALL error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT ~E_NOTICE%error_reporting = E_ALL & ~E_NOTICE%g" /etc/php5/apache2/php.ini
service apache2 reload
cd /home/$OS_USER/apps
echo "------------------------------------------------------"
echo "Konfiguriere kvwmap"
cp kvwmap/config-default.php kvwmap/config.php
sed -i "s%define('INSTALLPATH','/home/gisadmin/');%define('INSTALLPATH','/home/$OS_USER/');%g" kvwmap/config.php
sed -i "s%define('URL','http://localhost/');%define('URL','http://$IP/');%g" kvwmap/config.php
chown -R $OS_USER.$OS_USER kvwmap
echo "------------------------------------------------------"
echo "Richte Postgresql Datenbank kvwmapsp ein"
PGPASSWORD=$PGPASSWORD createdb kvwmapsp -U $PGUSER -T template_postgis_$POSTGIS_VERSION
PGPASSWORD=$PGPASSWORD psql -U $PGUSER -d kvwmapsp -f /home/$OS_USER/apps/kvwmap/layouts/sql_dumps/postgis_install.sql
echo "------------------------------------------------------"
echo "Richte MySQL Datenbank kvwmapdb ein"
mysql --user=$MYUSER --password=$MYPASSWORD -e "CREATE USER '$KVWMAPUSER'@'localhost' IDENTIFIED BY '$KVWMAPPASSWORD'"
mysql --user=$MYUSER --password=$MYPASSWORD -e "GRANT ALL PRIVILEGES ON * . * TO '$KVWMAPUSER'@'localhost'"
mysql --user=$MYUSER --password=$MYPASSWORD -e "CREATE DATABASE kvwmapdb CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT ALL PRIVILEGES ON kvwmapdb.* TO $KVWMAPUSER@localhost IDENTIFIED BY '$KVWMAPPASSWORD'"
mysql --user=$KVWMAPUSER --password=$KVWMAPPASSWORD kvwmapdb < /home/$OS_USER/apps/kvwmap/layouts/sql_dumps/mysql_install.sql
sed -i "s/SET @kvwmap_password='kvwmap';/SET @kvwmap_password='$KVWMAPPASSWORD';/g" kvwmap/layouts/sql_dumps/mysql_install_admin.sql
mysql --user=$KVWMAPUSER --password=$KVWMAPPASSWORD kvwmapdb < /home/$OS_USER/apps/kvwmap/layouts/sql_dumps/mysql_install_admin.sql