#!/bin/sh
#--------------------------------------------------------------------
# Config for tbbsV1.3.xx
# configuration program for tbbs
# WARNIG : This program is alpha !
#
# If you have any problems or bugs with this program, 
# please let me know.
#
# This script needs dialog 0.4
# 
# (c) 1995   <runge@nina.boerde.de>
#

#Your favorite editor
#EDITOR="joe " 
EDITOR=`cat ../etc/config/EDITOR`

#Your 'Multimedia-Editor'
WENDY=`cat ../etc/config/M.EDITOR`

LESS=`cat ../etc/config/LESS`



# tempory file
TEMP=/tmp/tbbs.setup/config.answers

# config file
CONFIG_BACK=/tmp/config.backup


CONFIG=/tmp/tbbs.config


DIALOG=dialog

#Dialog-Switch-File
DLCK=/tmp/tbbs.setup/dialog





#
# define_bool sets the value of a boolean argument
#
#	define_bool define value
#
function define_bool () {
        case "$2" in
         "y" | "Y")
		echo "$1=y" >>$CONFIG
		echo "#define $1 1" >>$CONFIG_H
		;;

         "m" | "M")
		echo "$1=m" >>$CONFIG
		echo "#undef  $1" >>$CONFIG_H
		;;

         "n" | "N")
		echo "# $1 is not set" >>$CONFIG
		echo "#undef  $1" >>$CONFIG_H
                ;;
	esac
	eval "$1=$2"
}


#
# readln reads a line into $ans.
#
#       readln prompt default
#
function readln () {
        if [ "$DEFAULT" = "-d" ]; then
                echo "$1"
                ans=$2
        else
                echo -n "$1"
                IFS='@' read ans </dev/tty || exit 1
                [ -z "$ans" ] && ans=$2
        fi
}






function bool () {
        ans=""
        def="y"
        case "$def" in
         "y") defprompt="Y/n"
              ;;
         "n") defprompt="N/y"
              ;;
        esac
        while [ "$ans" != "y" -a "$ans" != "n" ]; do
                readln "$1 [$defprompt] " "$def"
        done

}





do_main() {

if test -f $DLCK; then \
   dialog --title "Automatic-Checkit-Tool" --yesno \
"\nWill you check read-only (no changes) ?\n\
\n\n\
You Select?" 11 70 ; \
    if [ ! $? = 0 ]; then
	../bin/bbs.checkit +c
	sleep 3
	exit
    fi
../bin/bbs.checkit +a
sleep 3
else \
   clear ; 
   echo "tbbs: Automatic-Checkit-Tool" ;
   echo "---------------------------------------------------------------" ;
   echo ;
   echo "Will you check read-only (no changes) ?" ;
   bool ;
   case $ans in
         "y" | "Y")
		clear ;
	        ../bin/bbs.checkit +c ;
        	sleep 3 ;
		exit ;
		;;

         "n" | "N")
		clear ;
	        ../bin/bbs.checkit +a ;
        	sleep 3 ;
		exit ;
                ;;
    esac
fi


}




# +++++ main() ++++++
do_main
