Projekt

Allgemein

Profil

Redmine bitnami 2 5 2 2 » Historie » Version 1

Jeremias Keihsler, 11.01.2017 15:11

1 1 Jeremias Keihsler
h1. Redmine bitnami 2 5 2 2
2
3
h1. Install
4
5
https://bitnami.com/stack/redmine/installer
6
7
h1. Migrate
8
9
http://wiki.bitnami.com/Applications/BitNami_Redmine
10
11
h1. Config
12
13
h2. setup email
14
15
add following parameter to @/opt/redmine-2.5.2-2/apps/redmine/htdocs/config/configuration.yml@
16
17
<pre><code class="ruby">
18
# about line 83
19
# default configuration options for all environments
20
default:
21
  # Outgoing emails configuration (see examples above)
22
  email_delivery:
23
    delivery_method: :smtp
24
    smtp_settings:
25
 
26
      address: "mail.example.com"
27
      port: 25
28
      domain: 'example.com'
29
      authentication: :login
30
      user_name: "redmine@example.com"
31
      password: "secret"
32
      enable_starttls_auto: true
33
      #openssl_verify_mode: 'none'
34
      #enable_starttls_auto: true
35
</code></pre>
36
37
h2. setup receiving email
38
39
add following shell-script to @/usr/local/bin/redmine_recv_mail.sh@
40
41
<pre><code class="bash">
42
#!/bin/sh
43
 
44
PATH="/opt/redmine-2.5.2-2/perl/bin:/opt/redmine-2.5.2-2/git/bin:/opt/redmine-2.5.2-2/sqlite/bin:/opt/redmine-2.5.2-2/ruby/bin:/opt/redmine-2.5.2-2/subversion/bin:/opt/redmine-2.5.2-2/postgresql/bin:/opt/redmine-2.5.2-2/php/bin:/opt/redmine-2.5.2-2/mysql/bin:/opt/redmine-2.5.2-2/apache2/bin:/opt/redmine-2.5.2-2/common/bin:$PATH"
45
 
46
/opt/redmine-2.5.2-2/ruby/bin/rake -f '/opt/redmine-2.5.2-2/apps/redmine/htdocs/Rakefile' redmine:email:receive_imap RAILS_ENV="production" ssl=1 host=mail.example.com port=993 username=redmine@example.com password=secret unknown_user=create no_permission_check=1 
47
</code></pre>
48
49
 this setup will accept mails from everyone and automagically register unknown users.
50
51
add following cron-file @/etc/cron.d/redmine_mail_recv@
52
53
<pre><code class="bash">
54
 */15 * * * * root /usr/local/bin/redmine_recv_mail.sh
55
</code></pre>
56
57
if you get an error about bundle you may want to try 
58
59
<pre><code class="bash">
60
cd /opt/redmine-2.5.2-2
61
./use_redmine
62
gem install rake -v 10.1.1
63
</code></pre>
64
65
if you get an error about SSL-certificate (self signed) you may bypass SSL-verify by adding this file to @/opt/redmine-2.5.2-2/apps/redmine/htdocs/config/initializers/avoid_ssl_verification.rb@
66
67
<pre><code class="ruby">
68
    require 'openssl'
69
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
70
</code></pre>
71
72
h2. setup log-rotating
73
74
The Bitnami-Stack does not preconfigure log-rotating for the @production.log@ located in @/opt/redmine-2.5.2-2/apps/redmine/htdocs/log@. Although you could use the standard Logrotate it's recommended (http://www.redmine.org/boards/2/topics/11836) to use the Ruby-functionality. Add following parameter to @/opt/redmine-2.5.2-2/apps/redmine/htdocs/config/environments/production.rb@ and restart the Bitnami-Stack. 
75
76
According to http://www.redmine.org/issues/11603 you have to provide a file directly to @Logger.new@ instead of the sample in the @production.rb@.
77
78
<pre><code class="ruby">
79
# 7 log-files, 20MB each
80
config.logger = Logger.new('/opt/redmine-2.5.2-2/apps/redmine/htdocs/log/production.log', 7, 20971520)
81
config.logger.level = Logger::INFO
82
</code></pre>
83
84
<pre><code class="bash">
85
ll /opt/redmine-2.5.2-2/apps/redmine/htdocs/log/
86
</code></pre>
87
88
<pre><code class="bash">
89
total 1504
90
-rwxrwxr-x. 1 root   daemon      36 Jul  6 14:44 delete.me
91
-rw-r--r--. 1 daemon daemon    3295 Sep 20 10:55 production.log
92
-rwxrwxr-x. 1 root   daemon 1523773 Sep 20 10:52 production.log.0
93
</code></pre>
94
95
h2. setup Redmine-Logo
96
97
http://www.redmine.org/projects/redmine/wiki/Howto_add_a_logo_to_your_Redmine_banner
98
99
edit following file @/opt/redmine-2.5.2-2/apps/redmine/htdocs/app/views/layouts/base.html.erb@
100
101
<pre><code class="html">
102
#line 44
103
<h1><img src="<%= Redmine::Utils.relative_url_root %>/images/logo.png" style="top-margin: 15px; left-margin: 15px;"/> <%= page_header_title %></h1>
104
</code></pre>
105
106
copy @logo.png@ to @/opt/redmine-2.5.2-2/apps/redmine/htdocs/public/images@
107
108
h1. Nagging
109
110
There are a couple of plugins available, we are trying to do our own thing. 
111
112
h2. create a read only user
113
114
<pre><code class="sql">
115
mysql -u root -p
116
grant select on bitnami_redmine.* to 'redmine_reader'@'localhost';
117
</code></pre>
118
119
h2. create a sql-statement
120
121
http://www.redmine.org/projects/redmine/wiki/DatabaseModel
122
!Redmine_2_5_2_2_ER-databasemodel.png!
123
124
This statement lists all open issues from the project with the internal ID 33 and all sub-projects with a due-date earlier than today+7days. All issue-IDs will be click-able links in the nag-mail. 
125
126
<pre><code class="sql">
127
SELECT CONCAT('@@@1@http://www.example.com/redmine/issues/',_i.id,'@@@2@',_i.id,'@@@3@') AS ID,_is.name AS STATUS,_p.name AS Projekt ,LEFT(_i.subject,100) AS Thema,_i.due_date AS Zieldatum,_u.mail 
128
FROM (SELECT DISTINCT _b.id,_b.name 
129
      FROM (SELECT _p.name,_p.id 
130
            FROM projects AS _p 
131
            WHERE _p.id=33 OR _p.parent_id=33
132
           ) AS pp, projects AS _b 
133
      WHERE _b.parent_id=pp.id OR _b.id=33 ORDER BY _b.name
134
     ) AS _p,
