blob: 97619b9d874c743d6397662dc4b97a69734eba97 (
plain)
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
|
#!/bin/bash
#
# ./fastback-unload-receipt RECEIPT
# where RECEIPT is the name of the file containing the receipt
# output by fastback
#
# will check the md5sum of the file, and decript it if it is encrypted
# the file must have already been downloaded to the local directory
#
RECEIPT=$1
if [ "$2" = "" ]; then
DO_FETCH=false
elif [ "$2" = "fetch" ]; then
DO_FETCH=true
else
echo >&2 "Error: invalid second argument: $2"
exit 2
fi
if [ ! -e $RECEIPT ]; then
echo >&2 "Error: no such file $RECEIPT"
exit 2
fi
cat $RECEIPT | while read FIRST REST ; do
#echo "FIRST:" $FIRST
#echo "REST:" $REST
if [ "$FIRST" = "FILE:" ]; then
export FILE=$REST
if [ -z "$FILE" ]; then
echo >&2 "Error: file name missing from \"FILE:\" line"
exit 2
fi
#echo found FILE: $FILE
fi
if [ "$FIRST" = "MD5SUM:" ]; then
if ! read MD5LINE; then
echo >&2 "Error: unable to read MD5SUM"
exit 2
fi
#echo found MD5LINE: $MD5LINE
fi
if [ "$FIRST" = "KEY:" ]; then
KEYCODE=$REST
if [ -z "$KEYCODE" ]; then
echo >&2 "Error: key code name missing from \"KEY:\" line"
exit 2
fi
if ! read KEYLINE; then
echo >&2 "Error: unable to read encryption key"
exit 2
fi
#echo found KEY: $KEYCODE $KEYLINE
fi
if [ "$FIRST" = "END:" ]; then
if [ -z "$FILE" ]; then
echo >&2 "Error: no file name found in receipt: $RECEIPT"
exit 2
fi
if $DO_FETCH; then
./fetch-from-indus $FILE
fi
if [ -z "$MD5LINE" ]; then
echo >&2 "Error: no md5sum found in receipt: $RECEIPT"
exit 2
else
#echo "MD5LINE:$MD5LINE"
echo "\"md5sum --check\" reports:"
echo "$MD5LINE" | md5sum --check -
fi
if [ ! -z "$KEYLINE" ]; then
OUTFILE=${FILE%.aes}
if [ "$OUTFILE" = "$FILE" ]; then
OUTFILE=$FILE.decoded
fi
if openssl $KEYCODE -d -in $FILE -out $OUTFILE -pass pass:$KEYLINE; then
echo decode file writen to $OUTFILE
fi
fi
fi
done
|