2022-03-21 04:22:37 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-03-21 06:40:35 +00:00
|
|
|
datadir=$1
|
|
|
|
network=$2
|
2022-03-21 04:22:37 +00:00
|
|
|
|
2022-03-30 02:54:07 +00:00
|
|
|
if [ -z "$datadir" ]; then
|
2022-03-30 02:55:22 +00:00
|
|
|
echo "arguments: <your_datadir> <network_name>"
|
2022-03-30 02:54:07 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$network" ]; then
|
2022-03-30 02:55:22 +00:00
|
|
|
echo "arguments: <your_datadir> <network_name>"
|
2022-03-30 02:54:07 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-03-21 06:40:35 +00:00
|
|
|
#git reset --hard
|
|
|
|
#git checkout devel
|
|
|
|
#git pull
|
|
|
|
|
|
|
|
# clean
|
|
|
|
cd ./../erigon-snapshot
|
2022-03-21 04:22:37 +00:00
|
|
|
git reset --hard
|
2022-03-30 02:54:07 +00:00
|
|
|
git checkout auto
|
|
|
|
git pull --ff-only origin auto
|
2022-03-21 06:40:35 +00:00
|
|
|
cd ../erigon
|
|
|
|
|
2022-03-21 04:22:37 +00:00
|
|
|
# it will return only .seg of 500K (because Erigon send to Downloader only such files)
|
2022-03-28 07:44:11 +00:00
|
|
|
go run -trimpath ./cmd/downloader torrent_hashes --datadir="$datadir" --targetfile=./../erigon-snapshot/"$network".toml
|
2022-03-21 06:40:35 +00:00
|
|
|
cd ./../erigon-snapshot
|
2022-03-21 04:22:37 +00:00
|
|
|
git add "$network".toml
|
2022-03-30 02:54:07 +00:00
|
|
|
git commit -m "[ci]: $network, [from]: $HOSTNAME"
|
|
|
|
|
2022-04-02 06:20:26 +00:00
|
|
|
#GH_TOKEN=""
|
2022-03-30 02:54:07 +00:00
|
|
|
GH_TOKEN_FILE=""
|
2022-04-02 06:20:26 +00:00
|
|
|
if [ ! type gcloud ] &>/dev/null; then
|
|
|
|
# GH_TOKEN=$(gcloud secrets versions access 1 --secret="github-snapshot-push")
|
|
|
|
GH_TOKEN_FILE="~/.ssh/vm_rsa"
|
2022-03-30 02:54:07 +00:00
|
|
|
fi
|
2022-03-21 06:40:35 +00:00
|
|
|
|
2022-03-30 02:54:07 +00:00
|
|
|
# /dev/null to avoid logging of insecure git output
|
|
|
|
#SSH_CMD='echo ${GH_TOKEN} | ssh -i /dev/stdin -o IdentitiesOnly=yes'
|
|
|
|
SSH_CMD="ssh -i ${GH_TOKEN_FILE} -o IdentitiesOnly=yes"
|
2022-04-02 06:20:26 +00:00
|
|
|
GIT_SSH_COMMAND=${SSH_CMD} git push git@github.com:ledgerwatch/erigon-snapshot.git auto >/dev/null 2>&1
|
|
|
|
echo "Done"
|