start.sh looks to be good to go.
This commit is contained in:
parent
67d3e00261
commit
2b5e7326e6
1 changed files with 70 additions and 46 deletions
92
reflector.go/compile/start.sh
Normal file → Executable file
92
reflector.go/compile/start.sh
Normal file → Executable file
|
@ -1,5 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
## Launch service will tell prism-bin what mode to run in.
|
## Launch service will tell prism-bin what mode to run in.
|
||||||
LAUNCHMODE="${MODE:-$1}"
|
LAUNCHMODE="${MODE:-$1}"
|
||||||
|
@ -7,41 +6,44 @@ LAUNCHMODE="${MODE:-$1}"
|
||||||
## This variable will be what can override default launch args. I may modify this as I learn more about prism-bin
|
## This variable will be what can override default launch args. I may modify this as I learn more about prism-bin
|
||||||
LAUNCHARGS="${CUSTOM_ARGS:-$2}"
|
LAUNCHARGS="${CUSTOM_ARGS:-$2}"
|
||||||
|
|
||||||
|
## This is setup this way to handle any situations that might arise from the
|
||||||
|
## config being JSON and bash not being any good at JSON.
|
||||||
# ## Strings to replace.
|
# ## Strings to replace.
|
||||||
AWS_ID_STR='YOUR-AWS-ID'
|
AWS_ID_STR="YOUR-AWS-ID"
|
||||||
AWS_SECRET_STR=''
|
AWS_SECRET_STR="YOUR-AWS-SECRET"
|
||||||
BUCKET_REGION_STR=''
|
BUCKET_REGION_STR="YOUR-BUCKET-REGION"
|
||||||
BUCKET_NAME_STR=''
|
BUCKET_NAME_STR="YOUR-BUCKET-NAME"
|
||||||
DB_USER_STR=''
|
DB_USER_STR="USER"
|
||||||
DB_PASSWORD=''
|
DB_PASSWORD_STR="PASSWORD"
|
||||||
DB_HOSTIP=''
|
DB_HOSTIP_STR="localhost"
|
||||||
DB_PORT=''
|
DB_PORT_STR="3306"
|
||||||
DB_NAME=''
|
DB_NAME_STR="DBNAME"
|
||||||
|
|
||||||
|
## For the most part this section is disabled
|
||||||
# ## Keys to re-insert
|
# ## Keys to re-insert
|
||||||
AWS_ID_KEY=''
|
# AWS_ID_KEY=''
|
||||||
AWS_SECRET_KEY=''
|
# AWS_SECRET_KEY=''
|
||||||
BUCKET_REGION_KEY=''
|
# BUCKET_REGION_KEY=''
|
||||||
BUCKET_NAME_KEY=''
|
# BUCKET_NAME_KEY=''
|
||||||
DB_USER_KEY=''
|
# DB_USER_KEY=''
|
||||||
DB_PASSWORD=''
|
# DB_PASSWORD_KEY=''
|
||||||
DB_HOSTIP=''
|
# DB_HOSTIP_KEY=''
|
||||||
DB_PORT=''
|
# DB_PORT_KEY=''
|
||||||
DB_NAME=''
|
# DB_NAME_KEY=''
|
||||||
|
|
||||||
# Environment Variables/Defaults
|
# Environment Variables/Defaults
|
||||||
## Json sucks in BASH/Shell so you need to add trailing commas intermittently.
|
## Json sucks in BASH/Shell so you need to add trailing commas intermittently.
|
||||||
## Just pay attention to this. Also at some point I'll need to make a fringe
|
## Just pay attention to this. Also at some point I'll need to make a fringe
|
||||||
## case for handling key/values that aren't included in the default config.
|
## case for handling key/values that aren't included in the default config.
|
||||||
AWS_ID="${AWS_ID:-YOUR-AWS-ID}"
|
AWS_ID="${AWS_ID:-potato}"
|
||||||
AWS_SECRET="${AWS_SECRET:-YOUR_AWS_SECRET}"
|
AWS_SECRET="${AWS_SECRET:-potato}"
|
||||||
BUCKET_REGION="${BUCKET_REGION:-YOUR_BUCKET_REGION}"
|
BUCKET_REGION="${BUCKET_REGION:-potato}"
|
||||||
BUCKET_NAME="${BUCKET_NAME:-YOUR_BUCKET_NAME}"
|
BUCKET_NAME="${BUCKET_NAME:-potato}"
|
||||||
DB_USER="${DB_USER:-DB_USER}"
|
DB_USER="${DB_USER:-potato}"
|
||||||
DB_PASSWORD="${DB_PASSWORD:-YOUR_DB_PASSWORD}"
|
DB_PASSWORD="${DB_PASSWORD:-potato}"
|
||||||
DB_HOSTIP="${DB_HOSTIP:-YOUR_DB_HOSTIP}"
|
DB_HOSTIP="${DB_HOSTIP:-potato}"
|
||||||
DB_PORT="${DB_PORT:-YOUR_DB_PORT}"
|
DB_PORT="${DB_PORT:-potato}"
|
||||||
DB_NAME="${DB_NAME:-YOUR_DB_NAME}"
|
DB_NAME="${DB_NAME:-potato}"
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
## Missing Vars off the hop SLACK_HOOK_URL
|
## Missing Vars off the hop SLACK_HOOK_URL
|
||||||
|
@ -56,11 +58,28 @@ CONFIG_SETTINGS=(
|
||||||
DB_PORT
|
DB_PORT
|
||||||
DB_NAME
|
DB_NAME
|
||||||
)
|
)
|
||||||
|
CONFIG_SECRETS=(
|
||||||
|
AWS_ID
|
||||||
|
AWS_ID_STR
|
||||||
|
AWS_SECRET
|
||||||
|
AWS_SECRET_STR
|
||||||
|
BUCKET_NAME
|
||||||
|
BUCKET_NAME_STR
|
||||||
|
DB_USER
|
||||||
|
DB_USER_STR
|
||||||
|
DB_PASSWORD
|
||||||
|
DB_PASSWORD_STR
|
||||||
|
DB_HOSTIP
|
||||||
|
DB_HOSTIP_STR
|
||||||
|
DB_PORT
|
||||||
|
DB_PORT_STR
|
||||||
|
DB_NAME
|
||||||
|
DB_NAME_STR
|
||||||
|
)
|
||||||
|
|
||||||
## This function might be a bit overkill as all key/value pairs are unique in this config.
|
## This function might be a bit overkill as all key/value pairs are unique in this config.
|
||||||
function config_modify() {
|
|
||||||
for i in "${!CONFIG_SETTINGS[@]}"; do
|
for i in "${!CONFIG_SETTINGS[@]}"; do
|
||||||
# echo ${CONFIG_SETTINGS[$i]}"_KEY"
|
echo ${CONFIG_SETTINGS[$i]}"_KEY"
|
||||||
## Indirect references http://tldp.org/LDP/abs/html/ivr.html
|
## Indirect references http://tldp.org/LDP/abs/html/ivr.html
|
||||||
eval FROM_STRING=\$"${CONFIG_SETTINGS[$i]}_STR"
|
eval FROM_STRING=\$"${CONFIG_SETTINGS[$i]}_STR"
|
||||||
eval VALUE_STRING=\$${CONFIG_SETTINGS[$i]}
|
eval VALUE_STRING=\$${CONFIG_SETTINGS[$i]}
|
||||||
|
@ -71,12 +90,17 @@ function config_modify() {
|
||||||
# echo DEBUG VALUE_STRING: $VALUE_STRING
|
# echo DEBUG VALUE_STRING: $VALUE_STRING
|
||||||
# echo DEBUG KEY_STRING: $KEY_STRING
|
# echo DEBUG KEY_STRING: $KEY_STRING
|
||||||
# echo DEBUG TO_STRING: "$TO_STRING"
|
# echo DEBUG TO_STRING: "$TO_STRING"
|
||||||
sed -i "s/$FROM_STRING/${TO_STRING:-$FROM_STRING}/g" /data/config.tmpl
|
sed -i '' "s/$FROM_STRING/$TO_STRING/g" ./config.tmpl
|
||||||
done
|
done
|
||||||
}
|
|
||||||
config_modify
|
|
||||||
|
|
||||||
## Actual launch invoked here
|
## Sanitization section
|
||||||
|
# Awaiting someone smarter than me to suggest a method for this.
|
||||||
|
# https://unix.stackexchange.com/questions/474097/i-want-to-unset-a-list-of-bash-variables-that-have-their-variable-strings-stored
|
||||||
|
for i in "${CONFIG_SECRETS[@]}"; do
|
||||||
|
unset $i
|
||||||
|
done
|
||||||
|
|
||||||
|
# Actual launch invoked here
|
||||||
case $MODE in
|
case $MODE in
|
||||||
cluster )
|
cluster )
|
||||||
prism-bin cluster ${LAUNCHARGS:-'-v --conf /data/config.tmpl'}
|
prism-bin cluster ${LAUNCHARGS:-'-v --conf /data/config.tmpl'}
|
||||||
|
|
Loading…
Reference in a new issue