Created
August 8, 2011 22:59
-
-
Save rtekie/1132976 to your computer and use it in GitHub Desktop.
RightScale script to generate rails database.yml file upon server launch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -ex | |
# Create database.yml for a Ruby on Rails application | |
# Storing database.yml in a source code control system with its production database credentials creates a security risk. | |
# Using this script, you can take advantage of RightScale's secure credentials store | |
# and generate the file when an application server is launched. | |
# | |
# If this is a reboot skip this script. | |
if test "$RS_REBOOT" = "true" ; then | |
logger -t RightScale "Skip RB create database.yml." | |
exit 0 | |
fi | |
# Create database.yml file | |
cat <<EOF >/home/webapps/$APPLICATION/shared/system/config/database.yml | |
$RAILS_ENV: | |
adapter: mysql2 | |
host: $MASTER_DB_DNSNAME | |
port: 3306 | |
encoding: utf8 | |
reconnect: false | |
database: $DB_SCHEMA_NAME | |
pool: 5 | |
username: $DBAPPLICATION_USER | |
password: $DBAPPLICATION_PASSWORD | |
EOF | |
ln -nfs /home/webapps/$APPLICATION/shared/system/config/database.yml /home/webapps/$APPLICATION/current/config/database.yml | |
logger -t RightScale "database.yml created." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment