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}"
|
|
|
|
MYSQL_SERVER="${MYSQL_SERVER:-localhost}"
|
|
|
|
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}"
|
|
|
|
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
|