#! /bin/sh
#
# Script zur Einrichtung von TNT
# Written by Matthias Hensler, wsp@gmx.de
# Copyright WSPse 1998
#
# Script-Version: 1.0d
# Script-Revision: 12/10/98, 5/1/99, 12/1/99
# TNT-Version: 1.1alpha13/sound, 1.2/sound
#
# Created: 10.10.1998 by Matthias Hensler
# Updated:  5.01.1999 by Matthias Hensler: fixed /dev/cua to /dev/ttyS
# Updated:  9.01.1999 by Matthias Hensler: program exits after installation
# Updated: 12.01.1999 by Matthias Hensler: ready for TNT 1.4

# Globals
MAINPATH=/usr/local/tnt # Default Mainpath
TERMCALL=EMPTY
BOXCALL=EMPTY
BAUD=9600               # Default Baud-Rate
DEVICE=/dev/ttyS0       # Default Device
SOFTTNC=0               # Default TNC-Type
LOCKFILE=/var/lock/LCK..tnt # Default Lockfile
TNCCHAN=10              # Default TNC-Channels
TNCREDBUF=5             # Default First Channel with reduced backscroll
REMOTEUSER=root         # Default Remoteuser
UNIXNEWUSER=1           # Default Create New User
UNIXFIRSTUID=410        # Default Lowest Userid for New User
UNIXGID=101             # Default Group ID for New User
HEARTENTRY=50           # Calls in Heartlist
LINES_MONITOR=500       # Lines for Monitor
LINES_INPUT=100         # Lines for Input on Connectscreen
LINES_OUTPUT=900        # Lines for Output on Connectscreen
LINES_R_INPUT=50        # Lines for Input (reduced)
LINES_R_OUTPUT=600      # Lines for Output (reduced)
LINES_BOXOUT=500        # Lines for Mailbox
MON_LINES=5             # Screendevide
COLOR=2                 # Color on
ALTSTAT=1               # Alternate Status on
FRONTEND=localhost:5002 # Frontendsocket
BOXFRONT=/usr/local/box/stat/socket
COOKIE=/usr/share/fortune/startrek
ENABLE_RESY=#

DEFTYP0=/dev/ttyS0
DEFTYP1=/usr/local/tfkiss/socket
DEFTYP2=localhost:5001

show_docs()
{
  while [ 1 ] ; do
    dialog --title "Dokumentation zeigen" \
           --backtitle "Select" \
           --menu "Was wollen Sie wissen?" 11 60 4 \
           DOC "Dokumentation zum PR-Programm TNT" \
           README "Informationen ueber diese Version" \
           COPYING "Copyrightinformationen" \
           INFO "Infos zu TNT-Setup" \
           2>/tmp/$$
    if [ ! $? = 0 ] ; then
      return
    fi
    read WHICH < /tmp/$$
    case "$WHICH" in
      DOC) dialog --title "TNT-Dokumentation" \
                  --backtitle "Read..." \
                  --textbox ./other/tnt.doc 25 80;;
      README) dialog --title "TNT-Readme" \
                     --backtitle "Read..." \
                     --textbox ./other/README 25 80;;
      COPYING) dialog --title "Copyrightinformation" \
                      --backtitle "Read..." \
                      --textbox ./other/COPYING 25 80;;
      INFO) dialog --title "Info" \
                   --backtitle "Read..." \
                   --msgbox "TNT-Setup V1.0\nWritten by Matthias Hensler\nCopyright WSPse 1998\neMail: wsp@gmx.de\n\nRechte unterliegen der GPL\n(siehe auch COPYING)" 11 35;;
    esac
  done
}
sel_baud_rate()
{
  dialog --title "Baudrate einstellen" \
         --menu "Default: $BAUD" 13 40 6 \
         1200 "Baud" \
         2400 "Baud" \
         4800 "Baud" \
         9600 "Baud" \
         19200 "Baud" \
         38400 "Baud" \
         2>/tmp/$$
  if [ $? = 0 ] ; then
    read BAUD < /tmp/$$
  fi
}

sel_color()
{
  dialog --title "Farbeinstellungen" \
         --menu "Default: $COLOR" 11 60 4 \
         0 "Monochrom" \
         1 "Farbe falls Terminaltyp = Linux" \
         2 "Farbe" \
         3 "Farbe falls Terminaltyp = Xterm" \
         2>/tmp/$$
  if [ $? = 0 ] ; then
    read COLOR < /tmp/$$
  fi
}

global_menu()
{
  while [ 1 ] ; do
    dialog --title "Globale Einstellungen" \
           --backtitle "Select..." \
           --menu "Auswahl:" 14 80 7 \
           MAIN "Hauptpfad: $MAINPATH" \
           LOCK "Lockfile: $LOCKFILE" \
           TNTC "Frontend: $FRONTEND" \
           BOX "Boxsocket: $BOXFRONT" \
           COOKIE "Cookiedatei: $COOKIE" \
           MENU "Zurueck zum Hauptmenu" \
           HELP "Eine kleine Hilfe" \
           2>/tmp/$$
    if [ ! $? = 0 ] ; then
      return
    fi
    read WHICH < /tmp/$$
    case "$WHICH" in
      HELP) dialog --textbox "./other/Readme1" 25 80;;
      MENU) return;;
      MAIN) dialog --inputbox "Hauptpfad von TNT" 8 80 "$MAINPATH" 2>/tmp/$$
            if [ $? = 0 ] ; then
              read MAINPATH < /tmp/$$
            fi;;
      LOCK) dialog --inputbox "Lockfile fuer TNT" 8 80 "$LOCKFILE" 2>/tmp/$$
            if [ $? = 0 ] ; then
              read LOCKFILE < /tmp/$$
            fi;;
      TNTC) dialog --inputbox "Frontendsocket fuer die TNT-Konsole" \
            8 80 "$FRONTEND" 2>/tmp/$$
            if [ $? = 0 ] ; then
              read FRONTEND < /tmp/$$
            fi;;
      BOX) dialog --inputbox "Socket der Mailbox (sofern vorhanden)" \
           8 80 "$BOXFRONT" 2>/tmp/$$
           if [ $? = 0 ] ; then
             read BOXFRONT < /tmp/$$
           fi;;
      COOKIE) dialog --inputbox "Cookiedatei (zB aus dem Fortunebereich)" \
              8 80 "$COOKIE" 2>/tmp/$$
              if [ $? = 0 ] ; then
                read COOKIE < /tmp/$$
              fi;;
    esac
  done
}

