File: dar_par_test.duc

package info (click to toggle)
dar 2.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,068 kB
  • sloc: cpp: 86,310; sh: 6,996; ansic: 895; makefile: 502; python: 242; csh: 115; perl: 43; sed: 16
file content (49 lines) | stat: -rwxr-xr-x 1,264 bytes parent folder | download | duplicates (9)
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
#!/bin/sh

###
#
# this script is to be launched on dar command line when testing an archive with -s option (slicing)
# you need to run this script from dar, adding the following argument on command-line
#
#     -E "dar_par_test.duc %p %b %n %e %c"
#
###
#
# if you prefer you can also add the line above in your the $HOME/.darrc file
# under the test: conditional statement (see dar man page)
#
###
#
# usage par_script slice.basename slice.number extension
# generates a Parchive redundancy file from the slice file
#
###

if [ "$1" = "" -a "$2" = "" -a "$3" = "" -a "$4" = "" -a "$5" = "" ]; then
  echo "usage: $0 <path> <basename> <slice number> <extension> <context>"
  echo "$0 tests and if necessary repairs the given slice using Parchive redundancy  files"
  exit 1
fi

if [ "$3" = "0" ]; then
  exit 0
fi

PAR=par2
SLICE="$1/$2.$3.$4"

if [ ! -r $SLICE ]; then
   echo "`basename $0`: Cannot find or read the slice $SLICE, skiping, Dar will ask user for it"
   exit 0;
fi

echo "$PAR verification slice $SLICE..."
if ! $PAR v "$SLICE" ; then
  echo "trying to repair the slice..."
  if ! $PAR r "$SLICE" ; then
     echo "PAR repairation failed. (read-only filesystem ?)"
     exit 1
  fi
  echo "verifying after reparation..."
  exec $PAR v "$SLICE"
fi