forked from drakontia/redmine_charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redmine_install.sh
133 lines (112 loc) · 3.69 KB
/
redmine_install.sh
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
#/bin/bash
if [[ ! "$TESTSPACE" = /* ]] ||
[[ ! "$PATH_TO_REDMINE" = /* ]] ||
[[ ! "$PATH_TO_TESTER" = /* ]] ||
[[ ! "$NAME_OF_PLUGIN" = * ]] ||
[[ ! "$PATH_TO_PLUGIN" = /* ]];
then
echo "You should set"\
" TESTSPACE, PATH_TO_REDMINE, PATH_TO_TESTER"\
" NAME_OF_PLUGIN, PATH_TO_PLUGIN"\
" environment variables"
echo "You set:"\
"$TESTSPACE"\
"$PATH_TO_REDMINE"\
"$PATH_TO_PLUGIN"
"$NAME_OF_PLUGIN"
"$PATH_TO_PLUGIN"
exit 1;
fi
export RAILS_ENV=test
case $REDMINE_VER in
1.4.5) export PATH_TO_INSTALL=./vendor/plugins # for redmine < 2.0
export GENERATE_SECRET=generate_session_store
export MIGRATE_PLUGINS=db:migrate_plugins
export REDMINE_GIT_REPO=git://github.com/edavis10/redmine.git
export REDMINE_GIT_TAG=$REDMINE_VER
;;
2.1.4) export PATH_TO_INSTALL=./plugins # for redmine 2.0
export GENERATE_SECRET=generate_secret_token
export MIGRATE_PLUGINS=redmine:plugins:migrate
export REDMINE_GIT_REPO=git://github.com/edavis10/redmine.git
export REDMINE_GIT_TAG=$REDMINE_VER
;;
2.0.4) export PATH_TO_INSTALL=./plugins # for redmine 2.0
export GENERATE_SECRET=generate_secret_token
export MIGRATE_PLUGINS=redmine:plugins:migrate
export REDMINE_GIT_REPO=git://github.com/edavis10/redmine.git
export REDMINE_GIT_TAG=$REDMINE_VER
;;
master) export PATH_TO_INSTALL=./plugins # for redmine 2.0
export GENERATE_SECRET=generate_secret_token
export MIGRATE_PLUGINS=redmine:plugins:migrate
export REDMINE_GIT_REPO=git://github.com/edavis10/redmine.git
export REDMINE_GIT_TAG=$REDMINE_VER
;;
v3.3.0) export PATH_TO_INSTALL=./vendor/plugins
export GENERATE_SECRET=generate_session_store
export MIGRATE_PLUGINS=db:migrate:plugins
export REDMINE_GIT_REPO=http://github.com/chiliproject/chiliproject.git
export REDMINE_GIT_TAG=$REDMINE_VER
;;
*) echo "Unsupported platform $REDMINE_VER"
exit 1
;;
esac
export BUNDLE_GEMFILE=$PATH_TO_REDMINE/Gemfile
clone_redmine()
{
set -e # exit if clone fails
git clone -b master --depth=100 --quiet $REDMINE_GIT_REPO $PATH_TO_REDMINE
cd $PATH_TO_REDMINE
git checkout $REDMINE_GIT_TAG
}
run_tests()
{
# exit if tests fail
set -e
cd $PATH_TO_REDMINE
bash $PATH_TO_TESTER
}
uninstall()
{
set -e # exit if migrate fails
cd $PATH_TO_REDMINE
# clean up database
bundle exec rake $MIGRATE_PLUGINS NAME=$NAME_OF_PLUGIN VERSION=0
}
run_install()
{
# exit if install fails
set -e
# cd to redmine folder
cd $PATH_TO_REDMINE
echo current directory is `pwd`
# create a link to the backlogs plugin
ln -sf $PATH_TO_PLUGIN $PATH_TO_INSTALL/$NAME_OF_PLUGIN
# install gems
mkdir -p vendor/bundle
bundle install --path vendor/bundle --without development
# copy database.yml
cp $TESTSPACE/database.yml config/
git clone git://github.com/pullmonkey/open_flash_chart.git $PATH_TO_INSTALL/open_flash_chart
mkdir -p public/plugin_assets/open_flash_chart
cp -r $PATH_TO_INSTALL/open_flash_chart/assets/* public/plugin_assets/open_flash_chart/
# run redmine database migrations
bundle exec rake db:migrate
# install redmine database
bundle exec rake redmine:load_default_data REDMINE_LANG=en
# generate session store/secret token
bundle exec rake $GENERATE_SECRET
# run backlogs database migrations
bundle exec rake $MIGRATE_PLUGINS
}
while getopts :ictu opt
do case "$opt" in
i) run_install; exit 0;;
c) clone_redmine; exit 0;;
t) run_tests; exit 0;;
u) uninstall; exit 0;;
[?]) echo "i: install; c: clone redmine; t: run tests; u: uninstall";;
esac
done