Re: Progressbar for extracting Basefiles

2023-01-18 Diskussionsfäden Karsten Nordsiek

Please find included the both files I have changed.

Hint: you need to install pv in the nfsroot

Am 18.01.23 um 15:19 schrieb Karsten Nordsiek:

Yes that's working.

I have added the -f Option
Now it works as fine as it should

thx for the hint.

Regards


Karsten Nordsiek


Am 18.01.23 um 14:34 sch
rieb Thomas Lange:
On Wed, 18 Jan 2023 12:28:26 +0100, Karsten Nordsiek 
 said:
 >     -1   Use only first tar file matching 
class name.

 >     -c class[class]  Define classes (space separated).
Hmmm, it's hard to see what you have changed. A diff or git diff would
be much better to understand.

My first guess is to add -f to the pv call.

   -f, --force  output even if standard error is not a 
terminal


Inside FAI we redirect the output to a pipe which also does tee into a
file. Or you may try to force the output (does pv use stderr?) to
/dev/ttyN.
#! /bin/bash

#*
#
# ftar -- extract tar files using FAI classes
#
# This script is part of FAI (Fully Automatic Installation)
# Copyright (C) 2001-2017 Thomas Lange, la...@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

if [ $progress -eq 1 ]; then

echo "ftar: extracting $file to $target/$dir" | tr -s '/'
$catname $file | pv -f -s $(du -sb $file | awk '{print $1}') | tar 
$xattrs --numeric-owner -C $target/$dir $vflag -xf -
else
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
fi

}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
usage() {

cat <#! /bin/bash

#*
#
# subroutines -- useful subroutines for FAI
#
# This script is part of FAI (Fully Automatic Installation)
# (c) 2000-2021 by Thomas Lange, la...@informatik.uni-koeln.de
# Universitaet zu Koeln
# (c) 2001-2005 by Henning Glawe, gla...@physik.fu-berlin.de
# Freie Universitaet Berlin
#
#*
# 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
#*

# source this file, then you have these function available in the shell

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
die() {

# echo comment and exit

Re: Progressbar for extracting Basefiles

2023-01-18 Diskussionsfäden Karsten Nordsiek

Yes that's working.

I have added the -f Option
Now it works as fine as it should

thx for the hint.

Regards


Karsten Nordsiek


Am 18.01.23 um 14:34 sch
rieb Thomas Lange:

On Wed, 18 Jan 2023 12:28:26 +0100, Karsten Nordsiek  
said:

 >     -1   Use only first tar file matching class name.
 >     -c class[class]  Define classes (space separated).
Hmmm, it's hard to see what you have changed. A diff or git diff would
be much better to understand.

My first guess is to add -f to the pv call.

   -f, --force  output even if standard error is not a terminal

Inside FAI we redirect the output to a pipe which also does tee into a
file. Or you may try to force the output (does pv use stderr?) to
/dev/ttyN.



Re: Progressbar for extracting Basefiles

2023-01-18 Diskussionsfäden Thomas Lange
> On Wed, 18 Jan 2023 12:28:26 +0100, Karsten Nordsiek 
>  said:

>     -1   Use only first tar file matching class name.
>     -c class[class]  Define classes (space separated).
Hmmm, it's hard to see what you have changed. A diff or git diff would
be much better to understand.

My first guess is to add -f to the pv call.

  -f, --force  output even if standard error is not a terminal

Inside FAI we redirect the output to a pipe which also does tee into a
file. Or you may try to force the output (does pv use stderr?) to
/dev/ttyN.

-- 
viele Grüße Thomas


Progressbar for extracting Basefiles

2023-01-18 Diskussionsfäden Karsten Nordsiek

Hello to all,

a small problem and I hope you can help me

I want to show a progressbar while extracting the basefile so I have 
done some changes as follows:


changes in /srv/fai/nfsroot/usr/sbin/ftar

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.
   -p   Show progress indicator
   -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.

(Option p added to the Optionlist)

declare Variables:

source=$FAI/files
target=$FAI_ROOT
deletefiles=0
removedir=0
tardone=0
single=0
ignore=0
progress=0

(added progress=0)

Changes in Section extract()

    if [ $progress -eq 1 ]; then

    echo "ftar: extracting $file to $target/$dir" | tr -s '/'
    $catname $file | pv -s $(du -sb $file | awk '{print $1}') | tar 
$xattrs --numeric-owner -C $target/$dir $vflag -xf -

    else
    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
    fi

Changes in File /srv/fai/nfsroot/usr/lib/fai/subroutines

changes in Section task_extrabse()

fetch-basefile
    # remember, ftar extracts into $FAI_ROOT by default, so / means 
$FAI_ROOT/

    # copy the base file class based if it exists
    [ -d $FAI/basefiles ] && ftar -1vp -s $FAI/basefiles /
    if [ $? -ne 0 ]; then
    if [ $do_init_tasks -eq 1 ]; then
    ftar -p -1v -c base -s /var/tmp /
    else
   [ -d $NFSROOT/var/tmp ] &&
   ftar -p -1v -c base -s $NFSROOT/var/tmp /
    fi

    # if no base file was extracted, call debootstrap
    if [ ! -d $FAI_ROOT/etc ]; then
    echo "No base file found. Calling debootstrap."
    [ -z "$FAI_DEBOOTSTRAP" ] && die "\$FAI_DEBOOTSTRAP 
undefined. Aborting"

    call_debootstrap $FAI_DEBOOTSTRAP
    task_error 801 $?
        fi
    fi


The file has been extracted but there is no output in Stdout (Terminal)

Let me know if you need more Informations
Greetings


Karsten Nordsiek