sel_tnc_type()
{
  dialog --title "TNC-Typ" \
         --backtitle "Select..." \
         --menu "Auswahl:" 10 60 3 \
         TYP0 "Reales TNC an einer Schnittstelle" \
         TYP1 "TFKISS auf einem Unix-Socket" \
         TYP2 "TFKISS auf einem Netzwerk-Socket" \
         2>/tmp/$$
  if [ ! $? = 0 ] ; then
    return
  fi
  read WHICH < /tmp/$$
  case "$WHICH" in
    TYP0) SOFTTNC=0
          DEVICE=$DEFTYP0;;
    TYP1) SOFTTNC=1
          DEVICE=$DEFTYP1;;
    TYP2) SOFTTNC=2
          DEVICE=$DEFTYP2;;
  esac
}

sel_tnc_device()
{
  if [ "$SOFTTNC" = "0" ] ; then
    dialog --title "TNC-Schnittstelle" \
           --backtitle "Select..." \
           --menu "Auswahl:" 11 40 4 \
           COM1 "1. Schnittstelle" \
           COM2 "2. Schnittstelle" \
           COM3 "3. Schnittstelle" \
           COM4 "4. Schnittstelle" \
           2>/tmp/$$
    if [ ! $? = 0 ] ; then
      return
    fi
    read WHICH < /tmp/$$
    case "$WHICH" in
      COM1) DEVICE=/dev/ttyS0;;
      COM2) DEVICE=/dev/ttyS1;;
      COM3) DEVICE=/dev/ttyS2;;
      COM4) DEVICE=/dev/ttyS3;;
    esac
    return
  fi
  dialog --inputbox "Socket fuer das TNC" 8 80 "$DEVICE" 2>/tmp/$$
  if [ $? = 0 ] ; then
    read DEVICE < /tmp/$$
  fi
}

tnc_menu()
{
  while [ 1 ] ; do
    case "$SOFTTNC" in
      0) TYPDES="Echtes TNC";;
      1) TYPDES="TFKISS auf einem Unix-Socket";;
      2) TYPDES="TFKISS auf einem Netzwerk-Socket";;
    esac
    dialog --title "TNC Einstellungen" \
           --backtitle "Select..." \
           --menu "Auswahl:" 13 70 6 \
           TYP "TNC-Typ: $SOFTTNC ($TYPDES)" \
           BAUD "Baud-Rate (nur fuer TNC-Typ 0): $BAUD" \
           DEVICE "TNC-Device/Schnittstelle: $DEVICE" \
           CHAN "Anzahl der TNC-Kanaele: $TNCCHAN" \
           MENU "Zurueck zum Hauptmenu" \
           HELP "Eine kleine Hilfe" \
           2>/tmp/$$
    if [ ! $? = 0 ] ; then
      return
    fi
    read WHICH < /tmp/$$
    case "$WHICH" in
      HELP) dialog --textbox "./other/Readme2" 25 80;;
      MENU) return;;
      BAUD) sel_baud_rate;;
      CHAN) dialog --inputbox "Anzahl der TNC-Kanle (Default: 10)" \
            8 80 "$TNCCHAN" 2>/tmp/$$
            if [ $? = 0 ] ; then
              read TNCCHAN < /tmp/$$
            fi;;
      TYP) sel_tnc_type;;
      DEVICE) sel_tnc_device;;
    esac
  done
}

scroll_menu()
{
  while [ 1 ] ; do
    dialog --title "Backscroll Einstellungen" \
           --backtitle "Select..." \
           --menu "Auswahl:" 18 70 11 \
           RED "1. Kanal mit reduzierten Buffern: $TNCREDBUF" \
           MH "Anzahl der Eintrge in der MH-Liste: $HEARTENTRY" \
           MONITOR "Anzahl der Monitorzeilen: $LINES_MONITOR" \
           INPUT "Anzahl der Zeilen im Vorschreibeschirm: $LINES_INPUT" \
           OUTPUT "Zeilen im Empfangsschirm: $LINES_OUTPUT" \
           R_IN "Zeilen im Vorschreibescreen (reduziert): $LINES_R_INPUT" \
           R_OUT "Zeilen im Empfangsscreen (reduziert): $LINES_R_OUTPUT" \
           BOX "Ausgabezeilen im Mailboxbereich: $LINES_BOXOUT" \
           MON "Anzahl der Monitorzeilen auf dem Connectschirm: $MON_LINES" \
           MENU "Zurueck zum Hauptmenu" \
           HELP "Eine kleine Hilfe" \
           2>/tmp/$$
    if [ ! $? = 0 ] ; then
      return
    fi
    read WHICH < /tmp/$$
    case "$WHICH" in
      HELP) dialog --textbox "./other/Readme3" 25 80;;
      MENU) return;;
      RED) dialog --inputbox "Erster Kanal mit reduzierten Rueckscrollbuffern" 8 80 "$TNCREDBUF" 2>/tmp/$$
           if [ $? = 0 ] ; then
             read TNCREDBUF < /tmp/$$
           fi;;
      MH) dialog --inputbox "Anzahl der Rufzeichen in der Heard-Liste" 8 80 "$HEARTENTRY" 2>/tmp/$$
           if [ $? = 0 ] ; then
             read HEARTENTRY < /tmp/$$
           fi;;
      MONITOR) dialog --inputbox "Anzahl der Monitorzeilen" 8 80 "$LINES_MONITOR" 2>/tmp/$$
           if [ $? = 0 ] ; then
             read LINES_MONITOR < /tmp/$$
           fi;;
      INPUT) dialog --inputbox "Eingabezeilen fuer den Vorschreibebildschirm" 8 80 "$LINES_INPUT" 2>/tmp/$$
           if [ $? = 0 ] ; then
             read LINES_INPUT < /tmp/$$
           fi;;
      OUTPUT) dialog --inputbox "Ausgabezeilen im Empfangsbereich" 8 80 "$LINES_OUTPUT" 2>/tmp/$$
           if [ $? = 0 ] ; then
             read LINES_OUTPUT < /tmp/$$
           fi;;
      R_IN) dialog --inputbox "Eingabezeilen auf den reduzierten Kanaelen" 8 80 "$LINES_R_INPUT" 2>/tmp/$$
           if [ $? = 0 ] ; then
             read LINES_R_INPUT < /tmp/$$
           fi;;
      R_OUT) dialog --inputbox "Ausgabezeilen auf den reduzierten Kanaelen" 8 80 "$LINES_R_OUTPUT" 2>/tmp/$$
           if [ $? = 0 ] ; then
             read LINES_R_OUTPUT < /tmp/$$
           fi;;
      BOX) dialog --inputbox "Anzahl der Ausgabezeilen in der Mailbox" 8 80 "$LINES_BOXOUT" 2>/tmp/$$
           if [ $? = 0 ] ; then
             read LINES_BOXOUT < /tmp/$$
           fi;;
      MON) dialog --inputbox "Anzahl der Monitorzeilen auf dem Empfangsschirm" 8 80 "$MON_LINES" 2>/tmp/$$
           if [ $? = 0 ] ; then
             read MON_LINES < /tmp/$$
           fi;;
    esac
  done
}

term_menu()
{
  while [ 1 ] ; do
    case "$COLOR" in
      0) COLDEF="monochrom";;
      1) COLDEF="Termcap [LINUX]";;
      2) COLDEF="Farbe";;
      3) COLDEF="Termcap [XTERM]";;
    esac
    if [ "$ENABLE_RESY" = "#" ] ; then
      RESY="Nein"
    else
      RESY="Ja"
    fi
    dialog --title "Globale Einstellungen" \
           --backtitle "Select..." \
           --menu "Auswahl:" 14 55 7 \
           CALL "Ihr Rufzeichen: $TERMCALL" \
           BOX "Ihr Boxrufzeichen: $BOXCALL" \
           COLOR "Farbeinstellungen: $COLOR ($COLDEF)" \
           STAT "Typ der Statuszeile: $ALTSTAT" \
           RESY "Resynclogbuch: $RESY" \
           MENU "Zurueck zum Hauptmenu" \
           HELP "Eine kleine Hilfe" \
           2>/tmp/$$
    if [ ! $? = 0 ] ; then
      return
    fi
    read WHICH < /tmp/$$
    case "$WHICH" in
      HELP) dialog --textbox "./other/Readme4" 25 80;;
      MENU) return;;
      CALL) dialog --inputbox "Terminal-Rufzeichen" 8 40 "$TERMCALL" 2>/tmp/$$
            if [ $? = 0 ] ; then
              read TERMCALL < /tmp/$$
            fi;;
      BOX) dialog --inputbox "Box-Rufzeichen" 8 40 "$BOXCALL" 2>/tmp/$$
           if [ $? = 0 ] ; then
             read BOXCALL < /tmp/$$
           fi;;
      COLOR) sel_color;;
      STAT) dialog --menu "Statuszeile" 9 40 2 \
                   TYP1 "Altmodische Statuszeile" \
                   TYP2 "Informative Statuszeile" 2>/tmp/$$
            if [ $? = 0 ] ; then
              read WHICH < /tmp/$$
              if [ "$WHICH" = "TYP1" ] ; then
                ALTSTAT=0
              else
                ALTSTAT=1
              fi
            fi;;
      RESY) dialog --menu "Resync-Logbuch" 9 40 2 \
                   ON "Logbuch einschalten" \
                   OFF "Logbuch ausschalten" 2>/tmp/$$
            if [ $? = 0 ] ; then
              read WHICH < /tmp/$$
              if [ "$WHICH" = "ON" ] ; then
                ENABLE_RESY=
              else
                ENABLE_RESY=#
              fi
            fi;;
    esac
  done
}

unix_menu()
{
  while [ 1 ] ; do
    if [ "$UNIXNEWUSER" = "1" ] ; then
      UNIXDEF="Ja"
    else
      UNIXDEF="Nein"
    fi
    dialog --title "Globale Einstellungen" \
           --backtitle "Select..." \
           --menu "Auswahl:" 13 50 6 \
           USER "Remoteuser: $REMOTEUSER" \
           CREATE "Neue User anlegen: $UNIXDEF" \
           UID "Niedrigste User-ID: $UNIXFIRSTUID" \
           GID "Gruppen-ID: $UNIXGID" \
           MENU "Zurueck zum Hauptmenu" \
           HELP "Eine kleine Hilfe" \
           2>/tmp/$$
    if [ ! $? = 0 ] ; then
      return
    fi
    read WHICH < /tmp/$$
    case "$WHICH" in
      HELP) dialog --textbox "./other/Readme5" 25 80;;
      MENU) return;;
      USER) dialog --inputbox "Unix-User fuer Runprogramme (Vorsicht mit \"root\")" 8 60 2>/tmp/$$
            if [ $? = 0 ] ; then
              read REMOTEUSER < /tmp/$$
            fi;;
      CREATE) dialog --menu "unbekannte User anlegen?" 9 45 2 \
                     JA "neue UID wird erstellt" \
                     NEIN "Remoteuser wird verwendet" 2>/tmp/$$
              if [ $? = 0 ] ; then
                read WHICH < /tmp/$$
                if [ "$WHICH" = "JA" ] ; then
                  UNIXNEWUSER=1
                else
                  UNIXNEWUSER=0
                fi
              fi;;
      UID) dialog --inputbox "Niedrigste User-ID" 8 40 2>/tmp/$$
           if [ $? = 0 ] ; then
             read UNIXFIRSTUID < /tmp/$$
           fi;;
      GID) dialog --inputbox "Gruppen-ID" 8 40 2>/tmp/$$
           if [ $? = 0 ] ; then
             read UNIXGID < /tmp/$$
           fi;;
    esac
  done
}

write_ini()
{
  echo "\
#defines if select() shall be used, normally 1, put to 0, if you are
# using old kernels (select() produces there a higher CPU-load).
use_select 1

# --------------------------------------------------------------------------

# 0 for real TNC at serial port, 1 for TFKISS on a UNIX-socket,
# 2 for TFKISS on other socket
soft_tnc $SOFTTNC

# serial port to which TNC is connected, UNIX-socket of TFKISS or
# other socket for TFKISS
device $DEVICE

# lockfile for serial port or TFKISS
tnt_lockfile $LOCKFILE

# baudrate used, only used if TNC at serial port
speed $BAUD

# timinig parameters for interface to tfkiss (soft_tnc is 1)
# 1: fixed wait (10ms) after each hostmode-packet sent to tfkiss
fixed_wait 1
# if fixed_wait == 0, number of sent characters to tfkiss after which
# tnt will wait 10ms
amount_wait 20

# --------------------------------------------------------------------------

# number of channels of TNC
tnc_channels $TNCCHAN

# first channel with reduced backscroll buffer
r_channels $TNCREDBUF

# --------------------------------------------------------------------------

# enable static huffman compression (//COMP)
tnt_comp 1

# try to uncompress frames in the monitor window
moni_decomp 1

# packet length for transmission of files
file_paclen 255

# set to 1 to disconnect all channels on startup
disc_on_start 0

# --------------------------------------------------------------------------

# UNIX-user for remote permissions
remote_user $REMOTEUSER

# If set to 1, new users will be created, if set to 0, all new users will
# be logged in as user defined by 'remote_user'.
unix_new_user $UNIXNEWUSER

# lowest user-id for creation of new users
unix_first_uid $UNIXFIRSTUID

# group-id for new users
unix_user_gid $UNIXGID

# --------------------------------------------------------------------------

# timeout packet assembly (in seconds) for SHELL/REDIR and interface
pty_timeout 2

# --------------------------------------------------------------------------

# set to 1 for request of R:-headers in boxlist read command
blist_add_plus 0

# --------------------------------------------------------------------------

# SSID of DPBox (A channel with this SSID must exist in TNC!)
#tnt_box_ssid 7

# Call and SSID of DPBox (A channel with this Call and SSID
# must exist in TNC!)
# (If this parameter is used, 'tnt_box_ssid' will be ignored)
tnt_box_call $BOXCALL

# SSID of a node connect (not yet ready)
#tnt_node_ssid 9

# Call and SSID of a node connect (not yet ready)
#tnt_node_call

# --------------------------------------------------------------------------

# main directory
tnt_dir $MAINPATH
# remote directory
remote_dir remote/
# ctext directory
ctext_dir ctext/
# directory for corrupt autobin-files
abin_dir abin/
# directory for uploads
upload_dir up/
# directory for downloads
download_dir down/
# directory for 7plus
tnt_7plus_dir 7plus/
# directory for YAPP
yapp_dir yapp/
# directory for executable programs
run_dir bin/
# home-dir for new users
unix_user_dir tntusers/
# dir for macro-texts
macrotext_dir macro/
# dir for box-broadcastfiles
tnt_bcnewmaildir bcast/newmail/
# dir for broadcastfiles
tnt_bcsavedir bcast/save/
# dir for temporary broadcastfiles
tnt_bctempdir /tmp/

# upfile
tnt_upfile tnt.up
# downfile
tnt_downfile tnt.dwn
# file containing process id
proc_file tnt.pid
# remote infofile
rem_info_file tntrem.inf
# remote helpfile
rem_help_file tntrem.hlp
# tnthelpfile
tnt_help_file tnt.hlp
# cookiefile
tnt_cookiefile $COOKIE
# namesfile
name_file_name names.tnt
# routesfile
route_file_name routes.tnt
# newsfile
news_file_name news.tnt
# connect text
tnt_ctextfile ctext.tnt
# quit text
tnt_qtextfile qtext.tnt
# logbook file
tnt_logbookfile log.tnt
# password file
tnt_pwfile pw.tnt
# sysop access files
tnt_sysfile sys.tnt
# calls with remote disabled
tnt_noremfile norem.tnt
# calls which do flexnet-linkquality-check
tnt_flchkfile flchk.tnt
# own call/SSID not allowed for xconnect
tnt_notownfile notown.tnt
# resync logfile
$ENABLE_RESY resy_log_file resy.log
# broadcast logfile
bcast_log_file bcast.log
# socket passwordfile
sock_passfile netpass.tnt
# file for keyboard macros
func_key_file fkeys.tnt
# file for extended remote commands
tnt_extremotefile extrem.tnt
# file for autostart on connect
tnt_autostartfile autostrt.tnt
# tnt sound file
tnt_soundfile sounds.tnt
# tnt tell file
tnt_tellfile tnt.telltexte

# socket for digipoint box
box_socket $BOXFRONT
# directory for newmail
newmaildir newmail/
# file holding monitored folders
autobox_dir autobox.dir
# file for boxfile endings
tnt_boxender boxender.tnt
# file for f6fbb-definitions
f6fbb_box f6fbb.box

# socket for tntnode (not yet ready)
#node_socket /usr/local/tntnode/socket

# socket for frontend
frontend_socket $FRONTEND

# --------------------------------------------------------------------------

# maximum length of input line
input_linelen 80

# set to 1 if insertmode shall be active after startup
insertmode 1

# maximum number of entries in heardlist
num_heardentries $HEARTENTRY

# number of lines for backscroll

# command-screen
lines_command 30
# monitor-screen
lines_monitor $LINES_MONITOR

# input area of connect-screens
lines_input $LINES_INPUT
# output area of connect-screens
lines_output $LINES_OUTPUT
# input area of connect-screens (reduced backscroll)
lines_r_input $LINES_R_INPUT
# output area of connect-screens (reduced backscroll)
lines_r_output $LINES_R_OUTPUT
# input/output-lines ratio on real screen (connect)
scr_divide 5
# monitor lines on connect-screens
lines_moncon $MON_LINES

# input area of mailbox-screen
lines_mbinput 10
# output area of mailbox-screen
lines_mboutput $LINES_BOXOUT
# input/output-lines ratio on real screen (mailbox)
mbscr_divide 8

# input area of extended monitor screens
lines_xmon_pre 10
# output area of extended monitor screens
lines_xmon 250
# input/output-lines ratio on real screen (extended monitor)
xmon_scr_divide 5

# --------------------------------------------------------------------------

# 0: monochrom, 1: use color attributes if TERM = 'linux' or 'conXXX',
# otherwise use monochrom attributes and termcap, 2: use color attributes,
# 3: use color attributes and termcap if TERM = 'xterm'
color $COLOR

# 0: don't use termcap, 1: use termcap
termcap 1
# 1: alternative channel status line
altstat $ALTSTAT

# --------------------------------------------------------------------------

# attributes for color

# normal characters
attc_normal 0x47
# characters in bottom statusline
attc_statline 0x3A
# characters in monitor-headers
attc_monitor 0x4A
# characters in channel statusline
attc_cstatline 0x74
# control-characters
attc_controlchar 0x07
# remote-answers
attc_remote 0x4F
# special features
attc_special 0x0F

# --------------------------------------------------------------------------

# attributes for monochrom

# normal characters
attm_normal 0x00
# characters in bottom statusline
attm_statline 0x10
# characters in monitor-headers
attm_monitor 0x10
# characters in channel statusline
attm_cstatline 0x10
# control-characters
attm_controlchar 0x10
# remote-answers and own transmitted text
attm_remote 0x10
# special features
attm_special 0x10
# channels with new data
#attm_newtext 0x10

# --------------------------------------------------------------------------

# these values must remain unchanged using LINUX

# 1: terminal puts cursor to a new line after character in last column
auto_newline 0

# 1: don't display characters 128-160
supp_hicntl 0

# --------------------------------------------------------------------------
" > $MAINPATH/tnt.ini
}

