Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Seitosh
csback
Commits
5ba9fd7c
Commit
5ba9fd7c
authored
Jun 13, 2016
by
thomas.forbriger
Browse files
[FEATURE] (util): implement csbucomparecsfiles.sh
parent
43f5f805
Changes
2
Hide whitespace changes
Inline
Side-by-side
util/README
View file @
5ba9fd7c
...
...
@@ -21,7 +21,6 @@ csbulistcsfiles.sh
csbucomparecsfiles.sh
Check downstream data archives for checksum files. Report missing checksum
files and checksum files differing from the upstream file.
--- not yet implemented ---
csbucscheck.sh
Recurse into a read-only subdirectory tree and verify checksums.
...
...
util/csbucomparecsfiles.sh
View file @
5ba9fd7c
...
...
@@ -11,18 +11,26 @@
#
# ============================================================================
#
VERSION
=
"
06
/06/2016 V1.0"
VERSION
=
"
13
/06/2016 V1.0"
# name of csback checksum files
CHECKSUMFILE
=
"checksumfile.cs"
# current working directory
HERE
=
$(
pwd
)
# base name of temporary directory used for intermediate lists and for report
# files
TMPBASE
=
$HERE
/report
# ============================================================================
# usage function
function
usage
{
cat
<<
HERE
This is <csbucomparecsfiles.sh>
version:
$VERSION
usage: csbucomparecsfiles.sh [-v] [-d]
dir [dir ...]
usage: csbucomparecsfiles.sh [-v] [-d]
[-r dir] basedir downdir
or: csbucomparecsfiles.sh -h
Check downstream data archives for checksum files. Report missing checksum
...
...
@@ -30,6 +38,8 @@ files and checksum files differing from the upstream file.
HERE
}
# ----------------------------------------------------------------------------
# usage function
function
longusage
{
cat
<<
HERE
...
...
@@ -37,31 +47,39 @@ cat << HERE
-h print detailed usage information
-v be verbose
-d print debug output
-r dir base directory for report
if not provided, a subdirectory in the current directory will
be created; the default is
$TMPBASE
dir one or more directories to be checked recursively
basedir base directory of data collection
downdir base directory of downstream data collection
The name of checksumfiles to be searched for is:
$CHECKSUMFILE
HERE
}
# ============================================================================
verbose
=
0
debug
=
0
# fetch commandline arguments
while
getopts
'hvd'
Option
;
while
getopts
'hvd
r:
'
Option
;
do
case
${
Option
}
in
h
)
hflag
=
1
usage
;
longusage
;
exit
0
;;
v
)
verbose
=
1
;;
d
)
debug
=
1
;;
r
)
TMPBASE
=
"
$OPTARG
"
;;
*
)
echo
-e
"ERROR: Unimplemented option chosen.
\n
"
usage
;
exit
2
;;
esac
done
shift
$((${
OPTIND
}
-
1
))
MINPARAMS
=
1
MINPARAMS
=
2
# check number of commandline arguments
if
[
$#
-lt
${
MINPARAMS
}
]
then
...
...
@@ -69,5 +87,90 @@ then
exit
2
fi
TMPBASEDIR
=
$(
dirname
$TMPBASE
)
if
test
!
\(
-d
$(
dirname
$TMPBASE
)
-a
-w
$(
dirname
$TMPBASE
)
\)
then
echo
report output base directory
$TMPBASEDIR
is not a directory
echo
or is not writable
exit
2
fi
TMPDIR
=
$TMPBASE
/report_
$(
basename
$0
.sh
)
_
$(
basename
$DATADIR
)
_
$$
mkdir
-p
$TMPDIR
if
test
!
\(
-d
$TMPDIR
-a
-w
$TMPDIR
\)
then
echo
report output directory
$TMPDIR
is not a directory
echo
or is not writable
exit
2
fi
DATADIR
=
$1
DOWNDIR
=
$2
if
test
!
\(
-d
$DATADIR
-a
-r
$DATADIR
\)
then
echo
data directory
$DATADIR
does not exits or is not readable
exit
2
fi
# ============================================================================
# action
# ======
REPORT
=
$TMPDIR
/report
MISSING
=
$TMPDIR
/missing
DEVIANT
=
$TMPDIR
/deviant
touch
$REPORT
$MISSING
$DEVIANT
# report
tee
-a
$REPORT
<<
HERE
-----------------------------------------------------------------------
$0
version:
$VERSION
started:
$(
date
)
check downstream data directory
$DOWNDIR
against data directory tree at
$DATADIR
-----------------------------------------------------------------------
HERE
cd
$DATADIR
nc
=
0
for
FILE
in
$(
find
.
-name
$CHECKSUMFILE
|
sort
)
do
echo
check
$FILE
|
tee
-a
$REPORT
DOWNFILE
=
$DOWNDIR
/
$FILE
if
test
-r
$DOWNFILE
then
if
/usr/bin/cmp
-s
$FILE
$DOWNFILE
then
echo
verified:
$DOWNFILE
|
tee
-a
$REPORT
else
echo
$DOWNFILE
>>
$DEVIANT
echo
differs:
$DOWNFILE
|
tee
-a
$REPORT
LOGFILE
=
$TMPDIR
/
$(
echo
$FILE
|
tr
'/'
'_'
)
diff
$FILE
$DOWNFILE
>
$LOGFILE
fi
else
echo
$DOWNFILE
>>
$MISSING
echo
missing:
$DOWNFILE
|
tee
-a
$REPORT
fi
nc
=
$((
nc+1
))
done
# ----------------------------------------------------------------------------
tee
-a
$REPORT
<<
HERE
$nc
files were checked
$(
cat
$MISSING
|
wc
-l
)
are missing in downstream data archive
$(
cat
$DEVIANT
|
wc
-l
)
files in downstream archive do not match
a report is provided in
$TMPDIR
HERE
# ----- END OF csbucomparecsfiles.sh -----
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment