Skip to content

Instantly share code, notes, and snippets.

@conleym
Created November 20, 2016 23:59
Show Gist options
  • Save conleym/64afeac0ac77e59fa24a4c1511507889 to your computer and use it in GitHub Desktop.
Save conleym/64afeac0ac77e59fa24a4c1511507889 to your computer and use it in GitHub Desktop.
Read nuxeo configuration into an associative array
# Get nuxeo config parameters as <name>=<value> pairs, one per line.
# grep gets rid of other output.
# Perform replacement so that the results can be assigned to an associative array.
RAW_CONFIG=$(
nuxeoctl --get-regexp config '.' |
grep '=' |
sed -r 's/([^=]*)=(.*)/\[\1\]="\2"/')
# Assign transformed results to an associative array.
declare -A CONFIG
eval "CONFIG=(${RAW_CONFIG})"
# Export postgresql vars.
export PGPASSWORD="${CONFIG[nuxeo.db.password]}"
export PGUSER="${CONFIG[nuxeo.db.user]}"
export PGDATABASE="${CONFIG[nuxeo.db.name]}"
export PGHOST="${CONFIG[nuxeo.db.host]}"
export PGPORT="${CONFIG[nuxeo.db.port]}"
# Export other important things
export NX_DATA_DIR="${CONFIG[nuxeo.data.dir]}"
export NX_S3_BUCKET="${CONFIG[nuxeo.s3storage.bucket]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment