/usr/sbin/ftar is in fai-client 3.4.8ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | #! /bin/bash
# $Id$
#*********************************************************************
#
# ftar -- extract tar files using FAI classes
#
# This script is part of FAI (Fully Automatic Installation)
# Copyright (C) 2001-2010 Thomas Lange, lange@informatik.uni-koeln.de
# Universitaet zu Koeln
#
#*********************************************************************
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# A copy of the GNU General Public License is available as
# '/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You
# can also obtain it by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#*********************************************************************
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
die() {
echo "ftar died with error: $1"
exit 99
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
extract() {
local file=$1
local catname=$2
echo "ftar: extracting $file to $target/$dir"
$catname $file | tar -C $target/$dir $vflag -xf -
tardone=1
# if option -1 is set, only one class will be used
[ $single -eq 1 ] && exit 0
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
usage() {
cat <<EOF
ftar, extract tar files using classes.
Copyright (C) 2001-2010 by Thomas Lange
Usage: ftar [OPTION] ... SOURCE
-1 Use only first tar file matching class name.
-c class[class] Define classes (space separated).
-d Delete all files in target before extracting.
-D Create debug output.
-h Show summary of options.
-r Recursively remove files in target before extracting.
-s source_dir Look for source files relative to source_dir.
-t target_dir Extract files relativ to target_dir.
-v Be verbose. Not yet used.
EOF
exit 0
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
source=$FAI/files
target=$FAI_ROOT
deletefiles=0
removedir=0
tardone=0
single=0
while getopts 1hDdrvs:t:c: opt ; do
case "$opt" in
d) deletefiles=1 ;;
D) debug=1 ;;
r) removedir=1 ;;
# v) verbose=1 ;;
1) single=1 ;;
s) source=$OPTARG ;;
t) target=$OPTARG ;;
c) classes=$OPTARG ;;
h) usage ;;
esac
done
shift $(($OPTIND - 1))
[ "$1" ] || usage
[ -f $ENV{LOGDIR}/FAI_CLASSES ] && classes=$(< $ENV{LOGDIR}/FAI_CLASSES)
# last class has highest priority
# reverse order of classes
for class in $classes; do
revclasses="$class $revclasses"
done
[ "$debug" ] && vflag="-v"
[ "$debug" ] && echo "ftar: classes : $revclasses"
[ -z "$source" ] && die "Source directory undefined."
[ -z "$target" ] && die "Target directory undefined."
# currently only one directory is used
dir=$1
fpath=$source/$dir
[ -d $fpath ] || die "No directory $fpath"
[ $deletefiles -eq 1 ] && cd $target/$dir && rm -f .* * 2>/dev/null
if [ $removedir -eq 1 ]; then
cd $target/$dir
if [ $PWD = "/" ]; then
echo "ftar WARNING: Will not do recursive removal of directory /"
else
rm -rf .* * 2>/dev/null
fi
fi
for c in $revclasses ; do
# what if a directory exists which is equal to the hostname or a classname?
# [ -f $fpath/$c ] && extract $fpath/$c cat
[ -f $fpath/$c.tgz ] && extract $fpath/$c.tgz zcat
[ -f $fpath/$c.tar ] && extract $fpath/$c.tar cat
[ -f $fpath/$c.tar.gz ] && extract $fpath/$c.tar.gz zcat
[ -f $fpath/$c.tar.bz2 ] && extract $fpath/$c.tar.bz2 bzcat
[ -f $fpath/$c.tar.xz ] && extract $fpath/$c.tar.xz xzcat
[ -f $fpath/$c.txz ] && extract $fpath/$c.txz xzcat
done
if [ $tardone -eq 0 ]; then
echo "ftar: No matching class found in $fpath"
exit 1
else
exit 0
fi
|