lbry-sdk/docker/wallet_server_entrypoint.sh

34 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2019-09-16 15:51:22 +02:00
#!/bin/bash
# entrypoint for wallet server Docker image
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
2021-10-20 00:16:56 +02:00
if [[ -n "$SNAPSHOT_URL" ]] && [[ ! -f /database/lbry-leveldb ]]; then
files="$(ls)"
2019-09-16 15:51:22 +02:00
echo "Downloading wallet snapshot from $SNAPSHOT_URL"
wget --no-verbose --trust-server-names --content-disposition "$SNAPSHOT_URL"
2019-09-16 15:51:22 +02:00
echo "Extracting snapshot..."
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
if [ -z "$HUB_COMMAND" ]; then
echo "HUB_COMMAND env variable must be writer, reader, or es_sync"
exit 1
fi
case "$HUB_COMMAND" in
writer ) /home/lbry/.local/bin/lbry-hub-writer "$@" ;;
reader ) /home/lbry/.local/bin/lbry-hub-server "$@" ;;
es_sync ) /home/lbry/.local/bin/lbry-hub-elastic-sync ;;
* ) "HUB_COMMAND env variable must be writer, reader, or es_sync" && exit 1 ;;
esac