#!/bin/sh # postinst script for owsproxy # # see: dh_installdeb(1) set -e # source debconf library #export DEBCONF_DEBUG=developer # for debugging . /usr/share/debconf/confmodule PKGNAME=deegree-owsproxy TOMCATDIR=/opt/gispatcher/owsproxy/webapps/owsproxy db_capb escape db_settitle ${PKGNAME}/title # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package case "$1" in configure) # dialog for setting the db-host db_input high ${PKGNAME}/dbhost || true db_go db_get ${PKGNAME}/dbhost && dbhost=$RET if [ "$RET" = "false" ]; then db_input high ${PKGNAME}/dbhost db_get ${PKGNAME}/dbhost && dbhost=$RET db_go fi # dialog for setting the db-port db_input high ${PKGNAME}/dbport || true db_go db_get ${PKGNAME}/dbport && dbport=$RET if [ "$RET" = "false" ]; then db_input high ${PKGNAME}/dbport db_get ${PKGNAME}/dbport && dbport=$RET db_go fi # set up the appropriate database named gispatcher_owsproxy_security db_input high ${PKGNAME}/dbname || true db_go db_get ${PKGNAME}/dbname && dbname=$RET if [ "$RET" = "false" ]; then db_input high ${PKGNAME}/dbname db_get ${PKGNAME}/dbname && dbname=$RET db_go fi # dialog for setting the db-user db_input high ${PKGNAME}/dbuser || true db_go db_get ${PKGNAME}/dbuser && dbuser=$RET if [ "$RET" = "false" ]; then db_input high ${PKGNAME}/dbuser db_get ${PKGNAME}/dbuser && dbuser=$RET db_go fi # Dialog for setting the admin-password for the database db_input high ${PKGNAME}/adminpassword || true db_go db_get ${PKGNAME}/adminpassword && adminpw=$RET if [ "$RET" = "false" ]; then db_input high ${PKGNAME}/adminpassword db_get ${PKGNAME}/adminpassword && adminpw=$RET db_go fi # Dialog for setting the WMS-URL db_input high ${PKGNAME}/wmsurl || true db_go db_get ${PKGNAME}/wmsurl && wmsurl=$RET if [ "$RET" = "false" ]; then db_input high ${PKGNAME}/wmsurl db_get ${PKGNAME}/wmsurl && wmsurl=$RET db_go fi # FIXME: WFS-Dialog is commented out unless we have tested the # WFS-component of deegree more deeply. This is no the case # actually yet. ## Dialog for setting the WFS-URL #db_input high ${PKGNAME}/wfsurl || true #db_go #db_get ${PKGNAME}/wfsurl && wfsurl=$RET #if [ "$RET" = "false" ]; then # db_input high ${PKGNAME}/wfsurl # db_get ${PKGNAME}/wfsurl && wfsurl=$RET # db_go #fi # GET Tomcat-Port and target-webapps-name db_get gispatcher-integration-owsproxy/tc_connector_port && tc_connector_port=$RET db_get gispatcher-integration-owsproxy/tc_proxy_target && tc_proxy_target=$RET db_get gispatcher-integration/vhostname && vhostname=$RET # check, if database is already there db_get ${PKGNAME}/db_installed && db_is_installed=$RET if [ "${db_is_installed}" != "true" ] ; then # create database PWD="/tmp/bla$$.log" PGDB="/tmp/blub$$.sql" echo "ALTER USER ${dbuser} ENCRYPTED PASSWORD '$adminpw';" > ${PWD} # import the schema as user ${dbuser}, but connect as user # postgres (without password) echo "SET ROLE ${dbuser};" > ${PGDB} # install database only on localhost, otherwise we most probably do not have # access to the needed password if [ "${dbhost}" == "localhost" ] ; then su postgres -c "createuser -SDRl ${dbuser}" > /dev/null su postgres -c "createdb -O ${dbuser} ${dbname}" >/dev/null gunzip -c /usr/share/doc/${PKGNAME}/create-security-postgres.sql.gz >> ${PGDB} su postgres -c "psql ${dbname} -f ${PWD}" > /dev/null su postgres -c "psql ${dbname} -f ${PGDB}" >/dev/null else db_input high ${PKGNAME}/noremote-inst || true db_go fi # Set flag to true if database is published db_set ${PKGNAME}/db_installed "true" rm -f ${PWD} ${PGDB} fi # set configuration:WMS sed -i "s|@database@|${dbname}|" ${TOMCATDIR}/WEB-INF/conf/security/wmspolicy.xml sed -i "s|@username@|${dbuser}|" ${TOMCATDIR}/WEB-INF/conf/security/wmspolicy.xml sed -i "s|@databasehost@|${dbhost}|" ${TOMCATDIR}/WEB-INF/conf/security/wmspolicy.xml sed -i "s|@databaseport@|${dbport}|" ${TOMCATDIR}/WEB-INF/conf/security/wmspolicy.xml sed -i "s|@password@|${adminpw}|" ${TOMCATDIR}/WEB-INF/conf/security/wmspolicy.xml sed -i "s|@OWSPROXY_WMS@|${wmsurl}|" ${TOMCATDIR}/WEB-INF/web.xml # FIXME: WFS-Dialog is commented out unless we have tested the # WFS-component of deegree more deeply. This is no the case # actually yet. ## set configuration:WFS #sed -i "s|@database@|${dbname}|" ${TOMCATDIR}/WEB-INF/conf/security/wfspolicy.xml #sed -i "s|@username@|${dbuser}|" ${TOMCATDIR}/WEB-INF/conf/security/wfspolicy.xml #sed -i "s|@databasehost@|${dbhost}|" ${TOMCATDIR}/WEB-INF/conf/security/wmspolicy.xml #sed -i "s|@databaseport@|${dbport}|" ${TOMCATDIR}/WEB-INF/conf/security/wmspolicy.xml #sed -i "s|@password@|${adminpw}|" ${TOMCATDIR}/WEB-INF/conf/security/wfspolicy.xml #sed -i "s|@OWSPROXY_WFS@|${wfsurl}|" ${TOMCATDIR}/WEB-INF/web.xml # misc stuff:Set proxy-URL sed -i "s|@TC_CONNECTOR_PORT@|${tc_connector_port}|" ${TOMCATDIR}/WEB-INF/web.xml sed -i "s|@TC_PROXY_TARGET@|${tc_proxy_target}|" ${TOMCATDIR}/WEB-INF/web.xml sed -i "s|@SERVER_URL@|${vhostname}|" ${TOMCATDIR}/WEB-INF/web.xml db_input high ${PKGNAME}/finish || true db_go ;; upgrade) # if there is already a database set up, dont create annother one db_get ${PKGNAME}/dbname && dbname=$RET db_input high ${PKGNAME}/dbupdate || true db_go exit 0 ;; abort-upgrade|abort-remove|abort-deconfigure) # FIXME: implement me exit 0 ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. exit 0