2019-09-16 15:51:22 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# entrypoint for wallet server Docker image
|
|
|
|
|
2019-12-21 20:39:04 +01:00
|
|
|
set -euo pipefail
|
|
|
|
|
2019-09-16 15:51:22 +02:00
|
|
|
SNAPSHOT_URL="${SNAPSHOT_URL:-}" #off by default. latest snapshot at https://lbry.com/snapshot/wallet
|
|
|
|
|
|
|
|
if [[ -n "$SNAPSHOT_URL" ]] && [[ ! -f /database/claims.db ]]; then
|
2019-12-21 20:39:04 +01:00
|
|
|
files="$(ls)"
|
2019-09-16 15:51:22 +02:00
|
|
|
echo "Downloading wallet snapshot from $SNAPSHOT_URL"
|
2019-12-21 20:39:04 +01:00
|
|
|
wget --no-verbose --trust-server-names --content-disposition "$SNAPSHOT_URL"
|
2019-09-16 15:51:22 +02:00
|
|
|
echo "Extracting snapshot..."
|
2019-12-21 20:39:04 +01:00
|
|
|
filename="$(grep -vf <(echo "$files") <(ls))" # finds the file that was not there before
|
|
|
|
case "$filename" in
|
|
|
|
*.tgz|*.tar.gz|*.tar.bz2 ) tar xvf "$filename" --directory /database ;;
|
|
|
|
*.zip ) unzip "$filename" -d /database ;;
|
|
|
|
* ) echo "Don't know how to extract ${filename}. SNAPSHOT COULD NOT BE LOADED" && exit 1 ;;
|
|
|
|
esac
|
|
|
|
rm "$filename"
|
2019-09-16 15:51:22 +02:00
|
|
|
fi
|
|
|
|
|
2021-02-12 05:10:30 +01:00
|
|
|
/home/lbry/.local/bin/torba-elastic-sync /database/claims.db
|
|
|
|
echo 'starting server'
|
2019-09-16 15:51:22 +02:00
|
|
|
/home/lbry/.local/bin/torba-server "$@"
|