135
     issues AS _i, 
136
     issue_statuses AS _is , 
137
     users AS _u 
138
WHERE _p.id = _i.project_id AND _i.status_id=_is.id AND _u.id=_i.assigned_to_id AND _is.is_closed=0 AND _i.due_date<=ADDDATE(curdate(),7) 
139
ORDER BY _p.name,_i.id;
140
</code></pre>
141
142
the funny @@@n@ groups are used later on.
143
144
h2. create a html-mail
145
146
create a little shell-sript @redmine_send_mail.sh@ that
147
* fetches the data from the database
148
* forms a valid html-mail
149
* sends the mail to one recipient
150
151
<pre><code class="bash">
152
#!/bin/sh
153
154
PATH="/opt/redmine-2.5.2-2/perl/bin:/opt/redmine-2.5.2-2/git/bin:/opt/redmine-2.5.2-2/sqlite/bin:/opt/redmine-2.5.2-2/ruby/bin:/opt/redmine-2.5.2-2/subversion/bin:/opt/redmine-2.5.2-2/postgresql/bin:/opt/redmine-2.5.2-2/php/bin:/opt/redmine-2.5.2-2/mysql/bin:/opt/redmine-2.5.2-2/apache2/bin:/opt/redmine-2.5.2-2/common/bin:$PATH"
155
156
#export List from DB
157
mysql -u redmine_reader -H -B bitnami_redmine < list.sql > /tmp/redmine_mysql_output
158
159
#replace special stuff
160
sed -i -e 's/@@@1@/<a href="/g' /tmp/redmine_mysql_output
161
sed -i -e 's/@@@2@/">/g' /tmp/redmine_mysql_output
162
sed -i -e 's/@@@3@/<\/a>/g' /tmp/redmine_mysql_output
163
164
echo 'Subject: weekly audit "all open issues due within the next 7 days"' > /tmp/redmine_mail_raw
165
echo 'to: user@example.com' >> /tmp/redmine_mail_raw
166
echo 'MIME-Version: 1.0' >> /tmp/redmine_mail_raw
167
echo 'Content-Type: text/html; charset=utf-8' >> /tmp/redmine_mail_raw
168
169
echo '' >> /tmp/redmine_mail_raw
170
echo '<html>' >> /tmp/redmine_mail_raw
171
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' >> /tmp/redmine_mail_raw
172
173
#export List from DB
174
cat /tmp/redmine_mysql_output >> /tmp/redmine_mail_raw
175
echo '</html>' >> /tmp/redmine_mail_raw
176
177
#send mail
178
cat /tmp/redmine_mail_raw | sendmail -t
179
</code></pre>
180
181
h2. use cron to nag periodically
182
183
run the shell-script from above every monday at 8:00am. @/etc/cron.d/redmine_audit@
184
185
<pre><code class="bash">
186
# JKE 2014-10-22
187
#
188
# minute hour day month dayofweek
189
# m h d m d
190
# - - - - -
191
# | | | | |
192
# | | | | +-day of week (0-7) sunday=0 or 7
193
# | | | +---month (1-12)
194
# | | +-----day of month (1-31)
195
# | +-------hour (0-23)
196
# +---------min (0-59)
197
# 
198
	00	08	*	*	1	root	/usr/local/bin/redmine_send_mail.sh
199
</code></pre>