Started working through configuration steps
This commit is contained in:
parent
a999544a05
commit
cf486bed93
1 changed files with 42 additions and 25 deletions
|
@ -1,31 +1,48 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# TODO: Remove this notes section.
|
## Config setup
|
||||||
## Keeping this here as notes for later sed magic.
|
|
||||||
# #########################
|
|
||||||
# ## Chainquery Settings ##
|
|
||||||
# #########################
|
|
||||||
# RPC_USER=lbryrpc ## Not super necessery to change this.
|
|
||||||
# RPC_PASSWORD=changeme ## Please replace changeme.
|
|
||||||
# RPC_ALLOW_IP=10.6.1.3 ## You're better off not changing this.
|
|
||||||
#
|
|
||||||
# #################
|
|
||||||
# ## Mysql Creds ##
|
|
||||||
# #################
|
|
||||||
# MYSQL_SERVER=10.6.1.10 ## You're better off not changing this.
|
|
||||||
# MYSQL_USER=changeme ## This could be changed.
|
|
||||||
# MYSQL_PASSWORD=changeme ## This could be set to something random it sets this string for both Mysql's main user and Chainquery's MysqlDSN.
|
|
||||||
# MYSQL_DATABASE=chainquery ## This can stay the same.
|
|
||||||
# MYSQL_ROOT_PASSWORD=changeme ## Set this to something random and obnoxious we're not using it.
|
|
||||||
|
|
||||||
# TODO: Add chainquery startup magic for configuration.
|
## Setup Values
|
||||||
# sed -i ''
|
DEBUGMODE=${DEBUGMODE:-false}
|
||||||
#
|
LBRYCRDURL="rpc://${RPC_USER:-lbryrpc}:${RPC_PASSWORD:-changeme}@10.5.1.2:9245"
|
||||||
#
|
MYSQLDSN="${MYSQL_USER:-changeme}:${MYSQL_PASSWORD:-changeme}@tcp(${MYSQL_SERVER:-10.5.1.10}:3306)/${MYSQL_DATABASE:-chainquery}"
|
||||||
# debugmode=${DEBUGMODE:-false}
|
APIMYSQLDSN="${MYSQL_USER:-changeme}:${MYSQL_PASSWORD:-changeme}@tcp(${MYSQL_SERVER:-10.5.1.10}:3306)/${MYSQL_DATABASE:-chainquery}"
|
||||||
# lbrycrdurl="rpc://${RPC_USER:-lbryrpc}:${RPC_PASSWORD:-changeme}@10.6.1.2:9245"
|
|
||||||
# mysqldsn="${MYSQL_USER:-changeme}:${MYSQL_PASSWORD:-changeme}@tcp(${MYSQL_SERVER:-10.6.1.10}:3306)/${MYSQL_DATABASE:-chainquery}"
|
## Setup Defaults
|
||||||
# apimysqldsn="${MYSQL_USER:-changeme}:${MYSQL_PASSWORD:-changeme}@tcp(${MYSQL_SERVER:-10.6.1.10}:3306)/${MYSQL_DATABASE:-chainquery}"
|
DEBUGMODE_DEFAULT='#DEFAULT-debugquerymode=false'
|
||||||
|
LBRYCRDURL_DEFAULT='#DEFAULT-lbrycrdurl="rpc://lbry:lbry@localhost:9245"'
|
||||||
|
MYSQLDSN_EFAULT='#DEFAULT-mysqldsn="lbry:lbry@tcp(localhost:3306)/chainquery"'
|
||||||
|
APIMYSQLDSN_DEFAULT='#DEFAULT-apihostport="0.0.0.0:6300"'
|
||||||
|
|
||||||
|
## Add setup value variable name to this list to get processed on container start
|
||||||
|
CONFIG_SETTINGS=(
|
||||||
|
DEBUGMODE
|
||||||
|
LBRYCRDURL
|
||||||
|
MYSQLDSN_
|
||||||
|
APIMYSQLDSN
|
||||||
|
)
|
||||||
|
|
||||||
|
function set_configs(parameter) {
|
||||||
|
## Set configs on container start if not already set.
|
||||||
|
for i in "${!CONFIG_SETTINGS[@]}"; do
|
||||||
|
echo ${CONFIG_SETTINGS[$i]}"_KEY"
|
||||||
|
## Indirect references http://tldp.org/LDP/abs/html/ivr.html
|
||||||
|
eval FROM_STRING=\$"${CONFIG_SETTINGS[$i]}_DEFAULT"
|
||||||
|
eval TO_STRING=\$${CONFIG_SETTINGS[$i]}
|
||||||
|
## TODO: Add a bit more magic to make sure that you're only configuring things if not set by config mounts.
|
||||||
|
sed -i '' "s/$FROM_STRING/$TO_STRING/g" /etc/chainquery/chainqueryconfig.toml
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ ! -f /etc/chainquery/chainqueryconfig.toml ]]; then
|
||||||
|
echo "[INFO]: Found no chainqueryconfig.toml"
|
||||||
|
echo " Installing default and configuring with provided environment variables if any."
|
||||||
|
set_configs
|
||||||
|
else
|
||||||
|
echo "[INFO]: Found a copy of chainqueryconfig.toml in /etc/chainquery"
|
||||||
|
echo " Attempting to non destructively install any new environment configurations."
|
||||||
|
set_configs
|
||||||
|
fi
|
||||||
|
|
||||||
## For now keeping this simple. Potentially eventually add all command args as envvars for the Dockerfile or use safe way to add args via docker-compose.yml
|
## For now keeping this simple. Potentially eventually add all command args as envvars for the Dockerfile or use safe way to add args via docker-compose.yml
|
||||||
chainquery serve -c "/etc/chainquery/"
|
chainquery serve -c "/etc/chainquery/"
|
||||||
|
|
Loading…
Reference in a new issue