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