#!/bin/sh
#
# the following script installs PHP version of demo program for MapServer.
# 
#--
mkdir -p /opt/htdocs/mapserver_demos/tmp
chown www.apache /opt/htdocs/mapserver_demos/tmp
WORK=/tmp
#WORK=/expo/Build/mapserver/Custom
(cd $WORK;
  wget -N http://www.maptools.org/dl/ms4w/ms_ogc_workshop-1.0.10.zip )

DEMOROOT=/opt/htdocs/mapserver_demos
mkdir -p $DEMOROOT/ms_ogc_workshop
( cd $DEMOROOT/
  unzip $WORK/ms_ogc_workshop-1.0.10.zip
  rm -rf ./ms_ogc_workshop
  mv ./ms4w/apps/ms_ogc_workshop ./
  rm -rf ./ms4w )
( cd $DEMOROOT/ms_ogc_workshop/;
  for i in `find . -type f`; do \
    sed -e 's%/ms4w/tmp/ms_tmp%/opt/htdocs/mapserver_demos/tmp%' \
	-e 's%mapserv.exe%mapserv%' \
	-e 's%/ms4w/apps/ms_ogc_workshop%/opt/htdocs/mapserver_demos/ms_ogc_workshop%' \
	$i > $i.new;
    if `diff ${i} ${i}.new > /dev/null 2>&1`; then
      rm  $i.new;
    else
      mv -v $i.new $i;
    fi
  done
)


cat >/opt/httpd/conf/conf.d/ms_ogc_workshop.conf<<_EOF_
# ms_ogc_workshop mapserver demo
Alias /ms_ogc_workshop/   "/opt/htdocs/mapserver_demos/ms_ogc_workshop/"
Alias /ms_tmp/ "/opt/htdocs/mapserver_demos/tmp/"

SetEnvIfNoCase Request_URI "/cgi-bin/ms_ogc_workshop" MS_MAPFILE=/opt/htdocs/mapserver_demos/ms_ogc_workshop/service/config.map
_EOF_


/etc/rc.d/init.d/httpd restart
#--
# access http://localhost/ms_ogc_workshop/ to check it
#							note by J.Kuwamura
