Redmine bitnami 4 1 1 4 » Historie » Version 6
Jeremias Keihsler, 04.09.2020 11:27
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 | 2 | Jeremias Keihsler | PATH="/opt/redmine-4.1.1-4/perl/bin:/opt/redmine-4.1.1-4/git/bin:/opt/redmine-4.1.1-4/sqlite/bin:/opt/redmine-4.1.1-4/ruby/bin:/opt/redmine-4.1.1-4/subversion/bin:/opt/redmine-4.1.1-4/postgresql/bin:/opt/redmine-4.1.1-4/php/bin:/opt/redmine-4.1.1-4/mysql/bin:/opt/redmine-4.1.1-4/apache2/bin:/opt/redmine-4.1.1-4/common/bin:$PATH" |
18 | BITNAMI_ROOT="/opt/redmine-4.1.1-4" |
||
19 | 1 | Jeremias Keihsler | export BITNAMI_ROOT |
20 | |||
21 | 2 | Jeremias Keihsler | cd /opt/redmine-4.1.1-4/apps/redmine/htdocs |
22 | 1 | Jeremias Keihsler | 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 | |||
34 | h1. setup log-rotating |
||
35 | |||
36 | h2. Redmine |
||
37 | |||
38 | 4 | Jeremias Keihsler | The Bitnami-Stack does not preconfigure log-rotating for the @production.log@ located in @/opt/redmine-4.1.1-4/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-4.1.1-4/apps/redmine/htdocs/config/environments/production.rb@ and restart the Bitnami-Stack. |
39 | 1 | Jeremias Keihsler | |
40 | 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@. |
||
41 | |||
42 | <pre><code class="ruby"> |
||
43 | # 7 log-files, 20MB each |
||
44 | 4 | Jeremias Keihsler | config.logger = Logger.new('/opt/redmine-4.1.1-4/apps/redmine/htdocs/log/production.log', 7, 20971520) |
45 | 1 | Jeremias Keihsler | config.logger.level = Logger::INFO |
46 | </code></pre> |
||
47 | |||
48 | <pre> |
||
49 | 2 | Jeremias Keihsler | [root@redmine ~]# cd /opt/redmine-4.1.1-4/apps/redmine/htdocs/log/ |
50 | 1 | Jeremias Keihsler | [root@redmine log]# ll |
51 | total 1120 |
||
52 | -rwxrwxr-x. 1 root daemon 36 Jun 18 2012 delete.me |
||
53 | -rw-r--r--. 1 daemon daemon 12158 Jul 9 09:36 production.log |
||
54 | -rw-rw-r--. 1 root daemon 30053 Jul 9 09:28 production.log.0 |
||
55 | -rwxrwxr-x. 1 root daemon 1093571 Jul 9 08:59 production.log.1 |
||
56 | </pre> |
||
57 | |||
58 | h2. apache / mysql |
||
59 | |||
60 | let's use @logrotate@ for this task. There is @.conf@-files already shipped with the bitnami-stack. |
||
61 | 5 | Jeremias Keihsler | https://docs.bitnami.com/installer/apps/redmine/administration/configure-use-logrotate/ |
62 | 1 | Jeremias Keihsler | |
63 | <pre><code class="bash"> |
||
64 | 6 | Jeremias Keihsler | ln -s /opt/redmine-4.1.1-4/config/logrotate/bitnami.conf /etc/logrotate.d/bitnami.conf |
65 | 1 | Jeremias Keihsler | </code></pre> |
66 | 6 | Jeremias Keihsler | |
67 | |||
68 | 1 | Jeremias Keihsler | |
69 | h2. setup Redmine-Logo |
||
70 | |||
71 | http://www.redmine.org/projects/redmine/wiki/Howto_add_a_logo_to_your_Redmine_banner |
||
72 | |||
73 | 2 | Jeremias Keihsler | edit following file @/opt/redmine-4.1.1-4/apps/redmine/htdocs/app/views/layouts/base.html.erb@ |
74 | 1 | Jeremias Keihsler | |
75 | <pre><code class="html"> |
||
76 | 3 | Jeremias Keihsler | #line 93 |
77 | 1 | Jeremias Keihsler | <h1><img src="<%= Redmine::Utils.relative_url_root %>/images/logo.png" style="top-margin: 15px; left-margin: 15px;"/> <%= page_header_title %></h1> |
78 | </code></pre> |
||
79 | |||
80 | 2 | Jeremias Keihsler | copy @logo.png@ to @/opt/redmine-4.1.1-4/apps/redmine/htdocs/public/images@ |
81 | 1 | Jeremias Keihsler | |
82 | h1. setup service |
||
83 | |||
84 | add following service-unit @/etc/systemd/system/bitnami-redmine.service@ |
||
85 | |||
86 | <pre><code class="ini"> |
||
87 | [Unit] |
||
88 | Description=run bitnami redmine |
||
89 | After=network.target |
||
90 | |||
91 | [Service] |
||
92 | Type=oneshot |
||
93 | RemainAfterExit=yes |
||
94 | ExecStart=/opt/redmine-4.1.1-4/ctlscript.sh start |
||
95 | ExecStop=/opt/redmine-4.1.1-4/ctlscript.sh stop |
||
96 | |||
97 | [Install] |
||
98 | WantedBy=multi-user.target |
||
99 | </code></pre> |
||
100 | |||
101 | enable the unit by |
||
102 | |||
103 | <pre><code class="bash"> |
||
104 | systemctl enable bitnami-redmine |
||
105 | </code></pre> |
||
106 | |||
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 | create user 'redmine_reader'@'localhost'; |
||
117 | grant select on bitnami_redmine.* to 'redmine_reader'@'localhost'; |
||
118 | flush privileges; |
||
119 | </code></pre> |
||
120 | |||
121 | h2. create a sql-statement |
||
122 | |||
123 | http://www.redmine.org/projects/redmine/wiki/DatabaseModel |
||
124 | !Redmine_2_5_2_2_ER-databasemodel.png! |
||
125 | |||
126 | 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. |
||
127 | |||
128 | <pre><code class="sql"> |
||
129 | 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 |
||
130 | FROM (SELECT DISTINCT _b.id,_b.name |
||
131 | FROM (SELECT _p.name,_p.id |
||
132 | FROM projects AS _p |
||
133 | WHERE _p.id=33 OR _p.parent_id=33 |
||
134 | ) AS pp, projects AS _b |
||
135 | WHERE _b.parent_id=pp.id OR _b.id=33 ORDER BY _b.name |
||
136 | ) AS _p, |
||
137 | issues AS _i, |
||
138 | issue_statuses AS _is , |
||
139 | users AS _u, |
||
140 | email_addresses AS _e |
||
141 | WHERE _p.id = _i.project_id |
||
142 | AND _i.status_id=_is.id |
||
143 | AND _u.id=_i.assigned_to_id |
||
144 | AND _u.id=_e.user_id |
||
145 | AND _is.is_closed=0 |
||
146 | AND _i.due_date<=ADDDATE(curdate(),7) |
||
147 | ORDER BY _p.name,_i.id; |
||
148 | </code></pre> |
||
149 | |||
150 | the funny @@@n@ groups are used later on. |
||
151 | |||
152 | h2. create a html-mail |
||
153 | |||
154 | create a little shell-sript @redmine_send_mail.sh@ that |
||
155 | * fetches the data from the database |
||
156 | * forms a valid html-mail |
||
157 | * sends the mail to one recipient |
||
158 | |||
159 | <pre><code class="bash"> |
||
160 | #!/bin/sh |
||
161 | |||
162 | 2 | Jeremias Keihsler | PATH="/opt/redmine-4.1.1-4/perl/bin:/opt/redmine-4.1.1-4/git/bin:/opt/redmine-4.1.1-4/sqlite/bin:/opt/redmine-4.1.1-4/ruby/bin:/opt/redmine-4.1.1-4/subversion/bin:/opt/redmine-4.1.1-4/postgresql/bin:/opt/redmine-4.1.1-4/php/bin:/opt/redmine-4.1.1-4/mysql/bin:/opt/redmine-4.1.1-4/apache2/bin:/opt/redmine-4.1.1-4/common/bin:$PATH" |
163 | 1 | Jeremias Keihsler | |
164 | #export List from DB |
||
165 | mysql -u redmine_reader -H -B bitnami_redmine < list.sql > /tmp/redmine_mysql_output |
||
166 | |||
167 | #replace special stuff |
||
168 | sed -i -e 's/@@@1@/<a href="/g' /tmp/redmine_mysql_output |
||
169 | sed -i -e 's/@@@2@/">/g' /tmp/redmine_mysql_output |
||
170 | sed -i -e 's/@@@3@/<\/a>/g' /tmp/redmine_mysql_output |
||
171 | |||
172 | echo 'Subject: weekly audit "all open issues due within the next 7 days"' > /tmp/redmine_mail_raw |
||
173 | echo 'to: user@example.com' >> /tmp/redmine_mail_raw |
||
174 | echo 'MIME-Version: 1.0' >> /tmp/redmine_mail_raw |
||
175 | echo 'Content-Type: text/html; charset=utf-8' >> /tmp/redmine_mail_raw |
||
176 | |||
177 | echo '' >> /tmp/redmine_mail_raw |
||
178 | echo '<html>' >> /tmp/redmine_mail_raw |
||
179 | echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' >> /tmp/redmine_mail_raw |
||
180 | |||
181 | #export List from DB |
||
182 | cat /tmp/redmine_mysql_output >> /tmp/redmine_mail_raw |
||
183 | echo '</html>' >> /tmp/redmine_mail_raw |
||
184 | |||
185 | #send mail |
||
186 | cat /tmp/redmine_mail_raw | sendmail -t |
||
187 | </code></pre> |
||
188 | |||
189 | h2. use cron to nag periodically |
||
190 | |||
191 | run the shell-script from above every monday at 8:00am. @/etc/cron.d/redmine_audit@ |
||
192 | |||
193 | <pre><code class="bash"> |
||
194 | # JKE 2014-10-22 |
||
195 | # |
||
196 | # minute hour day month dayofweek |
||
197 | # m h d m d |
||
198 | # - - - - - |
||
199 | # | | | | | |
||
200 | # | | | | +-day of week (0-7) sunday=0 or 7 |
||
201 | # | | | +---month (1-12) |
||
202 | # | | +-----day of month (1-31) |
||
203 | # | +-------hour (0-23) |
||
204 | # +---------min (0-59) |
||
205 | # |
||
206 | 00 08 * * 1 root /usr/local/bin/redmine_send_mail.sh |
||
207 | </code></pre> |