24 Feb
Posted by dan as Ruby on Rails, SVN, Shell Scripting
Tags: bash, project setup, script, SVN
The Deploying Rails Applications book is a good read and if you are new to deploying rails apps, I highly suggest you read it. One of the first things explained is how to correctly setup your rails app and your svn repository. While I have known for awhile that certain files are not supposed to be included within your repositories, I never took the time to really figure out the best way to do it. Thanks to this book, I now know.
I decided to attempt some bash scripting and automate the process. This is one of my first shell scripts and may not be entirely correct. Any feedback would be greatly appreciated. If you have no idea how to create shell scripts, take a look at this, it helped me get started.
Correct usage is ./rails_with_svn.sh svn_repo_path rails_project_path. Since I’m also a wordpress noob, you’ll have to just copy and paste what is below into a file with a .sh extension. I named mine rails_with_svn.sh.
#!/bin/bash # rails_with_svn.sh # This script creates an svn repository at location of first argument # and a rails project at location of second argument # correct usage is ./rails_with_svn.sh svn_repo_path rails_project_path # please report any problems or ideas for improvement to dan@morebs.com # this is one of my first attempts at shell scripting # and I am not responsibly for anything bad that happens if you use it # and I cannot guarantee the correctness of it # Created with the help of # Deploying Rails Applications: A Stet-by-Step Guide by # Ezra Zygmuntowicz and Bruce Tate with Geoffrey Grosenbach # a book available at http://www.pragprog.com/ SUCCESS=0 E_NOARGS=65 if [ -z "$1" ] then echo "Please supply a repository path" exit $E_NOARGS fi if [ -z "$2" ] then echo "Please supply a project path" exit $E_NOARGS fi echo echo "Creating a repository at $1 and rails project at $2" svnadmin create $1 svn mkdir file://$1/trunk file://$1/tags file://$1/branches -m "initial project layout" rails $2 svn checkout file://$1/trunk $2 cd $2 svn add test app tmp log Rakefile script db config doc lib vendor README public svn revert log/* svn propset svn:ignore "*.log" log svn revert config/database.yml mv config/database.yml config/database.yml.sample svn add config/database.yml.sample svn propset svn:ignore "database.yml" config cp config/database.yml.sample config/database.yml svn propset svn:ignore "schema.rb" db svn propset svn:ignore "*" tmp svn propset svn:ignore "*doc" doc svn propset svn:executable "*" `find script -type f | grep -v '.svn'` svn propset svn:executable "*" `find public/dispatch.* script -type f | grep -v '.svn'` svn propset svn:eol-style native public/dispatch.* svn revert public/index.html rm public/index.html svn commit -m "initial project config and checkin" echo "Successfully created your" echo "repository at $1 and" echo "rails project at $2" exit 0
As mentioned above, I can’t guarantee the correctness and am not responsibly for anything bad that might happen because of your use of the script. Of course, any help for improvement would be greatly appreciated.
Tags: bash, project setup, script, SVN
RSS feed for comments on this post · TrackBack URI
Leave a reply