4
#*********************************************************************
6
# ftar -- extract tar files using FAI classes
8
# This script is part of FAI (Fully Automatic Installation)
9
# Copyright (C) 2001-2003 Thomas Lange, lange@informatik.uni-koeln.de
10
# Universitaet zu Koeln
12
#*********************************************************************
13
# This program is free software; you can redistribute it and/or modify
14
# it under the terms of the GNU General Public License as published by
15
# the Free Software Foundation; either version 2 of the License, or
16
# (at your option) any later version.
18
# This program is distributed in the hope that it will be useful, but
19
# WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
# General Public License for more details.
23
# A copy of the GNU General Public License is available as
24
# '/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
25
# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You
26
# can also obtain it by writing to the Free Software Foundation, Inc.,
27
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
#*********************************************************************
30
version="Version 1.5.3, 24-dec-2004"
32
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
34
echo "ftar died with error: $1"
37
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
43
echo "ftar: extracting $file to $target/$dir"
44
$catname $file | tar -C $target/$dir $vflag -xf -
46
# if option -1 is set, only one class will be used
49
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
53
ftar, extract tar files using classes. $version
55
Copyright (C) 2001-2003 by Thomas Lange
57
Usage: ftar [OPTION] ... SOURCE
59
-1 Use only first tar file matching class name.
60
-c class[class] Define classes (space separated).
61
-d Delete all files in target before extracting.
62
-D Create debug output.
63
-h Show summary of options.
64
-r Recursively remove files in target before extracting.
65
-s source_dir Look for source files relative to source_dir.
66
-t target_dir Extract files relativ to target_dir.
67
-v Be verbose. Not yet used.
69
Report bugs to <lange@informatik.uni-koeln.de>.
73
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
81
while getopts 1hDdrvs:t:c: opt ; do
94
shift $(($OPTIND - 1))
97
[ -f $ENV{LOGDIR}/FAI_CLASSES ] && classes=`cat $ENV{LOGDIR}/FAI_CLASSES`
98
# last class has highest priority
100
# reverse order of classes
101
for class in $classes; do
102
revclasses="$class $revclasses"
105
[ "$debug" ] && vflag="-v"
106
[ "$debug" ] && echo "ftar: classes : $revclasses"
107
[ -z "$source" ] && die "Source directory undefined."
108
[ -z "$target" ] && die "Target directory undefined."
110
# currently only one directory is used
113
[ -d $fpath ] || die "No directory $fpath"
115
[ $deletefiles -eq 1 ] && cd $target/$dir && rm -f .* * 2>/dev/null
117
if [ $removedir -eq 1 ]; then
119
if [ $PWD = "/" ]; then
120
echo "ftar WARNING: Will not do recursive removal of directory /"
122
rm -rf .* * 2>/dev/null
126
for c in $revclasses ; do
127
# what if a directory exists which is equal to the hostname or a classname?
128
# [ -f $fpath/$c ] && extract $fpath/$c cat
129
[ -f $fpath/$c.tar ] && extract $fpath/$c.tar cat
130
[ -f $fpath/$c.tar.gz ] && extract $fpath/$c.tar.gz zcat
131
[ -f $fpath/$c.tar.bz2 ] && extract $fpath/$c.tar.bz2 bzcat
134
[ $tardone -eq 0 ] && echo "ftar: No matching class found in $fpath"