Created
September 26, 2011 07:48
-
-
Save rahul100885/1241804 to your computer and use it in GitHub Desktop.
Deploy Redmine to Heroku
This file contains 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 | |
set -e | |
REDMINE_URL="http://rubyforge.org/frs/download.php/75097/redmine-1.2.1.tar.gz" | |
S3_ACCESS_KEY_ID="" | |
S3_SECRET_ACCESS_KEY="" | |
S3_BUCKET_NAME="" | |
HEROKU_APP_NAME="" | |
txtund=$(tput sgr 0 1) # Underline | |
txtbld=$(tput bold) # Bold | |
txtred=$(tput setaf 1) # Red | |
txtgrn=$(tput setaf 2) # Green | |
txtylw=$(tput setaf 3) # Yellow | |
txtblu=$(tput setaf 4) # Blue | |
txtrst=$(tput sgr0) # Text reset | |
STEP=0 | |
function step() { | |
STEP=$(echo $STEP+1 | bc) | |
echo -n "${txtund}${txtbld}${STEP}. $1${txtrst} … " | |
} | |
function success() { | |
echo "${txtgrn}$1${txtrst}" | |
} | |
function error() { | |
echo | |
echo "${txtred}ERROR: $1${txtrst}" | |
exit 99 | |
} | |
step "Check prerequisites" | |
if ! which git ; then | |
error "No git executable found. Please install Git before proceeding." | |
fi | |
if ! which heroku ; then | |
error "The heroku command line tool was not found. Please see http://devcenter.heroku.com/articles/heroku-command on how to install it." | |
fi | |
success "Done" | |
step "Get latest Redmine sources" | |
REDMINE_FILENAME=$(echo $REDMINE_URL | sed -e 's/.*\///') | |
if [[ ! -e ./$REDMINE_FILENAME ]] ; then | |
wget -q $REDMINE_URL | |
success "Done." | |
else | |
success "Redmine archive already downloaded." | |
fi | |
step "Extract Redmine archive" | |
TEMPDIR=redmine-$$ | |
mkdir $TEMPDIR | |
cd $TEMPDIR | |
tar --strip-components 1 -xzf ../$REDMINE_FILENAME | |
success "Done." | |
step "Create .gems file" | |
echo "rails --version 2.3.11 | |
i18n --version 0.4.2 | |
rack --version 1.1.1 | |
faker | |
random_data | |
memcached-northscale" > .gems | |
success "Done." | |
step "Clone plugins" | |
echo | |
cd vendor/plugins | |
git clone -q https://github.com/edavis10/redmine_heroku.git | |
#git clone -q https://github.com/tigrish/redmine_s3.git | |
cd ../.. | |
success "Done." | |
step "Alter .gitignore" | |
echo "6,7d5 | |
< /config/email.yml | |
< /config/initializers/session_store.rb | |
18d15 | |
< /public/plugin_assets | |
" | patch .gitignore | |
success "Done." | |
step "Alter config/environment.rb" | |
RANDOM_STRING=$(date | md5sum) | |
echo "55a56,57 | |
> config.action_controller.session = { :key => \"_myapp_session\", :secret => \"${RANDOM_STRING}\" } | |
> | |
" | patch config/environment.rb | |
success "Done." | |
step "Create Git repository" | |
git init | |
#git rm -q --cached vendor/plugins/redmine_heroku | |
#git rm -q --cached vendor/plugins/redmine_s3 | |
rm -rf vendor/plugins/redmine_heroku/.git | |
#rm -rf vendor/plugins/redmine_s3/.git | |
git add . | |
success "Done." | |
step "Configure S3 plugin" | |
if [[ -z "$S3_ACCESS_KEY_ID" ]] ; then | |
read -p "S3 Access Key ID? " S3_ACCESS_KEY_ID | |
fi | |
if [[ -z "$S3_SECRET_ACCESS_KEY" ]] ; then | |
read -p "S3 Secret Access Key? " S3_SECRET_ACCESS_KEY | |
fi | |
if [[ -z "$S3_BUCKET_NAME" ]] ; then | |
read -p "S3 Bucket Name? " S3_BUCKET_NAME | |
fi | |
echo "production: | |
access_key_id: ${S3_ACCESS_KEY_ID} | |
secret_access_key: ${S3_SECRET_ACCESS_KEY} | |
bucket: ${S3_BUCKET_NAME} | |
development: | |
access_key_id: ${S3_ACCESS_KEY_ID} | |
secret_access_key: ${S3_SECRET_ACCESS_KEY} | |
bucket: ${S3_BUCKET_NAME} | |
" > config/s3.yml | |
success "Done." | |
step "Setup email" | |
echo "production: | |
delivery_method: :smtp | |
smtp_settings: | |
address: \"smtp.sendgrid.net\" | |
port: 25 | |
authentication: :plain | |
domain: \"heroku.com\" | |
user_name: \"YOUR_SENDGRID_PASSWORD\" | |
password: \"YOUR_SENDGRID_USERNAME\" | |
" > config/email.yml | |
git add . | |
echo "SMTP credentials need updating" | |
echo "(use heroku config --long and update the email.yml, then commit and push)" | |
success "Done" | |
step "Configure database" | |
echo "production: | |
adapter: sqlite3 | |
database: db/production.db | |
development: | |
adapter: sqlite3 | |
database: db/development.db | |
" > config/database.yml | |
success "Done." | |
step "Create heroku app" | |
if [[ -z "$HEROKU_APP_NAME" ]]; then | |
read -p "Heroku app name (leave empty for random name)? " HEROKU_APP_NAME | |
fi | |
heroku create $HEROKU_APP_NAME --stack bamboo-ree-1.8.7 | |
heroku addons:add sendgrid | |
heroku config | |
success "Done." | |
step "Setup the heroku plugin" | |
rake heroku:setup | |
success "Done." | |
step "Add files to Git" | |
git add . | |
git commit -am 'Heroku setup' | |
success "Done." | |
step "Push app to heroku" | |
git push heroku master | |
success "Done." | |
step "Apply database migrations – this could take a while" | |
heroku rake db:migrate | |
success "Done." | |
echo | |
echo "${txtgrn}Redmine was set up on Heroku!${txtrst} | |
Next steps: | |
- open website by entering \"heroku open\" | |
- login with admin:admin | |
- click on \"Administration\" | |
- select language and load the default configuration | |
- change password | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment