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





user_expire() {
echo "wait....."
while true 
do
if test -f $DLCK; then \
$DIALOG --title "after many 'not-login-days' the usr-account will been remove?" \
   --menu "\n\
currect selection is: `cat ../etc/config/expire.days` days\n\n\
warning: user-account will remove after XX days (without login)!\n\n\
comment: all menu-entry with \"!\" at the begin of the line\n\
         are until now present. " 22 70 9 \
  1 "7" \
  2 "14"  \
  3 "30" \
  4 "60" \
  5 "120" \
  6 "240" \
  7 "365" \
  8 "400" \
  9 "none (user-expire is inactive)" \
  f "Quit       : main-menu" \
2> $TEMP ; \
else \
  clear; \
  echo "tbbs: user-expire-daemon"; \
  echo "=======================================================================" ; \
  echo " after many 'not-login-days' the usr-account will been remove?"	; \
  echo " warning: user-account will remove after XX days (without login)!"; \
  echo "(1) 7" ; \
  echo "(2) 14" ;  \
  echo "(3) 30" ; \
  echo "(4) 60"; \
  echo "(5) 120"; \
  echo "(6) 240"; \
  echo "(7) 365"; \
  echo "(8) 400"; \
  echo "(9) none (user-expire is inactive)"; \
  echo "-----------------------------------------------------"; \
  echo "(f) Quit       : main-menu"; \
  ans="c" ; \
  PROMPT="please select" ; \
  PROMPT2="1..9,f" ; \
  readln ;\
  echo "select-code: " ; \
  echo $ans ; \
  echo $ans >$TEMP; \

fi

#cat $TEMP
#sleep 5

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


choice=`cat $TEMP`
case $choice in
   0) exit;;
   1) echo "7" >../etc/config/expire.days;;
   2) echo "14" >../etc/config/expire.days;;
   3) echo "30" >../etc/config/expire.days;;
   4) echo "60" >../etc/config/expire.days;;
   5) echo "120" >../etc/config/expire.days;;
   6) echo "240" >../etc/config/expire.days;;
   7) echo "365" >../etc/config/expire.days;;
   8) echo "400" >../etc/config/expire.days;;
   9) rm -f ../etc/config/expire.days;;
   f) clear;
      echo "return to main..."
      exit;
esac
done
}  




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

dialog --title "User-Expire-Daemon (bbs.update) " \
   --menu "\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 70 9 \
  1 "expire-user-account after XX days" \
  2 "edit \"invalid-user-entry\"mail (get user with invalid entrys)" \
  3 "!??????          " \
  f "Quit       : main-menu" \
2> $TEMP

#cat $TEMP
#sleep 5

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


choice=`cat $TEMP`
case $choice in
   0) exit;;
   1) user_expire;;
   2) $EDITOR ../etc/mail/invalid.entry.txt;;
   3) do_noimpl;;
   f) clear;
      echo "return to main..."
      exit;
esac
done
}  

while true
do 
#  bbsd_main
   user_expire
done
