Skip to content

Instantly share code, notes, and snippets.

@dangarthwaite
Created October 7, 2019 17:50
Show Gist options
  • Save dangarthwaite/fc3ad01b29bd75387836e3c16cd21c9b to your computer and use it in GitHub Desktop.
Save dangarthwaite/fc3ad01b29bd75387836e3c16cd21c9b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Override defaults with environment variables
CONFIGFILE="${CONFIGFILE:-/etc/lbry/chainqueryconfig.toml}"
DEBUGMODE="${DEBUGMODE:-false}"
RPC_USER="${RPC_USER:-lbry}"
RPC_PASSWORD="${RPC_PASSWORD:-lbry}"
RPC_HOST="${RPC_HOST:-localhost}"
MYSQL_SERVER="${MYSQL_SERVER:-localhost}"
MYSQL_USER="${MYSQL_USER:-lbry}"
MYSQL_PASSWORD="${MYSQL_PASSWORD:-lbry}"
MYSQL_DATABASE="${MYSQL_DATABASE:-chainquery}"
exec_chainquery() {
CONFIG_DIR=$(dirname "${CONFIGFILE}")
exec chainquery serve --configpath "$CONFIG_DIR"
}
if [[ -f "$CONFIGFILE" ]]; then
echo "[INFO]: Found a copy of chainqueryconfig.toml in /etc/lbry"
exec_chainquery
fi
cat << EOF >> "${CONFIGFILE}"
DEBUGMODE="${DEBUGMODE}"
LBRYCRDURL="rpc://${RPC_USER}:${RPC_PASSWORD}@${RPC_HOST}:9245"
MYSQLDSN="${MYSQL_USER}:${MYSQL_PASSWORD}@tcp(${MYSQL_SERVER}:3306)/$MYSQL_DATABASE"
APIMYSQLDSN="${MYSQL_USER}:${MYSQL_PASSWORD}@tcp(${MYSQL_SERVER}:3306)/$MYSQL_DATABASE"
EOF
exec_chainquery
@dangarthwaite
Copy link
Author

This should be a wire-equivalent replacement of the current stuff/start.sh script.

Next would be to add RPC_PORT since the lbrycrd in RUN_MODE=REG_TEST runs on a nonstandard port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment