2018-10-14 14:30:06 +02:00
|
|
|
#!/usr/bin/env bash
|
2018-10-03 19:39:28 +02:00
|
|
|
|
2019-10-10 03:41:24 +02:00
|
|
|
# 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}"
|
2019-10-10 15:28:28 +02:00
|
|
|
RPC_PORT="${RPC_PORT:-9245}"
|
2019-10-10 03:41:24 +02:00
|
|
|
MYSQL_SERVER="${MYSQL_SERVER:-localhost}"
|
2019-10-10 15:28:28 +02:00
|
|
|
MYSQL_PORT="${MYSQL_PORT:-3306}"
|
2019-10-10 03:41:24 +02:00
|
|
|
MYSQL_USER="${MYSQL_USER:-lbry}"
|
|
|
|
MYSQL_PASSWORD="${MYSQL_PASSWORD:-lbry}"
|
|
|
|
MYSQL_DATABASE="${MYSQL_DATABASE:-chainquery}"
|
2018-11-05 04:42:35 +01:00
|
|
|
|
2019-10-10 03:41:24 +02:00
|
|
|
exec_chainquery() {
|
|
|
|
CONFIG_DIR=$(dirname "${CONFIGFILE}")
|
|
|
|
exec chainquery serve --configpath "$CONFIG_DIR"
|
2018-11-12 03:11:09 +01:00
|
|
|
}
|
|
|
|
|
2019-10-10 03:41:24 +02:00
|
|
|
if [[ -f "$CONFIGFILE" ]]; then
|
2019-04-18 19:48:46 +02:00
|
|
|
echo "[INFO]: Found a copy of chainqueryconfig.toml in /etc/lbry"
|
2019-10-10 03:41:24 +02:00
|
|
|
exec_chainquery
|
2018-11-12 03:11:09 +01:00
|
|
|
fi
|
2018-11-05 04:42:35 +01:00
|
|
|
|
2019-10-10 03:41:24 +02:00
|
|
|
cat << EOF >> "${CONFIGFILE}"
|
|
|
|
DEBUGMODE="${DEBUGMODE}"
|
2019-10-10 15:28:28 +02:00
|
|
|
LBRYCRDURL="rpc://${RPC_USER}:${RPC_PASSWORD}@${RPC_HOST}:${RPC_PORT}"
|
|
|
|
MYSQLDSN="${MYSQL_USER}:${MYSQL_PASSWORD}@tcp(${MYSQL_SERVER}:${MYSQL_PORT})/$MYSQL_DATABASE"
|
|
|
|
APIMYSQLDSN="${MYSQL_USER}:${MYSQL_PASSWORD}@tcp(${MYSQL_SERVER}:${MYSQL_PORT})/$MYSQL_DATABASE"
|
2019-10-10 03:41:24 +02:00
|
|
|
EOF
|
|
|
|
exec_chainquery
|