#!/bin/bash
#
# This program is part of the three backup (tbackup) package,
# (c) 1993,1994 Koen Holtman.


export bupbin=/usr/lib/tbackup/bin
export bupdir=/usr/lib/tbackup
export PATH=$bupbin\:$PATH
export ttytitle=list

source tinit

#get method names and parameters

source getlistpars

source makelogtty

#exit if pars argument given.
if [ "$only_params" = "y" ]; then
 cp /tmp/tbup/allpars /etc/tbackup/allpars
 echo
 echo The supplied parameters are recorded in the file /etc/tbackup/allpars.
 echo
 echo Cleaning up....
 cd /tmp
 rm -rf /tmp/tbup
 eval $rmbulkdir
 exit 0
fi


echo
echo "List in progress..."
echo

# make named pipe

mkfifo -m 700 archive

# execute restore.

# readmethod is supposed to interact with the user.

# listmethod should start be a background task that deletes the pipe
# `archive' when finished.
# This method should do no i/o on the user tty.

cd /tmp/tbup
source $listmethod\.lx
cd /tmp/tbup
source $readmethod\.rx

# wait for `archive' to dissappear.
while [ -e archive ]; do sleep 1; done

#finalise methods
#what such methods would want to do is beyond me, we put it in for symmetry.

if [ -f $bupbin/$readmethod\.rf ]; then
 cd /tmp/tbup
 source $readmethod\.rf
fi
if [ -f $bupbin/$listmethod\.lf ]; then
 cd /tmp/tbup
 source $listmethod\.lf
fi


# if making one, stop flowpause etc that take care of index file.
if [ $makeindexfile = y ]; then
  kill $holdfifopid
fi

echo >logttydev
echo "---------List completed---------" >logttydev

echo "Cleaning up..."
cd /tmp

#sleep 1 added to fix race condition (?) in the kernel.
sleep 1

rm -rf /tmp/tbup
eval $rmbulkdir
eval $resetfloppy
sync

echo
echo "List completed."
