/usr/sbin/ftar is in fai-client 5.3.6ubuntu1.
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 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | #! /bin/bash
#*********************************************************************
#
# ftar -- extract tar files using FAI classes
#
# This script is part of FAI (Fully Automatic Installation)
# Copyright (C) 2001-2016 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() {
local e=$1 # first parameter is the exit code
shift
echo "ftar: $@" >&2 # print error message
exit $e
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
extract() {
local file=$1
local catname=$2
if [ $deletefiles -eq 1 ] ; then
cd $target/$dir && rm -f .* * 2>/dev/null
deletefiles=0
fi
if [ $removedir -eq 1 ]; then
cd $target/$dir || die 4 "ERROR: cd to $target/$dir failed. Aborting."
[ $PWD = "/" ] && die 3 "WARNING: Will not do recursive removal of directory /"
rm -rf .* * 2>/dev/null
removedir=0
fi
echo "ftar: extracting $file to $target/$dir" | tr -s '/'
$catname $file | tar $xattrs --numeric-owner -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-2016 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
ignore=0
if [ -n "$classes" ]; then
[ -f $LOGDIR/FAI_CLASSES ] && classes=$(< $LOGDIR/FAI_CLASSES)
fi
while getopts 1hDdrvs:t:c:i opt ; do
case "$opt" in
d) deletefiles=1 ;;
D) debug=1 ;;
i) ignore=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
# check if tar has xattrs support
tar --xattrs -cf /dev/null /dev/null 2>/dev/null 1>/dev/null
if [ $? -eq 0 ]; then
xattrs="--xattrs --xattrs-include=*.* --selinux --acl"
else
xattrs=
fi
# 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 1 "Source directory undefined."
[ -z "$target" ] && die 1 "Target directory undefined."
# currently only one directory is used
dir=$1
fpath=$source/$dir
[ -d $fpath ] || die 1 "No directory $fpath"
for c in $revclasses ; do
# what if a directory exists which is equal to the hostname or a classname?
[ -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
if [ $ignore -eq 1 ]; then
echo "ftar: No matching class found in $fpath"
exit 0
else
die 1 "No matching class found in $fpath"
fi
fi
exit 0
|