Redmine bitnami 3 4 4 1 » Historie » Version 2
Jeremias Keihsler, 14.02.2018 15:00
1 | 1 | Jeremias Keihsler | h1. Bitnami Redmine 3.4.4-1 |
---|---|---|---|
2 | |||
3 | h2. setup receiving email |
||
4 | |||
5 | add following shell-script to @/usr/local/bin/redmine_recv_mail.sh@ |
||
6 | |||
7 | <pre><code class="bash"> |
||
8 | |||
9 | #to make this work I also had to do following things: |
||
10 | # |
||
11 | # cd /opt/redmine-2.5.2-2 |
||
12 | # ./use_redmine |
||
13 | # gem install rake -v 10.1.1 |
||
14 | # |
||
15 | #add following file to |
||
16 | |||
17 | PATH="/opt/redmine-3.4.4-1/perl/bin:/opt/redmine-3.4.4-1/git/bin:/opt/redmine-3.4.4-1/sqlite/bin:/opt/redmine-3.4.4-1/ruby/bin:/opt/redmine-3.4.4-1/subversion/bin:/opt/redmine-3.4.4-1/postgresql/bin:/opt/redmine-3.4.4-1/php/bin:/opt/redmine-3.4.4-1/mysql/bin:/opt/redmine-3.4.4-1/apache2/bin:/opt/redmine-3.4.4-1/common/bin:$PATH" |
||
18 | BITNAMI_ROOT="/opt/redmine-3.4.4-1" |
||
19 | export BITNAMI_ROOT |
||
20 | |||
21 | cd /opt/redmine-3.4.4-1/apps/redmine/htdocs |
||
22 | bundle exec rake redmine:email:receive_imap RAILS_ENV="production" ssl=true host=mail.example.com port=993 username=redmine@example.com password=mySecret4711 unknown_user=create no_permission_check=1 |
||
23 | </code></pre> |
||
24 | |||
25 | this setup will accept mails from everyone and automagically register unknown users. |
||
26 | |||
27 | add following cron-file @/etc/cron.d/redmine_mail_recv@ |
||
28 | |||
29 | <pre><code class="bash"> |
||
30 | */15 * * * * root /usr/local/bin/redmine_recv_mail.sh |
||
31 | </code></pre> |
||
32 | |||
33 | 2 | Jeremias Keihsler | if you get an error about SSL-certificate (self signed) you may bypass SSL-verify by adding this file to @/opt/redmine-3.4.4-1/apps/redmine/htdocs/config/initializers/avoid_ssl_verification.rb@ |
34 | 1 | Jeremias Keihsler | |
35 | <pre><code class="ruby"> |
||
36 | require 'openssl' |
||
37 | OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE |
||
38 | </code></pre> |
||
39 | |||
40 | h2. Troubleshoot imap |
||
41 | 2 | Jeremias Keihsler | |
42 | if you did the above change, then this shouldn't be necessary. For me this is giving me |
||
43 | @/opt/redmine-3.4.4-1/apps/redmine/htdocs/config/initializers/avoid_ssl_verification.rb:4: warning: already initialized constant OpenSSL::SSL::VERIFY_PEER@ therefore I go for the change below. |
||
44 | 1 | Jeremias Keihsler | |
45 | change @/opt/redmine-3.4.4-1/ruby/lib/ruby/2.0.0/net/imap.rb@ line ~1429 |
||
46 | |||
47 | <pre><code class="ruby"> |
||
48 | def create_ssl_params(certs = nil, verify = true) |
||
49 | params = {} |
||
50 | if certs |
||
51 | if File.file?(certs) |
||
52 | params[:ca_file] = certs |
||
53 | elsif File.directory?(certs) |
||
54 | params[:ca_path] = certs |
||
55 | end |
||
56 | end |
||
57 | if verify |
||
58 | # params[:verify_mode] = VERIFY_PEER |
||
59 | # taken out by JKE 2015-07-06 |
||
60 | params[:verify_mode] = VERIFY_NONE |
||
61 | else |
||
62 | params[:verify_mode] = VERIFY_NONE |
||
63 | end |
||
64 | return params |
||
65 | end |
||
66 | </code></pre> |
||
67 | |||
68 | h1. setup log-rotating |
||
69 | |||
70 | h2. Redmine |
||
71 | |||
72 | The Bitnami-Stack does not preconfigure log-rotating for the @production.log@ located in @/opt/redmine-3.4.4-1/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-3.4.4-1/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-3.0.3-0/apps/redmine/htdocs/log/production.log', 7, 20971520) |
||
79 | config.logger.level = Logger::INFO |
||
80 | </code></pre> |
||
81 | |||
82 | <pre> |
||
83 | [root@redmine ~]# cd /opt/redmine-3.4.4-1/apps/redmine/htdocs/log/ |
||
84 | [root@redmine log]# ll |
||
85 | total 1120 |
||
86 | -rwxrwxr-x. 1 root daemon 36 Jun 18 2012 delete.me |
||
87 | -rw-r--r--. 1 daemon daemon 12158 Jul 9 09:36 production.log |
||
88 | -rw-rw-r--. 1 root daemon 30053 Jul 9 09:28 production.log.0 |
||
89 | -rwxrwxr-x. 1 root daemon 1093571 Jul 9 08:59 production.log.1 |
||
90 | </pre> |
||
91 | |||
92 | h2. apache / mysql |
||
93 | |||
94 | let's use @logrotate@ for this task. There is @.conf@-files already shipped with the bitnami-stack. |
||
95 | https://docs.bitnami.com/installer/components/logrotate/ |
||
96 | |||
97 | <pre><code class="bash"> |
||
98 | ln -s /opt/redmine-3.4.4-1/config/logrotate/logrotate.d/apache.conf /etc/logrotate.d/bitnami_3.4.4-1_apache.conf |
||
99 | ln -s /opt/redmine-3.4.4-1/config/logrotate/logrotate.d/mysql.conf /etc/logrotate.d/bitnami_3.4.4-1_mysql.conf |
||
100 | </code></pre> |
||
101 | |||
102 | h2. setup Redmine-Logo |
||
103 | |||
104 | http://www.redmine.org/projects/redmine/wiki/Howto_add_a_logo_to_your_Redmine_banner |
||
105 | |||
106 | edit following file @/opt/redmine-3.4.4-1/apps/redmine/htdocs/app/views/layouts/base.html.erb@ |
||
107 | |||
108 | <pre><code class="html"> |
||
109 | #line 44 |
||
110 | <h1><img src="<%= Redmine::Utils.relative_url_root %>/images/logo.png" style="top-margin: 15px; left-margin: 15px;"/> <%= page_header_title %></h1> |
||
111 | </code></pre> |
||
112 | |||
113 | copy @logo.png@ to @/opt/redmine-3.4.4-1/apps/redmine/htdocs/public/images@ |
||
114 | |||
115 | h1. setup service |
||
116 | |||
117 | add following service-unit @/etc/systemd/system/bitnami-redmine.service@ |
||
118 | |||
119 | <pre><code class="ini"> |
||
120 | [Unit] |
||
121 | Description=run bitnami redmine |
||
122 | After=network.target |
||
123 | |||
124 | [Service] |
||
125 | Type=oneshot |
||
126 | RemainAfterExit=yes |
||
127 | ExecStart=/opt/redmine-3.4.4-1/ctlscript.sh start |
||
128 | ExecStop=/opt/redmine-3.4.4-1/ctlscript.sh stop |
||
129 | |||
130 | [Install] |
||
131 | WantedBy=multi-user.target |
||
132 | </code></pre> |
||
133 | |||
134 | enable the unit by |
||
135 | |||
136 | <pre><code class="bash"> |
||
137 | systemctl enable bitnami-redmine |
||
138 | </code></pre> |
||
139 | |||
140 | |||
141 | h1. Nagging |
||
142 | |||
143 | There are a couple of plugins available, we are trying to do our own thing. |
||
144 | |||
145 | h2. create a read only user |
||
146 | |||
147 | <pre><code class="sql"> |
||
148 | mysql -u root -p |
||
149 | grant select on bitnami_redmine.* to 'redmine_reader'@'localhost'; |
||
150 | </code></pre> |
||
151 | |||
152 | h2. create a sql-statement |
||
153 | |||
154 | http://www.redmine.org/projects/redmine/wiki/DatabaseModel |
||
155 | !Redmine_2_5_2_2_ER-databasemodel.png! |
||
156 | |||
157 | 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. |
||
158 | |||
159 | <pre><code class="sql"> |
||
160 | 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, _e.address AS mail |
||
161 | FROM (SELECT DISTINCT _b.id,_b.name |
||
162 | FROM (SELECT _p.name,_p.id |
||
163 | FROM projects AS _p |
||
164 | WHERE _p.id=33 OR _p.parent_id=33 |
||
165 | ) AS pp, projects AS _b |
||
166 | WHERE _b.parent_id=pp.id OR _b.id=33 ORDER BY _b.name |
||
167 | ) AS _p, |
||
168 | issues AS _i, |
||
169 | issue_statuses AS _is , |
||
170 | users AS _u, |
||
171 | email_addresses AS _e |
||
172 | WHERE _p.id = _i.project_id |
||
173 | AND _i.status_id=_is.id |
||
174 | AND _u.id=_i.assigned_to_id |
||
175 | AND _u.id=_e.user_id |
||
176 | AND _is.is_closed=0 |
||
177 | AND _i.due_date<=ADDDATE(curdate(),7) |
||
178 | ORDER BY _p.name,_i.id; |
||
179 | </code></pre> |
||
180 | |||
181 | the funny @@@n@ groups are used later on. |
||
182 | |||
183 | h2. create a html-mail |
||
184 | |||
185 | create a little shell-sript @redmine_send_mail.sh@ that |
||
186 | * fetches the data from the database |
||
187 | * forms a valid html-mail |
||
188 | * sends the mail to one recipient |
||
189 | |||
190 | <pre><code class="bash"> |
||
191 | #!/bin/sh |
||
192 | |||
193 | PATH="/opt/redmine-3.4.4-1/perl/bin:/opt/redmine-3.4.4-1/git/bin:/opt/redmine-3.4.4-1/sqlite/bin:/opt/redmine-3.4.4-1/ruby/bin:/opt/redmine-3.4.4-1/subversion/bin:/opt/redmine-3.4.4-1/postgresql/bin:/opt/redmine-3.4.4-1/php/bin:/opt/redmine-3.4.4-1/mysql/bin:/opt/redmine-3.4.4-1/apache2/bin:/opt/redmine-3.4.4-1/common/bin:$PATH" |
||
194 | |||
195 | #export List from DB |
||
196 | mysql -u redmine_reader -H -B bitnami_redmine < list.sql > /tmp/redmine_mysql_output |
||
197 | |||
198 | #replace special stuff |
||
199 | sed -i -e 's/@@@1@/<a href="/g' /tmp/redmine_mysql_output |
||
200 | sed -i -e 's/@@@2@/">/g' /tmp/redmine_mysql_output |
||
201 | sed -i -e 's/@@@3@/<\/a>/g' /tmp/redmine_mysql_output |
||
202 | |||
203 | echo 'Subject: weekly audit "all open issues due within the next 7 days"' > /tmp/redmine_mail_raw |
||
204 | echo 'to: user@example.com' >> /tmp/redmine_mail_raw |
||
205 | echo 'MIME-Version: 1.0' >> /tmp/redmine_mail_raw |
||
206 | echo 'Content-Type: text/html; charset=utf-8' >> /tmp/redmine_mail_raw |
||
207 | |||
208 | echo '' >> /tmp/redmine_mail_raw |
||
209 | echo '<html>' >> /tmp/redmine_mail_raw |
||
210 | echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' >> /tmp/redmine_mail_raw |
||
211 | |||
212 | #export List from DB |
||
213 | cat /tmp/redmine_mysql_output >> /tmp/redmine_mail_raw |
||
214 | echo '</html>' >> /tmp/redmine_mail_raw |
||
215 | |||
216 | #send mail |
||
217 | cat /tmp/redmine_mail_raw | sendmail -t |
||
218 | </code></pre> |
||
219 | |||
220 | h2. use cron to nag periodically |
||
221 | |||
222 | run the shell-script from above every monday at 8:00am. @/etc/cron.d/redmine_audit@ |
||
223 | |||
224 | <pre><code class="bash"> |
||
225 | # JKE 2014-10-22 |
||
226 | # |
||
227 | # minute hour day month dayofweek |
||
228 | # m h d m d |
||
229 | # - - - - - |
||
230 | # | | | | | |
||
231 | # | | | | +-day of week (0-7) sunday=0 or 7 |
||
232 | # | | | +---month (1-12) |
||
233 | # | | +-----day of month (1-31) |
||
234 | # | +-------hour (0-23) |
||
235 | # +---------min (0-59) |
||
236 | # |
||
237 | 00 08 * * 1 root /usr/local/bin/redmine_send_mail.sh |
||
238 | </code></pre> |