Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
osak
tools
Commits
6a23baac
Commit
6a23baac
authored
Oct 04, 2018
by
Julian Rother
Browse files
Upload check_dd_total
parent
c860b593
Changes
1
Hide whitespace changes
Inline
Side-by-side
Check/check_dd_total
0 → 100644
View file @
6a23baac
#!/bin/bash
usage
=
"
$(
basename
"
$0
"
)
[-v] [-q] src des -- verifies per sha256sum, that src was correctly written to des
$(
basename
"
$0
"
)
-h
where:
-v verbose: prints the sha256sums
-q quite: suppresses the output of the result,
the return-Code remains as reponse
-h prints this help message"
quite
=
false
;
verbose
=
false
;
printHelp
=
false
;
for
opt
in
"
$@
"
do
case
$opt
in
-v
)
verbose
=
true
;
shift
1
;;
-q
)
quite
=
true
;
shift
1
;;
-h
)
printHelp
=
true
;
shift
1
;;
-?
)
printHelp
=
true
;
shift
1
;;
esac
done
if
[
"
$printHelp
"
=
true
]
||
[
$#
-ne
2
]
then
echo
"
$usage
"
;
exit
-1
;
fi
src
=
$1
;
des
=
$2
;
lengthSrc
=
$((
$(
stat
-c
'%s'
$src
)
/
4096
))
;
# length of the source (in 4096kB)
if
[
"
$verbose
"
=
true
]
then
echo
"length of the source (in 4096kB):
$lengthSrc
"
fi
sha256sumSrc
=
$(
dd
if
=
$src
bs
=
4096
count
=
$lengthSrc
status
=
none |
sha256sum
)
if
[
"
$verbose
"
=
true
]
then
echo
"sha256sum of the source:
$sha256sumSrc
"
fi
sha256sumDes
=
$(
dd
if
=
$des
bs
=
4096
count
=
$lengthSrc
status
=
none |
sha256sum
)
if
[
"
$verbose
"
=
true
]
then
echo
"sha256sum of the destination:
$sha256sumDes
"
fi
if
[
"
$sha256sumSrc
"
==
"
$sha256sumDes
"
]
then
if
[
"
$quite
"
=
false
]
then
echo
"OK!"
;
fi
exit
0
;
else
if
[
"
$quite
"
=
false
]
then
echo
"FAILED!"
;
fi
exit
1
;
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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