#!/bin/sh

# DESTDIR is a directory SSServer will be installed to.
DESTDIR="/usr/local/www/cgi-bin"

#--------------------------------------------------------------
# do not edit anything below
#--------------------------------------------------------------

cat <<!

This script will install SSServer into $DESTDIR
If you want to change the destination directory, answer N and edit the value of
the DESTDIR variable at the beginning of the script.

!
echo -n Do you want to install SSServer into $DESTDIR ? [y/N]
read REPLY
if [ "$REPLY" != "y" -a "$REPLY" != "Y" ] ; then exit 1; fi

#making directories
DATADIR="$DESTDIR/ssserverdata"
RWFILES="filelist.txt layout_s.htm layout_l.htm sitemap.htm help.htm ssserver.ini"

MKDIRHIER=`which mkdirhier 2>/dev/null`
if test $? -ne 0 ; then MKDIRHIER=mkdir; fi

if [ -z $DESTDIR ] ; then echo "DESTDIR cannot be empty"; exit 1; fi
echo ">>Making directories..."
if [ ! -d $DESTDIR ]; then $MKDIRHIER $DESTDIR; fi
if [ ! -d $DATADIR ]; then $MKDIRHIER $DATADIR; fi
chmod 777 $DATADIR
if test $? -ne 0 ; then
 echo
 echo Warning: make sure that the user who httpd runs as is allowed to write in $DATADIR
 echo
fi

#copying files
echo ">>Copying files..."
cp -fp www/cgi-bin/ssserver $DESTDIR
cp -fp www/cgi-bin/image $DESTDIR
cp -fp www/cgi-bin/ssserverdata/* ${DATADIR}
for i in $RWFILES; do chmod  666 $DATADIR/$i; done
for i in `ls $DATADIR/sampleform?.htm`; do chmod  666 $i; done

#write deinstall script
cat <<!>$DATADIR/Makefile
default:
	@echo Uninstall script for SSServer
	@echo Usage: make deinstall
	@echo
deinstall:
	@echo -n Uninstalling SSServer...
	@rm -f ../ssserver
	@rm -f ../image
	@(cd ..; rm -fR ssserverdata)
	@echo Done
!

cat <<!	
>>SSServer was successfully installed into $DESTDIR
Make sure that your Web server allows executing scripts in this directory.

To configure SSServer, run the Web-based configuration utility at
http://<your_web_server_address>/<virtual_path_to_SSServer>/ssserverdata/sssconf

You may find additional information in readme.htm and problems.htm files
located in $DATADIR.

To uninstall SSServer, select the directory
$DATADIR and type:

make deinstall


Send your questions and comments to Kryloff Technologies' technical
support service at support@kryltech.com

!
