/[fai]/trunk/scripts/ftar
ViewVC logotype

Contents of /trunk/scripts/ftar

Parent Directory Parent Directory | Revision Log Revision Log


Revision 679 - (show annotations) (download)
Wed Jul 11 13:11:49 2001 UTC (11 years, 11 months ago) by lange
File size: 4096 byte(s)
order of classes now correct
1 #! /bin/sh
2
3 # $Id$
4 #*********************************************************************
5 #
6 # ftar -- extract tar files using FAI classes
7 #
8 # This script is part of FAI (Fully Automatic Installation)
9 # Copyright (C) 2001 Thomas Lange, lange@informatik.uni-koeln.de
10 # Universitaet zu Koeln
11 #
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.
17 #
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.
22 #
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 #*********************************************************************
29
30 version="Version 1.4 11-july-2001"
31
32 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
33 die() {
34 echo "ftar died: $1"
35 exit 99
36 }
37 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
38 extract() {
39
40 local file=$1
41 local catname=$2
42
43 echo "ftar: extracting $file to $target/$dir"
44 $catname $file | tar -C $target/$dir $vflag -xf -
45 tardone=1
46 # if option -1 is set, only one class will be used
47 $single && exit 0
48 }
49 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
50 usage() {
51
52 cat <<EOF
53 ftar, extract tar files using classes. $version
54
55 Copyright (C) 2001 by Thomas Lange
56
57 Usage: ftar [OPTION] ... SOURCE
58
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.
68
69 Report bugs to <lange@informatik.uni-koeln.de>.
70 EOF
71 exit 0
72 }
73 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
74
75 source=$FAI_FILES
76 target=$FAI_ROOT
77 deletefiles=0
78 removedir=0
79 tardone=0
80
81 while getopts 1hDdrvs:t:c: opt ; do
82 case "$opt" in
83 d) deletefiles=1 ;;
84 D) debug=1 ;;
85 r) removedir=1 ;;
86 # v) verbose=1 ;;
87 1) single=1 ;;
88 s) source=$OPTARG ;;
89 t) target=$OPTARG ;;
90 c) classes=$OPTARG ;;
91 h) usage ;;
92 esac
93 done
94 shift $(($OPTIND - 1))
95
96 [ "$1" ] || usage
97 [ -f /tmp/FAI_CLASSES ] && classes=`cat /tmp/FAI_CLASSES`
98 # last class has highest priority
99
100 # reverse order of classes
101 for class in $classes; do
102 revclasses="$class $revclasses"
103 done
104
105 [ "$debug" ] && vflag="-v"
106 [ "$debug" ] && echo "ftar: classes : $revclasses"
107 [ -z "$source" ] && die "Source directory undefined."
108 [ -z "$target" ] && die "Target directory undefined."
109
110 # currently only one directory is used
111 dir=$1
112 fpath=$source/$dir
113 [ -d $fpath ] || die "no directory $fpath"
114
115 [ $deletefiles -eq 1 ] && cd $target/$dir ; rm -f .* * 2>/dev/null
116 [ $removedir -eq 1 ] && cd $target/$dir ; rm -rf .* * 2>/dev/null
117
118 for c in $revclasses ; do
119 # what if a directory exists, which is equal to the hostname or a classname ?
120 # [ -f $fpath/$c ] && extract $fpath/$c cat
121 [ -f $fpath/$c.tar ] && extract $fpath/$c.tar cat
122 [ -f $fpath/$c.tar.gz ] && extract $fpath/$c.tar.gz zcat
123 [ -f $fpath/$c.tar.bz2 ] && extract $fpath/$c.tar.bz2 bzcat
124 done
125
126 [ $tardone -eq 0 ] && echo "No matching class found in $fpath"
127 exit 0

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.5