Projekt

Allgemein

Profil

Redmine bitnami 2 5 2 2 » Historie » Version 2

Jeremias Keihsler, 11.01.2017 15:13

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