#!/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


level_question() {


dialog --title "level-selection for tbbs " \
   --menu \
"please select the level from the following list \n\n\
At this time the tbbs-setup-script is verry expermiental!\n\
comment: all menu-entry with \"!\" at the begin of the line\n\
         are until now present. " 22 74 9 \
  0 "Level 0 : exampl. guest/gast                                     " \
  1 "Level 1 : exampl. new-user with post-office                      " \
  2 "Level 2 : exampl. user is permitted for writing external mail    " \
  3 "Level 3 : exampl. pd-upload is aviable                           " \
  4 "Level 4 : exampl. pd-upload (mkdir-command)                      " \
  5 "Level 5 : exampl. posting news-article                           " \
  6 "Level 6 : exampl. pd-upload direct in download-area(not incoming)" \
  7 "Level 7 : exampl. telnet etc.                                    " \
  8 "Level 8 : exampl. shell-permission                               " \
  a "Quit    : main-menu                                              " \
2> $TEMP


#ERROR=$?
#if [ $ERROR = 1 -o $ERROR = 255 ]; then
#  exit 1;
#fi
    if [ ! $? = 0 ]; then
     main
    fi

choice=`cat $TEMP`
case $choice in
   a) clear;
      echo "return to main..."
      main;
esac

}






start_level_question() {


dialog --title "level-selection for tbbs (startup-level for new-user) " \
   --menu \
"please select the level from the following list \n\n\
At this time the tbbs-setup-script is verry expermiental!\n\
comment: all menu-entry with \"!\" at the begin of the line\n\
         are until now present. " 22 74 9 \
  1 "Level 1 : exampl. new-user with post-office                      " \
  2 "Level 2 : exampl. user is permitted for writing external mail    " \
  3 "Level 3 : exampl. pd-upload is aviable                           " \
  4 "Level 4 : exampl. pd-upload (mkdir-command)                      " \
  5 "Level 5 : exampl. posting news-article                           " \
  6 "Level 6 : exampl. pd-upload direct in download-area(not incoming)" \
2> $TEMP


#ERROR=$?
#if [ $ERROR = 1 -o $ERROR = 255 ]; then
#  exit 1;
#fi
    if [ ! $? = 0 ]; then
     main
    fi

choice=`cat $TEMP`
case $choice in
   a) clear;
      echo "return to main..."
      main;
esac

}



do_writein() {

level_question;

mv $TEMP ../etc/config/write_in_level
main;
}


do_mailout() {

level_question;

mv $TEMP ../etc/config/mailout_level
main;
}

do_write_ex() {

level_question;

mv $TEMP ../etc/config/write_ex_level
main;
}


do_exe() {

level_question;

mv $TEMP ../etc/config/exe_level
main;
}


do_pd_d() {

level_question;

mv $TEMP ../etc/config/pd_d_level
main;
}



do_pd_u() {

level_question;

mv $TEMP ../etc/config/pd_u_level
main;
}


do_startup_level() {

start_level_question;

mv $TEMP ../etc/config/startup_level
main;
}







# ---------------- main() -------------------------------------
main() {
echo "wait....."
while true 
do


dialog --title "level-defaults / permission " \
   --menu "\n\
warning: this adjustments are bbs-global!\n\n\
comment: guest-level is default==0, administartion/sysop==9 \n" 22 70 9 \
  1 "writing internal mail 'WRITE_IN_LEV'=`cat ../etc/config/write_in_level`" \
  2 "writing external mail 'MAILOUT_LEV'=`cat ../etc/config/mailout_level`" \
  3 "writing news-article 'WRITE_EX_LEV'=`cat ../etc/config/write_ex_level` " \
  4 "shell execution 'EXE_LEV=`cat ../etc/config/exe_level` " \
  7 "------------------------------------------------------" \
  8 "freeware download 'PD_D_LEV'=`cat ../etc/config/pd_d_level` " \
  9 "pd-upload'PD_U_LEV'=`cat ../etc/config/pd_u_level`(no incoming lev+1,mkdir lev+2)" \
  a "'STARTUP_LEVEL'=`cat ../etc/config/startup_level` (start-level for new-users 'account'-cmd)" \
  b "------------------------------------------------------" \
  f "Quit       : main-menu" \
2> $TEMP




#cat $TEMP
#sleep 5

    if [ ! $? = 0 ]; then
     exit
    fi


choice=`cat $TEMP`
case $choice in
   0) exit;;
   1) do_writein;;
   2) do_mailout;;
   3) do_write_ex;;
   4) do_exe;;
   5) do_noimpl;;
   6) do_noimpl;;
   8) do_pd_d;;
   9) do_pd_u;;
   a) do_startup_level;;
   f) clear;
      echo "return to main..."
      exit;
esac
done
}  

while true
do 
  main
done
