Projekt

Allgemein

Profil

Redmine bitnami 4 1 1 4 » Historie » Revision 7

Revision 6 (Jeremias Keihsler, 04.09.2020 11:27) → Revision 7/8 (Jeremias Keihsler, 01.09.2021 10:05)

h1. Bitnami Redmine 4.1.4-4 

 h2. setup receiving email 

 add following shell-script to @/usr/local/bin/redmine_recv_mail.sh@ 

 <pre><code class="bash"> 

 #to make this work I also had to do following things: 
 # 
 #    cd /opt/redmine-2.5.2-2 
 #    ./use_redmine 
 #    gem install rake -v 10.1.1 
 # 
 #add following file to  

 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" 
 BITNAMI_ROOT="/opt/redmine-4.1.1-4" 
 export BITNAMI_ROOT 

 cd /opt/redmine-4.1.1-4/apps/redmine/htdocs 
 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 
 </code></pre> 

  this setup will accept mails from everyone and automagically register unknown users. 

 add following cron-file @/etc/cron.d/redmine_mail_recv@ 

 <pre><code class="bash"> 
  */15 * * * * root /usr/local/bin/redmine_recv_mail.sh 
 </code></pre> 

 h1. Config 

 h2. setup email 

 add following parameter to @/opt/redmine-4.1.1-4/apps/redmine/htdocs/config/configuration.yml@ 

 <pre><code class="ruby"> 
 # about line 15 
 # default configuration options for all environments 
 default: 
   # Outgoing emails configuration (see examples below) 
   email_delivery: 
     delivery_method: :smtp 
     smtp_settings: 
 
       address: mail.example.com 
       port: 587 
       domain: example.com 
       authentication: :login 
       user_name: redmine@example.com 
       password: secret 

 </code></pre> 


 h1. setup log-rotating 

 

 h2. Redmine 

 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. 

 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@. 

 <pre><code class="ruby"> 
 # 7 log-files, 20MB each 
 config.logger = Logger.new('/opt/redmine-4.1.1-4/apps/redmine/htdocs/log/production.log', 7, 20971520) 
 config.logger.level = Logger::INFO 
 </code></pre> 

 <pre> 
 [root@redmine ~]# cd /opt/redmine-4.1.1-4/apps/redmine/htdocs/log/ 
 [root@redmine log]# ll 
 total 1120 
 -rwxrwxr-x. 1 root     daemon        36 Jun 18    2012 delete.me 
 -rw-r--r--. 1 daemon daemon     12158 Jul    9 09:36 production.log 
 -rw-rw-r--. 1 root     daemon     30053 Jul    9 09:28 production.log.0 
 -rwxrwxr-x. 1 root     daemon 1093571 Jul    9 08:59 production.log.1 
 </pre> 

 

 h2. apache / mysql 

 let's use @logrotate@ for this task. There is @.conf@-files already shipped with the bitnami-stack. 
 https://docs.bitnami.com/installer/apps/redmine/administration/configure-use-logrotate/ 

 <pre><code class="bash"> 
 ln -s /opt/redmine-4.1.1-4/config/logrotate/bitnami.conf /etc/logrotate.d/bitnami.conf 
 </code></pre> 



 



 h2. setup Redmine-Logo 

 http://www.redmine.org/projects/redmine/wiki/Howto_add_a_logo_to_your_Redmine_banner 

 edit following file @/opt/redmine-4.1.1-4/apps/redmine/htdocs/app/views/layouts/base.html.erb@ 

 <pre><code class="html"> 
 #line 93 
 <h1><img src="<%= Redmine::Utils.relative_url_root %>/images/logo.png" style="top-margin: 15px; left-margin: 15px;"/> <%= page_header_title %></h1> 
 </code></pre> 

 copy @logo.png@ to @/opt/redmine-4.1.1-4/apps/redmine/htdocs/public/images@ 

 

 h1. setup service 

 add following service-unit @/etc/systemd/system/bitnami-redmine.service@ 

 <pre><code class="ini"> 
 [Unit] 
 Description=run bitnami redmine 
 After=network.target 

 [Service] 
 Type=oneshot 
 RemainAfterExit=yes 
 ExecStart=/opt/redmine-4.1.1-4/ctlscript.sh start 
 ExecStop=/opt/redmine-4.1.1-4/ctlscript.sh stop 

 [Install] 
 WantedBy=multi-user.target 
 </code></pre> 

 enable the unit by 

 <pre><code class="bash"> 
 systemctl enable bitnami-redmine 
 </code></pre> 


 h1. Nagging 

 There are a couple of plugins available, we are trying to do our own thing.  

 h2. create a read only user 

 <pre><code class="sql"> 
 mysql -u root -p 
 create user 'redmine_reader'@'localhost'; 
 grant select on bitnami_redmine.* to 'redmine_reader'@'localhost'; 
 flush privileges; 
 </code></pre> 

 h2. create a sql-statement 

 http://www.redmine.org/projects/redmine/wiki/DatabaseModel 
 !Redmine_2_5_2_2_ER-databasemodel.png! 

 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.  

 <pre><code class="sql"> 
 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 
 FROM (SELECT DISTINCT _b.id,_b.name  
       FROM (SELECT _p.name,_p.id  
             FROM projects AS _p  
             WHERE _p.id=33 OR _p.parent_id=33 
            ) AS pp, projects AS _b  
       WHERE _b.parent_id=pp.id OR _b.id=33 ORDER BY _b.name 
      ) AS _p, 
      issues AS _i,  
      issue_statuses AS _is ,  
      users AS _u, 
      email_addresses AS _e 
 WHERE _p.id = _i.project_id  
   AND _i.status_id=_is.id  
   AND _u.id=_i.assigned_to_id  
   AND _u.id=_e.user_id  
   AND _is.is_closed=0  
   AND _i.due_date<=ADDDATE(curdate(),7)  
 ORDER BY _p.name,_i.id; 
 </code></pre> 

 the funny @@@n@ groups are used later on. 

 h2. create a html-mail 

 create a little shell-sript @redmine_send_mail.sh@ that 
 * fetches the data from the database 
 * forms a valid html-mail 
 * sends the mail to one recipient 

 <pre><code class="bash"> 
 #!/bin/sh 

 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" 

 #export List from DB 
 mysql -u redmine_reader -H -B bitnami_redmine < list.sql > /tmp/redmine_mysql_output 

 #replace special stuff 
 sed -i -e 's/@@@1@/<a href="/g' /tmp/redmine_mysql_output 
 sed -i -e 's/@@@2@/">/g' /tmp/redmine_mysql_output 
 sed -i -e 's/@@@3@/<\/a>/g' /tmp/redmine_mysql_output 

 echo 'Subject: weekly audit "all open issues due within the next 7 days"' > /tmp/redmine_mail_raw 
 echo 'to: user@example.com' >> /tmp/redmine_mail_raw 
 echo 'MIME-Version: 1.0' >> /tmp/redmine_mail_raw 
 echo 'Content-Type: text/html; charset=utf-8' >> /tmp/redmine_mail_raw 

 echo '' >> /tmp/redmine_mail_raw 
 echo '<html>' >> /tmp/redmine_mail_raw 
 echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">' >> /tmp/redmine_mail_raw 

 #export List from DB 
 cat /tmp/redmine_mysql_output >> /tmp/redmine_mail_raw 
 echo '</html>' >> /tmp/redmine_mail_raw 

 #send mail 
 cat /tmp/redmine_mail_raw | sendmail -t 
 </code></pre> 

 h2. use cron to nag periodically 

 run the shell-script from above every monday at 8:00am. @/etc/cron.d/redmine_audit@ 

 <pre><code class="bash"> 
 # JKE 2014-10-22 
 # 
 # minute hour day month dayofweek 
 # m h d m d 
 # - - - - - 
 # | | | | | 
 # | | | | +-day of week (0-7) sunday=0 or 7 
 # | | | +---month (1-12) 
 # | | +-----day of month (1-31) 
 # | +-------hour (0-23) 
 # +---------min (0-59) 
 #  
	 00 	 08 	 * 	 * 	 1 	 root 	 /usr/local/bin/redmine_send_mail.sh 
 </code></pre>