hub/scripts/entrypoint.sh

34 lines
1.2 KiB
Bash
Raw Normal View History

2022-03-18 18:01:47 +01:00
#!/bin/bash
# entrypoint for scribe Docker image
set -euo pipefail
SNAPSHOT_URL="${SNAPSHOT_URL:-}" #off by default. latest snapshot at https://lbry.com/snapshot/hub
if [[ "$HUB_COMMAND" == "scribe" ]] && [[ -n "$SNAPSHOT_URL" ]] && [[ ! -d /database/lbry-rocksdb ]]; then
files="$(ls)"
echo "Downloading hub snapshot from $SNAPSHOT_URL"
wget --no-verbose --trust-server-names --content-disposition "$SNAPSHOT_URL"
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"
fi
2022-03-18 18:01:47 +01:00
if [ -z "$HUB_COMMAND" ]; then
2022-05-18 19:09:42 +02:00
echo "HUB_COMMAND env variable must be scribe, herald, or scribe-elastic-sync"
2022-03-18 18:01:47 +01:00
exit 1
fi
case "$HUB_COMMAND" in
scribe ) exec /home/lbry/.local/bin/scribe "$@" ;;
2022-05-18 21:08:56 +02:00
herald ) exec /home/lbry/.local/bin/herald "$@" ;;
2022-04-22 02:00:19 +02:00
scribe-elastic-sync ) exec /home/lbry/.local/bin/scribe-elastic-sync "$@" ;;
2022-05-18 19:09:42 +02:00
* ) "HUB_COMMAND env variable must be scribe, herald, or scribe-elastic-sync" && exit 1 ;;
2022-03-18 18:01:47 +01:00
esac