Redmine bitnami 4 1 1 4 » Historie » Version 1
Jeremias Keihsler, 04.09.2020 11:02
1 | 1 | Jeremias Keihsler | h1. Bitnami Redmine 4.1.4-4 |
---|---|---|---|
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 | 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 | |||
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 | |||
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 | |||
45 | change @/opt/redmine-3.4.4-1/ruby/lib/ruby/2.3.0/net/imap.rb@ line ~1456 |
||
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.4.4-1/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 89 |
||
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-4.1.1-4/ctlscript.sh start |
||
128 | ExecStop=/opt/redmine-4.1.1-4/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 | create user 'redmine_reader'@'localhost'; |
||
150 | grant select on bitnami_redmine.* to 'redmine_reader'@'localhost'; |
||
151 | flush privileges; |
||
152 | </code></pre> |
||
153 | |||
154 | h2. create a sql-statement |
||
155 | |||
156 | http://www.redmine.org/projects/redmine/wiki/DatabaseModel |
||
157 | !Redmine_2_5_2_2_ER-databasemodel.png! |
||
158 | |||
159 | 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. |
||
160 | |||
161 | <pre><code class="sql"> |
||
162 | 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 |
||
163 | FROM (SELECT DISTINCT _b.id,_b.name |
||
164 | FROM (SELECT _p.name,_p.id |
||
165 | FROM projects AS _p |
||
166 | WHERE _p.id=33 OR _p.parent_id=33 |
||
167 | ) AS pp, projects AS _b |
||
168 | WHERE _b.parent_id=pp.id OR _b.id=33 ORDER BY _b.name |
||
169 | ) AS _p, |
||
170 | issues AS _i, |
||
171 | issue_statuses AS _is , |
||
172 | users AS _u, |
||
173 | email_addresses AS _e |
||
174 | WHERE _p.id = _i.project_id |
||
175 | AND _i.status_id=_is.id |
||
176 | AND _u.id=_i.assigned_to_id |
||
177 | AND _u.id=_e.user_id |
||
178 | AND _is.is_closed=0 |
||
179 | AND _i.due_date<=ADDDATE(curdate(),7) |
||
180 | ORDER BY _p.name,_i.id; |
||
181 | </code></pre> |
||
182 | |||
183 | the funny @@@n@ groups are used later on. |
||
184 | |||
185 | h2. create a html-mail |
||
186 | |||
187 | create a little shell-sript @redmine_send_mail.sh@ that |
||
188 | * fetches the data from the database |
||
189 | * forms a valid html-mail |
||
190 | * sends the mail to one recipient |
||
191 | |||
192 | <pre><code class="bash"> |
||
193 | #!/bin/sh |
||
194 | |||
195 | 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" |
||
196 | |||
197 | #export List from DB |
||
198 | mysql -u redmine_reader -H -B bitnami_redmine < list.sql > /tmp/redmine_mysql_output |
||
199 | |||
200 | #replace special stuff |
||
201 | sed -i -e 's/@@@1@/<a href="/g' /tmp/redmine_mysql_output |
||
202 | sed -i -e 's/@@@2@/">/g' /tmp/redmine_mysql_output |
||
203 | sed -i -e 's/@@@3@/<\/a>/g' /tmp/redmine_mysql_output |
||
204 | |||
205 | echo 'Subject: weekly audit "all open issues due within the next 7 days"' > /tmp/redmine_mail_raw |
||
206 | echo 'to: user@example.com' >> /tmp/redmine_mail_raw |
||
207 | echo 'MIME-Version: 1.0' >> /tmp/redmine_mail_raw |
||
208 | echo 'Content-Type: text/html; charset=utf-8' >> /tmp/redmine_mail_raw |
||
209 | |||
210 | echo '' >> /tmp/redmine_mail_raw |
||
211 | echo '<html>' >> /tmp/redmine_mail_raw |
||
212 | echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' >> /tmp/redmine_mail_raw |
||
213 | |||
214 | #export List from DB |
||
215 | cat /tmp/redmine_mysql_output >> /tmp/redmine_mail_raw |
||
216 | echo '</html>' >> /tmp/redmine_mail_raw |
||
217 | |||
218 | #send mail |
||
219 | cat /tmp/redmine_mail_raw | sendmail -t |
||
220 | </code></pre> |
||
221 | |||
222 | h2. use cron to nag periodically |
||
223 | |||
224 | run the shell-script from above every monday at 8:00am. @/etc/cron.d/redmine_audit@ |
||
225 | |||
226 | <pre><code class="bash"> |
||
227 | # JKE 2014-10-22 |
||
228 | # |
||
229 | # minute hour day month dayofweek |
||
230 | # m h d m d |
||
231 | # - - - - - |
||
232 | # | | | | | |
||
233 | # | | | | +-day of week (0-7) sunday=0 or 7 |
||
234 | # | | | +---month (1-12) |
||
235 | # | | +-----day of month (1-31) |
||
236 | # | +-------hour (0-23) |
||
237 | # +---------min (0-59) |
||
238 | # |
||
239 | 00 08 * * 1 root /usr/local/bin/redmine_send_mail.sh |
||
240 | </code></pre> |