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