#!/bin/bash

# This program is part of the tbackup package,
# (c) 1993,1994,1995,1998 Koen Holtman.
#
# The tbackup package is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation.
# No warranty. See the GNU General Public License for more details.


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

source tinit

#get method names and parameters

source getrespars

source makelogtty

source handlepars

echo
echo "Restore in progress..."
echo

# make named pipe

mkfifo -m 700 archive

# execute restore.

#Remove possible update scripts left in $packhome to prevent them from
#being mistaken from scripts uppacked from the archive.
#XXX source rmupdates

#Delete update scripts that may be unpacked on exit or abort.
#XXX rmupdates="rm -f $packh/TBACKUP%.gz $packh/TBACKUP%.mgz"

# readmethod is supposed to interact with the user.

# unpackmethod should start 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 $unpackmethod\.ux
cd /tmp/tbup
source $readmethod\.rx

# wait for `archive' to disappear.
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/$unpackmethod\.uf ]; then
 cd /tmp/tbup
 source $unpackmethod\.uf
fi

#process possible update files
#XXX source update

source texit
