Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 270 lines (233 sloc) 8.728 kb
#!/bin/bash
GEMSET=`rvm-prompt g | sed -e 's/@//'`
if [ -z "$GEMSET" ]; then
echo "No gemset"
exit
fi
CONFIG="$( cd "$( dirname "$0" )" && pwd )"
CONFIG="$CONFIG/rbl-reinstall.rc"
export RAILS_ENV=development
if [ ! -f $CONFIG ]; then
echo "$CONFIG does not exist"
exit
fi
source $CONFIG
function fixgemspecs {
gemspecs=`ls -A /home/hnse/.rvm/gems/ruby-1.8.7-p358@redmine/specifications | tail -1 | wc -l`
if [ "$gemspecs" = "1" ]; then
for gemspec in `gem environment gemdir`/specifications/*.gemspec; do
ruby -pi -e "gsub(/s.date\s*=\s*%q\{([0-9]{4}-[0-9]{2}-[0-9]{2}) 00:00:00.0+Z?\}/, 's.date = %q{\1}')" $gemspec
done
fi
}
if [ -z "$DBROOTPW" ]; then
echo "DBROOTPW not set"
exit
fi
if [ -z "$DBPW" ]; then
echo "DBPW not set"
exit
fi
if [ -z "$DBUSER" ]; then
echo "DBUSER not set, defaulting to redmine"
DBUSER=redmine
fi
if [ ! -d ~/redmine ]; then
echo "~/redmine does not exist"
exit
fi
cd ~/redmine
if [ ! -f ~/redmine/setup/database-redmine.yml ]; then
echo "~/redmine/setup/database-redmine.yml does not exist"
if [ "$GEMSET" = "redmine" ]; then
exit
fi
fi
if [ ! -f ~/redmine/setup/database-chiliproject.yml ]; then
echo "~/redmine/setup/database-chiliproject.yml does not exist"
if [ "$GEMSET" = "chiliproject" ]; then
exit
fi
fi
if [ ! -d ~/redmine/redmine_backlogs ]; then
echo "~/redmine/redmine_backlogs does not exist"
exit
fi
# ruby env
if [ -z "`gem list | grep rails`" ]; then
RVM=y
fi
if [ -z "$RVM" ]; then
read -p "Reinstall RVM? " RVM
fi
if [[ $RVM =~ [Yy] ]]; then
echo "re-creating $GEMSET"
rvm --force gemset empty $GEMSET
if [[ "$GEMSET" = "redmine" ]]; then
fixgemspecs
echo 'Downgrading rubygems'
rm -f `gem environment gemdir`/specifications/*.gemspec
rvm rubygems 1.7.2
echo 'Installing base gems'
gem install rack -v=1.1.1
gem install rails -v=2.3.14
gem install i18n -v=0.4.2
fixgemspecs
echo 'Installing gems for redmine-backlogs'
gem install mysql
gem install icalendar
gem install system_timer
gem install prawn
gem install holidays --version 1.0.3
#fixgemspecs
#gem install holidays
#fixgemspecs
gem install open-uri-cached
gem install nokogiri
# dev & testing
gem install gherkin -v=2.8.0
gem install term-ansicolor -v=1.0.6
gem install -v=1.1.8 cucumber
#gem install zentest-without-autotest
gem install ZenTest -v=4.6.0
gem install -v=1.3.1 rspec
gem install -v=0.3.2 cucumber-rails
gem install -v=0.2.15 culerity
gem install rubyzip -v=0.9.5
gem install capybara -v=0.3.9
gem install spork -v=0.8.5
gem install database_cleaner
#gem install autotest-rails
gem install redgreen
gem install rcov
gem install -v=1.3.3 rspec-rails
gem install timecop
gem install thin
# cucumber-rails pulls in an unnecesary gherkin
eval `ruby -e "require 'rubygems'; puts Gem.source_index.find_name('gherkin').reject{|x| x.version.version == '2.8.0'}.collect{|x| \"gem uninstall gherkin -v=#{x.version.version}\"}.join(\"\n\")"`
fi
if [[ "$GEMSET" = "chiliproject" ]]; then
gem install bundler
gem install system_timer
# rest is installed through bundler install
fi
fi
# redmine
if [ "$GEMSET" = "redmine" ]; then
if [ ! -f ~/redmine/redmine/config/database.yml ]; then
echo Forced RM install
RMINSTALL=Y
elif [ -z "$RMINSTALL" ]; then
read -p "Reinstall Redmine? " RMINSTALL
fi
if [[ $RMINSTALL =~ [Yy] ]]; then
if [ -z "$RMVERSION" ]; then
echo "VERSION not set"
exit
fi
echo "create database redmine character set utf8;" | mysql -u root -p$DBROOTPW mysql
echo "create user '$DBUSER'@'localhost' identified by '$DBPW';" | mysql -u root -p$DBROOTPW mysql
rm -rf ~/redmine/redmine
cd ~/redmine
#git clone git://github.com/edavis10/redmine.git
svn co http://redmine.rubyforge.org/svn/tags/$RMVERSION redmine
cd ~/redmine/redmine
#git fetch --tags
#git checkout $VERSION
cp ~/redmine/setup/database-redmine.yml ~/redmine/redmine/config/database.yml
ln -s ~/redmine/redmine_backlogs ~/redmine/redmine/vendor/plugins
ln -s ~/redmine/redmine_backlogs/features ~/redmine/redmine
echo 'rvm use 1.8.7@redmine' > ~/redmine/redmine/.rvmrc
[ -f ~/redmine/redmine/config/environments/cucumber.rb ] || script/generate cucumber --spork
fi
fi
# chiliproject
if [ "$GEMSET" = "chiliproject" ]; then
if [ ! -f ~/redmine/chiliproject/config/database.yml ]; then
echo Forced CP install
CPINSTALL=Y
elif [ -z "$CPINSTALL" ]; then
read -p "Reinstall ChiliProject? " CP
fi
if [[ $CPINSTALL =~ [Yy] ]]; then
if [ -z "$CPVERSION" ]; then
echo "VERSION not set"
exit
fi
echo "create database chiliproject character set utf8;" | mysql -u root -p$DBROOTPW mysql
echo "create user '$DBUSER'@'localhost' identified by '$DBPW';" | mysql -u root -p$DBROOTPW mysql
rm -rf ~/redmine/chiliproject
cd ~/redmine
git clone http://github.com/chiliproject/chiliproject.git
cd ~/redmine/chiliproject
git fetch --tags
git checkout v$CPVERSION
cp ~/redmine/setup/database-chiliproject.yml ~/redmine/chiliproject/config/database.yml
ln -s ~/redmine/redmine_backlogs ~/redmine/chiliproject/vendor/plugins
ln -s ~/redmine/redmine_backlogs/features ~/redmine/chiliproject
echo 'rvm use 1.8.7@chiliproject' > ~/redmine/chiliproject/.rvmrc
fi
if [[ $RVM =~ [Yy] ]]; then
cd ~/redmine/chiliproject
sed -i -e"s/gem 'capybara'/gem 'capybara', '=0.3.9'/" Gemfile
bundle install redmine_dev=true
fi
if [[ $CPINSTALL =~ [Yy] ]]; then
[ -f ~/redmine/redmine/config/environments/cucumber.rb ] || script/generate cucumber --spork
fi
fi
# RM database
if [ "$GEMSET" = "redmine" ]; then
if [ -z "$RMDB" ]; then
read -p "Reinstall RM database? " RMDB
fi
if [[ $RMDB =~ [Yy] ]]; then
mysqladmin -f -u root -p$DBROOTPW drop redmine
echo "create database redmine character set utf8;" | mysql -u root -p$DBROOTPW mysql
echo "create user '$DBUSER'@'localhost' identified by '$DBPW';" | mysql -u root -p$DBROOTPW mysql
echo "grant all privileges on redmine.* to 'redmine'@'localhost';" | mysql -u root -p$DBROOTPW mysql
cd ~/redmine/redmine
if [ -f ~/redmine/setup/redmine.sql.gz ]; then
echo 'Restoring database backup'
zcat ~/redmine/setup/redmine.sql.gz | mysql -u root -p$DBROOTPW redmine
echo "update users set auth_source_id = NULL;" | mysql -u root -p$DBROOTPW redmine
fi
echo "Let's go!"
rake db:migrate
rake generate_session_store
rake redmine:load_default_data REDMINE_LANG=en
rake db:migrate:upgrade:plugin_migrations
rake db:migrate:plugins
rake redmine:backlogs:install labels=no story_trackers=Story task_tracker=Task
if [ ! -z "$USERPW" ]; then
./script/runner "User.find(:all).reject{|user| user.login.to_s == ''}.each{|user| user.password, user.password_confirmation = '$USERPW'; user.auth_source = nil; user.save!; puts '** password for ' + user.login + ' set to $USERPW'}"
fi
fi
fi
if [ "$GEMSET" = "chiliproject" ]; then
if [ -z "$CPDB" ]; then
read -p "Reinstall CP database? " CPDB
fi
if [[ $CPDB =~ [Yy] ]]; then
mysqladmin -u root -p$DBROOTPW drop chiliproject
echo "create database chiliproject character set utf8;" | mysql -u root -p$DBROOTPW mysql
echo "create user '$DBUSER'@'localhost' identified by '$DBPW';" | mysql -u root -p$DBROOTPW mysql
echo "grant all privileges on chiliproject.* to 'redmine'@'localhost';" | mysql -u root -p$DBROOTPW mysql
cd ~/redmine/chiliproject
if [ -f ~/redmine/setup/chiliproject.sql.gz ]; then
echo 'Restoring database backup'
zcat ~/redmine/setup/chiliproject.sql.gz | mysql -u root -p$DBROOTPW chiliproject
echo "update users set auth_source_id = NULL;" | mysql -u root -p$DBROOTPW chiliproject
fi
echo "Let's go!"
bundle exec rake db:migrate
bundle exec rake generate_session_store
bundle exec rake redmine:load_default_data
bundle exec rake db:migrate:upgrade_plugin_migrations
bundle exec rake db:migrate:plugins
bundle exec rake redmine:backlogs:install
if [ ! -z "$ADMINPW" ]; then
bundle exec script/runner "user = User.find(:first, :conditions => {:admin => true}) ; user.password, user.password_confirmation = '$ADMINPW'; user.auth_source = nil; user.save!; puts '** password for ' + user.login + ' set to $ADMINPW'"
fi
fi
fi
Jump to Line
Something went wrong with that request. Please try again.