forked from jgraichen/redmine_dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redmine
executable file
·150 lines (116 loc) · 2.6 KB
/
redmine
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
#!/bin/bash
REDMINE_VERSION=${REDMINE_VERSION:-3.0.1}
PWD=$(pwd)
DIR="vendor/redmine/${REDMINE_VERSION}"
if [ "$BUNDLE_PATH" ]; then
BUNDLE_OPTS="--path ${BUNDLE_PATH}"
fi
case ${REDMINE_VERSION} in
master)
REDMINE_SOURCE="http://svn.redmine.org/redmine/trunk"
;;
*)
REDMINE_SOURCE="http://svn.redmine.org/redmine/tags/${REDMINE_VERSION}"
;;
esac
function install
{
set -e
set -x
mkdir -p "${DIR}"
mkdir -p tmp log
svn export --quiet --force "${REDMINE_SOURCE}" "${DIR}"
mkdir -p ${DIR}/public/plugin_assets
ln -s "${PWD}" "${DIR}/plugins/redmine_dashboard"
ln -s "${PWD}/spec" "${DIR}/spec"
ln -s "${PWD}/assets" "${DIR}/public/plugin_assets/redmine_dashboard_linked"
# Adjust capybara version requirements as redmine locks to ~> 2.1.0
# but rspec 3 requires >= 2.2
sed -i -e "s/.*gem [\"']capybara[\"'].*/gem 'capybara', '~> 2.3'/g" "${DIR}/Gemfile"
./redmine-genconf "${DIR}" "${REDMINE_VERSION}" > "${DIR}/config/database.yml"
set +x
pushd "${DIR}"
set -x
bundle install --without rmagick --jobs=3 --retry=3 ${BUNDLE_OPTS}
bundle exec rake generate_secret_token db:create:all db:migrate redmine:plugins:migrate db:test:prepare
set +x
popd
}
function update
{
set -e
[ ! -d "${DIR}" ] && install && return
if [ "${REDMINE_VERSION}" == "master" ]; then
set -x
svn export --quiet --force "${REDMINE_SOURCE}" "${DIR}"
sed -i -e "s/.*gem [\"']capybara[\"'].*/gem 'capybara', '~> 2.3'/g" "${DIR}/Gemfile"
set +x
fi
pushd "${DIR}"
set -x
bundle update --jobs=3 --retry=3
bundle exec rake db:create:all db:migrate redmine:plugins:migrate db:test:prepare
set +x
popd
}
function remove
{
set -e
set -x
rm -r "${DIR}"
set +x
}
function server
{
set -e
pushd "${DIR}"
set -x
bundle exec rails server --port 7000
set +x
popd
}
function do_exec
{
set -e
pushd "${DIR}"
set -x
$*
}
function cleanup
{
set -e
pushd "${DIR}"
set -x
rm -rf tmp/*
rm -rf log/*
set +x
popd
}
function testlog
{
cat "${DIR}/log/test.log"
echo
}
function dist
{
TAG=$1
[ -z "${TAG}" ] && TAG=`git tag | tail -n1`
mkdir -p dist
set -x
git archive --prefix redmine_dashboard/ --output "dist/redmine_dashboard-${TAG}.tar.gz" "${TAG}"
git archive --prefix redmine_dashboard/ --output "dist/redmine_dashboard-${TAG}.zip" "${TAG}"
}
case "$1" in
install) shift; install $@; exit 0;;
update) shift; update $@; exit 0;;
remove) shift; remove $@; exit 0;;
server) shift; server $@; exit 0;;
cleanup) shift; cleanup $@; exit 0;;
testlog) shift; testlog $@; exit 0;;
exec) shift; do_exec $@; exit 0;;
dist) shift; dist $@; exit 0;;
*)
echo "Unknown action: $@"
exit 1
;;
esac