-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
export-single-variant.sh
executable file
·39 lines (27 loc) · 1.08 KB
/
export-single-variant.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
#!/bin/bash -e
month=${1}
dir=${2}
variant=${3}
file="lichess_db_${variant}_rated_$month.pgn"
compressed_file="$file.zst"
echo "Export $variant games of $month to $file"
nice -n19 sbt "runMain lichess.Games $month $dir/$file $variant"
cd "$dir"
echo "Counting games in $compressed_file"
touch counts.txt
grep -v -F "$file" counts.txt >counts.txt.new || touch counts.txt.new
games=$(grep --count -F '[Site ' "$file")
echo "$compressed_file $games" >>counts.txt.new
mv counts.txt.new counts.txt
echo "Compressing $games games to $compressed_file"
rm -f $compressed_file
nice -n19 pzstd -p10 -19 --verbose $file
rm $file
echo "Check summing $compressed_file"
touch sha256sums.txt
grep -v -F "$compressed_file" sha256sums.txt >sha256sums.txt.new || touch sha256sums.txt.new
sha256sum "$compressed_file" | tee --append sha256sums.txt.new
mv sha256sums.txt.new sha256sums.txt
echo "Creating torrent for $compressed_file"
mktorrent --web-seed "https://database.lichess.org/$variant/$compressed_file" --piece-length 20 --announce "udp://tracker.torrent.eu.org:451" "$compressed_file"
echo "Done!"