forked from sftcd/tek_transparency
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tek_count.sh
executable file
·50 lines (40 loc) · 1.05 KB
/
tek_count.sh
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
#!/bin/bash
# set -x
# script to count TEKs for various places, and stash 'em
# For a cronjob set HOME as needed in the crontab
# and then the rest should be ok, but you can override
# any of these you want
x=${HOME:='/home/stephen'}
x=${TOP:="$HOME/code/tek_transparency"}
TEK_DECODE="$TOP/tek_file_decode.py"
function whenisitagain()
{
date -u +%Y%m%d-%H%M%S
}
NOW=$(whenisitagain)
# pass on zip file names, if given some, or go with all
zips="*.zip"
if [[ "$#" != "0" ]]
then
zips=$@
fi
total_keys=0
for file in $zips
do
echo -e "\tDoing $file"
rm -f export.bin export.sig content.sig content.bin
# try unzip and decode
timeout 120s unzip $file >/dev/null 2>&1
if [[ $? == 0 ]]
then
$TEK_DECODE
new_keys=$?
total_keys=$((total_keys+new_keys))
else
echo "Unzip of $file failed or took too long"
fi
rm -f export.bin export.sig content.sig content.bin
chunk_no=$((chunk_no+1))
done
END=$(whenisitagain)
echo "Finished at $END, got $total_keys (mod 256 - thanks to bash's 1 octet return)"