forked from backlogs/redmine_backlogs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrbl-reinstall
executable file
·255 lines (220 loc) · 7.94 KB
/
rbl-reinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/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
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
if [[ $VERSION =~ '1.2.[12]' ]]; then
echo 'Downgrading rubygems'
rvm rubygems 1.3.7
fi
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
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
gem install holidays
gem install open-uri-cached
gem install nokogiri
# dev & testing
gem install gherkin -v=2.8.0
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 capybara -v=0.3.9
gem install spork
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.cache.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
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
rake db:migrate:upgrade_plugin_migrations
rake --trace db:migrate:plugins
rake redmine:backlogs:install labels=no
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