-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_db.sh
executable file
·48 lines (35 loc) · 1.4 KB
/
build_db.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
#!/bin/bash
set -euxo pipefail
# install dependencies
sudo apt-get update && sudo apt-get install libnss3 nss-plugin-pem ca-certificates
curl -sL https://github.com/lwthiker/curl-impersonate/releases/download/v0.6.1/curl-impersonate-v0.6.1.x86_64-linux-gnu.tar.gz | sudo tar -xz -C /usr/bin
# https://docs.brew.sh/Homebrew-on-Linux#install
test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)"
test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bash_profile
echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.profile
brew update && brew install sqlite sqldiff
# populate CF cookies
./populate_cookies.sh
# forms
./populate_forms.sh
# formtypes
./populate_form_types.sh
# formoffices
./populate_form_types_offices.sh
# processing times
./populate_processing_times.sh
# must be last for selftest checksums
./populate_metadata.sh
# rename to current date
mv uscis.db "$(date +"%F").db"
# generate raw sqldiff
sqldiff prev/*.db *.db > sqldiff.txt
# generate changelog
sqldiff=$(<sqldiff.txt)
max_diff_length=124000
if [ $(wc -c <<< $sqldiff) -gt $max_diff_length ]
then
printf -v sqldiff '%.*s...\n\nTruncated for length' $max_diff_length "$(<sqldiff.txt)"
fi
printf "$(<changelog-template.txt)" "$(basename prev/*.db .db)" "$(basename *.db .db)" "$sqldiff" > changelog.txt