#!/bin/sh
dialog --title " KBackup is protected under the terms of the GPL: " --textbox COPYING 20 78
if dialog --title " KBackup Installation " --inputbox "
Where do you want KBackup to store its data files?

A reasonable place for this would be \"/var/lib/KBackup\".
Just press ENTER to confirm this default.

Please enter a directory to install the datafiles into:" 15 76 2>/tmp/.tmp$$
then
	datadir=`cat /tmp/.tmp$$`
	if [ "$datadir" = "" ]
	then
		datadir=/var/lib/KBackup
	fi
else
	echo Installation aborted.
	reset
	clear
	exit
fi

if dialog --title " KBackup Installation " --inputbox "
Where do you want to install the \"kbackup\" program itself?

A reasonable place for this would be \"/usr/local/bin\".
Just press ENTER to confirm this default.

Please enter a place for kbackup:" 15 76 2>/tmp/.tmp$$
then
	progdir=`cat /tmp/.tmp$$`
	if [ "$progdir" = "" ]
	then
		progdir=/usr/local/bin
	fi
else
	echo Installation aborted.
	reset
	clear
	exit
fi

dialog --title " KBackup Installation " --infobox "
Installing data files...

" 5 30 

install -d $datadir
cp -ar data/* $datadir

dialog --title " KBackup Installation " --infobox "
Installing Program...

" 5 30 

install -m a=rx kbackup $progdir

cat >~/.kbackrc <<_EOF_
#
#       KBackup base configuration
#
kbackdir=$datadir
configname=Default
_EOF_

while :
do

if dialog --title " KBackup Installation " --menu "

The manual is also included as an online help in
the program itself. However, maybe you'd like to
print it now (requires A4 paper) ?

" 18 56 5 \
I	"Install Documentation in /usr/doc/KBackup" \
P	"Print Manual 1 page per A4 sheet of paper" \
2	"Print Manual with 2 pages per A4 sheet of paper" \
V	"View README file with release notes" \
E	"End Installation"  2>/tmp/.tmp$$
then
	case `cat /tmp/.tmp$$` in
	I)	install -d /usr/doc/KBackup
		install -m a=r doc/* /usr/doc/KBackup
		;;
	P)	lpr doc/KBackup.ps
		;;
	2)	lpr doc/KBackup-2.ps
		;;	
	V)	less README
		;;
	E)	reset
		clear
		rm /tmp/.tmp$$
		exit
		;;
	esac
fi
done

