Most of OpenShift’s documentation on setting environment variables has you running commands like this:
$ rhc env set name=value
This is great, but there are a handful of circumstances where it would be better to set variables in your action hooks. Normal bash exports wont work, but OpenShift has a special directory where environment variables exist as files. To create variables, simply add files in the $OPENSHIFT_HOMEDIR/.env/user_vars/ directory, where the filename is the variable name. This allows you to place lines like this in your action hooks:
# pre_start cd $OPENSHIFT_HOMEDIR/.env/user_vars echo $OPENSHIFT_POSTGRESQL_DB_PASSWORD > POSTGRESQL_PASSWORD
Once created, OpenShift will automatically load this as a persistent environment variable.