Redmine bitnami 4 1 1 4 » Historie » Version 4
Jeremias Keihsler, 04.09.2020 11:20
| 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 | https://docs.bitnami.com/installer/components/logrotate/ |
||
| 62 | |||
| 63 | <pre><code class="bash"> |
||
| 64 | 2 | Jeremias Keihsler | ln -s /opt/redmine-4.1.1-4/config/logrotate/logrotate.d/apache.conf /etc/logrotate.d/bitnami_4.1.1-4_apache.conf |
| 65 | ln -s /opt/redmine-4.1.1-4/config/logrotate/logrotate.d/mysql.conf /etc/logrotate.d/bitnami_4.1.1-4_mysql.conf |
||
| 66 | 1 | Jeremias Keihsler | </code></pre> |
| 67 | |||
| 68 | h2. setup Redmine-Logo |
||
| 69 | |||
| 70 | http://www.redmine.org/projects/redmine/wiki/Howto_add_a_logo_to_your_Redmine_banner |
||
| 71 | |||
| 72 | 2 | Jeremias Keihsler | edit following file @/opt/redmine-4.1.1-4/apps/redmine/htdocs/app/views/layouts/base.html.erb@ |
| 73 | 1 | Jeremias Keihsler | |
| 74 | <pre><code class="html"> |
||
| 75 | 3 | Jeremias Keihsler | #line 93 |
| 76 | 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> |
| 77 | </code></pre> |
||
| 78 | |||
| 79 | 2 | Jeremias Keihsler | copy @logo.png@ to @/opt/redmine-4.1.1-4/apps/redmine/htdocs/public/images@ |
| 80 | 1 | Jeremias Keihsler | |
| 81 | h1. setup service |
||
| 82 | |||
| 83 | add following service-unit @/etc/systemd/system/bitnami-redmine.service@ |
||
| 84 | |||
| 85 | <pre><code class="ini"> |
||
| 86 | [Unit] |
||
| 87 | Description=run bitnami redmine |
||
| 88 | After=network.target |
||
| 89 | |||
| 90 | [Service] |
||
| 91 | Type=oneshot |
||
| 92 | RemainAfterExit=yes |
||
| 93 | ExecStart=/opt/redmine-4.1.1-4/ctlscript.sh start |
||
| 94 | ExecStop=/opt/redmine-4.1.1-4/ctlscript.sh stop |
||
| 95 | |||
| 96 | [Install] |
||
| 97 | WantedBy=multi-user.target |
||
| 98 | </code></pre> |
||
| 99 | |||
| 100 | enable the unit by |
||
| 101 | |||
| 102 | <pre><code class="bash"> |
||
| 103 | systemctl enable bitnami-redmine |
||
| 104 | </code></pre> |
||
| 105 | |||
| 106 | |||
| 107 | h1. Nagging |
||
| 108 | |||
| 109 | There are a couple of plugins available, we are trying to do our own thing. |
||
| 110 | |||
| 111 | h2. create a read only user |
||
| 112 | |||
| 113 | <pre><code class="sql"> |
||
| 114 | mysql -u root -p |
||
| 115 | create user 'redmine_reader'@'localhost'; |
||
| 116 | grant select on bitnami_redmine.* to 'redmine_reader'@'localhost'; |
||
| 117 | flush privileges; |
||
| 118 | </code></pre> |
||
| 119 | |||
| 120 | h2. create a sql-statement |
||
| 121 | |||
| 122 | http://www.redmine.org/projects/redmine/wiki/DatabaseModel |
||
| 123 | !Redmine_2_5_2_2_ER-databasemodel.png! |
||
| 124 | |||
| 125 | 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. |
||
| 126 | |||
| 127 | <pre><code class="sql"> |
||
| 128 | 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 |
||
| 129 | FROM (SELECT DISTINCT _b.id,_b.name |
||
| 130 | FROM (SELECT _p.name,_p.id |
||
| 131 | FROM projects AS _p |
||
| 132 | WHERE _p.id=33 OR _p.parent_id=33 |
||
| 133 | ) AS pp, projects AS _b |
||
| 134 | WHERE _b.parent_id=pp.id OR _b.id=33 ORDER BY _b.name |
||
| 135 | ) AS _p, |
||
| 136 | issues AS _i, |
||
| 137 | issue_statuses AS _is , |
||
| 138 | users AS _u, |
||
| 139 | email_addresses AS _e |
||
| 140 | WHERE _p.id = _i.project_id |
||
| 141 | AND _i.status_id=_is.id |
||
| 142 | AND _u.id=_i.assigned_to_id |
||
| 143 | AND _u.id=_e.user_id |
||
| 144 | AND _is.is_closed=0 |
||
| 145 | AND _i.due_date<=ADDDATE(curdate(),7) |
||
| 146 | ORDER BY _p.name,_i.id; |
||
| 147 | </code></pre> |
||
| 148 | |||
| 149 | the funny @@@n@ groups are used later on. |
||
| 150 | |||
| 151 | h2. create a html-mail |
||
| 152 | |||
| 153 | create a little shell-sript @redmine_send_mail.sh@ that |
||
| 154 | * fetches the data from the database |
||
| 155 | * forms a valid html-mail |
||
| 156 | * sends the mail to one recipient |
||
| 157 | |||
| 158 | <pre><code class="bash"> |
||
| 159 | #!/bin/sh |
||
| 160 | |||
| 161 | 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" |
| 162 | 1 | Jeremias Keihsler | |
| 163 | #export List from DB |
||
| 164 | mysql -u redmine_reader -H -B bitnami_redmine < list.sql > /tmp/redmine_mysql_output |
||
| 165 | |||
| 166 | #replace special stuff |
||
| 167 | sed -i -e 's/@@@1@/<a href="/g' /tmp/redmine_mysql_output |
||
| 168 | sed -i -e 's/@@@2@/">/g' /tmp/redmine_mysql_output |
||
| 169 | sed -i -e 's/@@@3@/<\/a>/g' /tmp/redmine_mysql_output |
||
| 170 | |||
| 171 | echo 'Subject: weekly audit "all open issues due within the next 7 days"' > /tmp/redmine_mail_raw |
||
| 172 | echo 'to: user@example.com' >> /tmp/redmine_mail_raw |
||
| 173 | echo 'MIME-Version: 1.0' >> /tmp/redmine_mail_raw |
||
| 174 | echo 'Content-Type: text/html; charset=utf-8' >> /tmp/redmine_mail_raw |
||
| 175 | |||
| 176 | echo '' >> /tmp/redmine_mail_raw |
||
| 177 | echo '<html>' >> /tmp/redmine_mail_raw |
||
| 178 | echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' >> /tmp/redmine_mail_raw |
||
| 179 | |||
| 180 | #export List from DB |
||
| 181 | cat /tmp/redmine_mysql_output >> /tmp/redmine_mail_raw |
||
| 182 | echo '</html>' >> /tmp/redmine_mail_raw |
||
| 183 | |||
| 184 | #send mail |
||
| 185 | cat /tmp/redmine_mail_raw | sendmail -t |
||
| 186 | </code></pre> |
||
| 187 | |||
| 188 | h2. use cron to nag periodically |
||
| 189 | |||
| 190 | run the shell-script from above every monday at 8:00am. @/etc/cron.d/redmine_audit@ |
||
| 191 | |||
| 192 | <pre><code class="bash"> |
||
| 193 | # JKE 2014-10-22 |
||
| 194 | # |
||
| 195 | # minute hour day month dayofweek |
||
| 196 | # m h d m d |
||
| 197 | # - - - - - |
||
| 198 | # | | | | | |
||
| 199 | # | | | | +-day of week (0-7) sunday=0 or 7 |
||
| 200 | # | | | +---month (1-12) |
||
| 201 | # | | +-----day of month (1-31) |
||
| 202 | # | +-------hour (0-23) |
||
| 203 | # +---------min (0-59) |
||
| 204 | # |
||
| 205 | 00 08 * * 1 root /usr/local/bin/redmine_send_mail.sh |
||
| 206 | </code></pre> |