write_up()
{
  echo "\
# connect-text
ctext 0 <text> (0=Aus, 1=Ein, 2=Erlaubt //Q fuer TNC im Terminalmode)
# monitor
m uisc
# number of connects
y $TNCCHAN

my $TERMCALL
i $TERMCALL

# bell for received packets
infobell on
# umlaut off
umlaut off
# logfile append
append on
wordwrap on
wholelin on
# timestamp
k 2

# set time and date in tnc
timeset
dateset

#defaults:
tx 35                   # TX-Delay
@t3 14000
actb                    # Mailbox aktivieren
qrg 0 link              # QRG fuer ersten Kanal
tnc o 4                 # Maxframes
f 400                   # Fracktime
p 32                    # Persistance
@t2 150
w 10
r 1
x 1                     # XMITOK on
tnc n 20
tnc @i 100
tnc @d 0
remote on               # Remoterechte ein
cont on                 # Ctext ein
setacc echo normal      # Remotebefehl "//echo" freigeben
autoya on               # Automatisches YAPP-Protokoll erlauben
auto7pl on              # Automatischen 7plus-Empfang erlauben
monl $MON_LINES                  # Anzahl der Monitorzeilen auf dem Bildschirm
cookie on               # Cookies erlauben
snobox Mailbox nicht erreichbar
snoacc Befehl gesperrt

s 0
my $TERMCALL
s 9
my $BOXCALL
s 10
my $BOXCALL

# Created by tntsetup (WSPse)
" > $MAINPATH/tnt.up
}

write_smpl()
{
  echo "\
Beispiel Ctext-Datei fuer XX1XXX
TNT %v
" > $MAINPATH/ctext/xx1xxx.ctx

  echo "\
Willkommen bei %y
Dein Call: %c, dein Name: %n, dein Kanal: %k
Die Zeit: %t %d
Programm: %v
Sysop zuletzt aktiv vor %a
TNT-Laufzeit: %s

%m
%?

Neues:
%i

Cookie:
%o
" > $MAINPATH/ctext.tnt

  echo "\
Bis bald %n
Du warst %l mit mir connected...
" > $MAINPATH/qtext.tnt

  echo "\
#
# additional strings to detect the end of a mailbox-message
#
# format: 'xy string'
# x: 1 = message complete, 2 = message aborted
# y: value from 1 to 4 (up to 4 strings)
#
# one prompt of baycom-box
11 Help Dir Read Erase Check REPly Send Alter Quit
# prompt of diebox, if message read cancelled
21 (H)elp (C)heck (L)ist (R)ead (S)end (E)rase (D)ir (U)sage (Q)uit
# flexnet-reconnect
22 *** reconnected to
" > $MAINPATH/boxender.tnt

  echo "\
#
# Definition of F6FBB-Fileheaders for the MonitorCut-Feature of DP
# YOU WILL HAVE TO ALTER THESE SETTINGS!
# BUT: NEVER CHANGE THE ORDER OF THE DEFINITIONS!
# Unfortunately, the f6fbb-soft has two basic types of fileheaders
# The first one consists of 5 lines, the second (and newer one) of 7.
# Additionally those headers exist in many different lingual versions.
# Therefore you are obliged to setup this file for your personal use...
#
# If the Header Format of your local F6FBB doesn't match to these,
# please write me a msg.
#
# THE '#' STARTS A COMMENT LINE... THE FIRST FOUR UNCOMMENTED LINES
# ARE KEPT AS THE KEYWORDS, THE FOLLOWING 12 UNCOMMENTED LINES ARE
# THE MONTH IDENTIFIERS AS USED IN YOUR LOCAL F6FBB-BOX
#
#
# An old-style (and dutch language) fbb-header may look like this:
#
# Van : DC6OQ  voor IBM   @DL
# Type/Status : B$
# Datum/tijd  : 21-Mrt 13:55
# Bericht #   : 72618
# Titel       : hilfe aastor
#
# Now the definitions:
#
# first word in header (all signs until the senders callsign):
#Van :
# third word in header
#voor
#
#
# A new-style (and german language) fbb-header may look like this:
#
# Von        : DG8NBR
# Nach       : YAESU @EU
# Typ/Status : B$
# Datum      : 18-Jun 06:44
# BID/MID    : 17630BDB0BOX
# Meldung #  : 85385
# Titel      : info > FT 530
#
# Now the definitions:
#
# Denotator in first line:
#Von         :
# Denotator in second line:
#An          :
#
#
#
# A new-style (and german language) fbb-header may look like this:
#
#Von         : DG1RFG
#An          : WINGT@DL
#Typ/Status  : BF
#Datum/Zeit  : 28-Apr 08:26
#BID (MID)   : DQKBUMDB0BLO
#Msg #       : 457242
#Titel       : TNX ! WinGT und Passwort wer...
#
# Now the definitions:
#
# Denotator in first line:
Von         :
# Denotator in second line:
An          :
#
#
#
# month identifiers as used in your local f6fbb-bbs:
# (they depend on the selected language, too)
#
Jan
Feb
Mar
Apr
Mai
Jun
Jul
Aug
Sep
Okt
Nov
Dez
" > $MAINPATH/f6fbb.box

  echo "\
#
# Function-Key-File
#
# XX:text
# XX::command
#
# '*' at end sends CR after a text
#
01::send .signature
02:***end*
08::logblist
09::blist
10::xblist
" > $MAINPATH/fkeys.tnt

  echo "\
T>WS1LS Matthias
" > $MAINPATH/names.tnt

  echo "\
Nix neues...
" > $MAINPATH/news.tnt

  echo "\
# sample file for remote commands disabling
# format:
# <callsign with SSID>
#
" > $MAINPATH/norem.tnt

  echo "\
# sample password file
# all lines must use the following format:
# DIEBOX:
# <callsign> <password-type> <password-file>
# FLEXNET:
# <callsign> <password-type> <secret-number> [priv-string]
# THENET:
# <callsign> <password-type> <password-file> <flags> <priv-string>
# BAYCOM:
# <callsign> <password-type> <password-file> <flags> [priv-string]
# MD2:
# <callsign> <password-type> <password-file>
#
# DieBox DB0XXX
#
# Beispiel fuer dpbox:
DPBOX1 MD2 $MAINPATH/tntusers/dpbox1.pw
" > $MAINPATH/pw.tnt

  echo "\
Passwort fuer die Box DPBOX1
" > $MAINPATH/tntusers/dpbox1.pw

  echo "\
#Soundfile fuer TNT
#
# Wav-Player
0 /usr/bin/rplay

# Packet Empfangen (default: 0 !!!)
1 0

# Connected to
2 /usr/share/sounds/au/spacemusic.au

# Disconnected
3 /usr/share/sounds/au/gate.au

# Link Reset
4 /usr/share/sounds/au/crash.au

# Busy
5 /usr/share/sounds/wav/fuenfte.wav

# Link Failure
6 /usr/share/sounds/wav/uuaargh.wav

# Ring (//ring)
7 /usr/share/sounds/wav/churbell.wav
" > $MAINPATH/sounds.tnt

  echo "\
# sample access restriction and sysop authentification file
# format:
# <callsign> <password-file> <sysop-level>
#
" > $MAINPATH/sys.tnt

  echo "\
ctext 2 Terminal von $TERMCALL off. Leave msg and //Q
m n
y 1
" > $MAINPATH/tnt.dwn

  echo "\
# Config fuer TNTC, created by tntsetup (WSPse)
# Maindirectory
tntc_dir $MAINPATH
# socket for frontend
frontend_socket $FRONTEND
" > $MAINPATH/tntc.ini

  echo "\
Infotext noch nicht erstellt.
Editiere die Datei $MAINPATH/tntrem.inf
" > $MAINPATH/tntrem.inf

  echo "\
# Bsp fuer TNT-Telltextfile (ab TNT1.1a7)
# Die Befehle ":DA", ":WEG", ":600" und ":KLO" erlauben die Ausgabe von
# bestimmten Texten auf allen Kanaelen und das aendern des Textes fuer
# das %m Makro im Ctext.
# Neu: GND
#
# Wird als Text eine "0" angegeben, so wird die entsprechende Aktion
# nicht durchgefuehrt.
#
# Wird beim zweiten Text eine "1" angegeben, so wird das Makro geloescht.
#
# Bsp: "1 Bin wieder da" - gibt beim ":DA" Befehl den Text auf alle Kanaele aus
#      "2 0" - der %m-Text wird jedoch nicht geandert.
#      "2 1" - der %m-Text wird geloescht, es erfolgt keine Ausgabe, im
#              Ctext.
#
# 1+2 fuer DA, 3+4 fuer WEG, 5+6 fuer 600, 7+8 fuer KLO, 9+10 fuer GND
# der erste Text ist immer der Text der auf allen Kanaelen ausgegeben wird und
# der zweite der Text, der fuer das %m Makro benutzt wird.
#
# Fuer den ersten Text koennen folgende Makros benutzt werden:
# %n - Name der Gegenstation, %c - Call der Gegenstation, %k - Kanal auf dem
# die Gegenstation connected ist, %t - Aktuelle Zeit, %g/%b - Klingel (CTRL-G)
#
# Meldungen fuer DA
1 Ich bin wieder da, auf gehts!
2 Ich freue mich auf ein Connect mit Dir!
#
# Meldungen fuer WEG
3 Ich bin jetzt erstmal weg [%t].
4 Bin zur Zeit leider nicht erreichbar. Msg in BBS $BOXCALL
#
# Meldungen fuer 600
5 Bin eben telefonieren [%t].
6 Der Sysop telefoniert gerade.
#
# Meldungen fuer KLO
7 Bin eben mal auf dem WC.
8 0
#
# Meldungen fuer GND
9 %n, bin kurz im Grund%g.
10 Der Sysop ist im Hintergrund beschaeftigt.
#
#
# (C) WSPse 1998
" > $MAINPATH/tnt.telltexte

  echo "\
// Header fuer TNT-Runprogramme

#define TNT_RUN_PATH \"$MAINPATH/bin\"
/* Eincompilierter Run-Pfad, wird zB vom Runprogramm "hilfe" benoetigt */

#define TNT_MAIN_PATH \"$MAINPATH\"
/* Eincompilierter Main-Pfad, wird zB vom Logbuchprogramm benoetigt */

/* Makrodefinitionen fuer Enviromentvariablen */
#define GET_CALLSIGN (char *) getenv(\"CALLSIGN\")
#define GET_LOGNAME (char *) getenv(\"LOGNAME\")
#define GET_CALLSSID (char *) getenv(\"CALLSSID\")
" > $MAINPATH/bin/.src/tntrun.h
}

copy_sys()
{
  cp -f -i ./src/* $MAINPATH/src
  cp -f -i ./other/README $MAINPATH/src
  cp -f -i ./other/iface.doc $MAINPATH/doc
  cp -f -i ./other/tnt.doc $MAINPATH/doc
  cp -f -i ./other/termcap.tnt $MAINPATH
  cp -f -i ./other/tnt.hlp $MAINPATH
  cp -f -i ./other/tnt.hlp.eng $MAINPATH
  cp -f -i ./other/tntrem.hlp $MAINPATH
  cp -f -i ./other/tntrem.hlp.eng $MAINPATH
  cp -f -i ./other/.hilfe $MAINPATH/bin
  cp -f -i ./other/.info $MAINPATH/bin
  cp -f -i ./other/.logcall $MAINPATH/bin
  cp -f -i ./other/READMEBIN $MAINPATH/bin/.src/README
  cp -f -i ./other/hilfe.c $MAINPATH/bin/.src
  cp -f -i ./other/info.c $MAINPATH/bin/.src
  cp -f -i ./other/logcall.c $MAINPATH/bin/.src
}

do_compile()
{
  make -C $MAINPATH/src/ 2>/tmp/$$
  if [ ! $? = 0 ] ; then
    dialog --title "Error creating binary" \
           --backtitle "Maybe permissions or error while download sources?!" \
           --textbox /tmp/$$ 10 80
    return 1
  fi
  gcc $MAINPATH/bin/.src/hilfe.c -o $MAINPATH/bin/hilfe
  gcc $MAINPATH/bin/.src/info.c -o $MAINPATH/bin/info
  gcc $MAINPATH/bin/.src/logcall.c -o $MAINPATH/bin/logcall
  return 0
}

do_install()
{
  mv $MAINPATH/src/tnt $MAINPATH/tnt 2>/tmp/$$
  if [ ! $? = 0 ] ; then
    dialog --title "Error installing main" \
           --backtitle "Error while compiling?" \
           --textbox /tmp/$$ 10 80
    return 1
  fi
  mv $MAINPATH/src/tntc $MAINPATH/tntc
}

create_scripts()
{
  dialog --title "Scriptcreation" \
         --backtitle "Select" \
         --yesno "Startscripte fuer TNT erstellen?" 5 45

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

  echo "\
$MAINPATH/tnt -i $MAINPATH/tnt.ini
" > /usr/local/bin/STARTTNT

  echo "\
$MAINPATH/tnt -d -i $MAINPATH/tnt.ini &
" > /usr/local/bin/STARTTNTD

  echo "\
$MAINPATH/tntc -i $MAINPATH/tntc.ini
" > /usr/local/bin/STARTTNTC

  chmod -c a+x /usr/local/bin/STARTTNT /usr/local/bin/STARTTNTD \
               /usr/local/bin/STARTTNTC

  dialog --title "Scripts" \
         --backtitle "Info" \
         --msgbox "Scripte sind fertig\nStarten Sie TNT mit dem Befehl \"STARTTNT\"\n\nUm TNT als Hintergrundprozess zu starten benutzen Sie\nden Befehl \"STARTTNTD\",\ndann kann mit \"STARTTNTC\" die Konsole gestartet werden.\nSie koennen die Namen der Befehle im\nVerzeichnis \"/usr/local/bin/\" veraendern." \
         13 60
}

create_tnt()
{
  dialog --title "Achtung!" \
         --backtitle "Select..." \
         --yesno "       Sind Sie sicher?\nExistiert der Pfad \"$MAINPATH\" bereits, so koennen\nhier wichtige Daten verloren gehen.\nDieses Setup fuehrt eine NEUINSTALLATION von TNT durch.\nBereits vorhandene Konfigurationen werden verloren gehen!\n\nBesttigen Sie nur, wenn Sie absolut sicher sind!" 11 70
  if [ ! $? = 0 ] ; then
    return
  fi

  dialog --title "Creation" \
         --backtitle "Wait..." \
         --infobox "Erstelle Verzeichnisse" 3 40

  mkdir -p $MAINPATH 2>/tmp/$$   # Mainpath erstellen
  if [ ! $? = 0 ] ; then
    dialog --title "Error creating \"$MAINPATH\"." \
           --backtitle "Check permissions!" \
           --textbox /tmp/$$ 10 80
    return
  fi
  mkdir -p $MAINPATH/7plus 2>/tmp/$$
  if [ ! $? = 0 ] ; then
    dialog --title "Error creating \"$MAINPATH/7plus\"." \
           --backtitle "Check permissions!" \
           --textbox /tmp/$$ 10 80
    return
  fi
  mkdir -p $MAINPATH/abin    # Create Subdirs
  mkdir -p $MAINPATH/bcast/newmail
  mkdir -p $MAINPATH/bcast/save
  mkdir -p $MAINPATH/bin/.src
  mkdir -p $MAINPATH/ctext
  mkdir -p $MAINPATH/doc
  mkdir -p $MAINPATH/down
  mkdir -p $MAINPATH/macro
  mkdir -p $MAINPATH/newmail
  mkdir -p $MAINPATH/remote
  mkdir -p $MAINPATH/src
  mkdir -p $MAINPATH/tntusers
  mkdir -p $MAINPATH/up
  mkdir -p $MAINPATH/yapp

  dialog --title "Creation" \
         --backtitle "Wait..." \
         --infobox "Erstelle Initdateien" 3 40

  write_ini             # Hauptini-Datei
  write_up              # TNC-Ini Datei
  write_smpl            # Beispiel-Dateien

  dialog --title "Copy" \
         --backtitle "Wait..." \
         --infobox "Kopiere Source- & Systemdateien" 3 60

  copy_sys

  dialog --title "Compile" \
         --backtitle "Wait..." \
         --infobox "Erstelle Hauptprogramm" 3 40

  do_compile
  if [ ! $? = 0 ] ; then
    return
  fi

  dialog --title "Install" \
         --backtitle "Wait..." \
         --infobox "Installiere Hauptprogramm" 3 40

  do_install

  create_scripts

  dialog --title "Installation komplett" \
         --backtitle "WSPse 1998/99 - wsp@gmx.de" \
         --msgbox "Die Installation ist abgeschlossen\n\nBei Problemen oder Fragen Mail an:\nwsp@gmx.de - Matthias Hensler\n\nViel Spa mit TNT\nWSPse 1998/99" 13 60

  exit 0
}

# ---MAIN-----------------------------------------------------------------

dialog --title "TNT-SETUP" \
       --backtitle "(C) WSPse 1998 - Created by Matthias Hensler - eMail: wsp@gmx.de" \
       --msgbox "        TNT-Setup V1\n\nInstalltionsprogramm fuer das\nPacket Terminal unter Linux\nTNT created by Mark Wahl\nand Matthias Hensler\n\nTNT-Setup created\nby Matthias Hensler" 13 33

# ---Mainmenu---

  while [ 1 ] ; do
    dialog --title "Mainmenu" \
           --backtitle "Treffen Sie Ihre Auswahl" \
           --menu "Whlen Sie:" 15 70 8 \
           GLOBAL "Globale Einstellungen (Pfade, etc)" \
           TNC "TNC-Einstellungen" \
           BACKSCROLL "Rueckscrollbuffer" \
           TERM "Terminal Einstellungen" \
           UNIX "Unix Benutzer Einstellungen" \
           DOC "Dokumentationen anzeigen" \
           INSTALL "Installation starten" \
           EXIT "Programm beenden" \
           2>/tmp/$$
    if [ ! $? = 0 ] ; then
      exit
    fi

    read WHICH < /tmp/$$
    case "$WHICH" in
      EXIT) exit;;
      DOC) show_docs;;
      INSTALL) create_tnt;;
      GLOBAL) global_menu;;
      BACKSCROLL) scroll_menu;;
      TNC) tnc_menu;;
      TERM) term_menu;;
      UNIX) unix_menu;;
    esac
  done

