# HG changeset patch # User Michael Schloh von Bennewitz # Date 1364838638 -7200 # Node ID 5be956b2db7441357c7d583e71b6ce07cb633bf8 # Parent b3f4be54aeb45fb8cbe474d51d1db897aa865f79 Complete packaging along with specification and runcommand improvements. diff -r b3f4be54aeb4 -r 5be956b2db74 chiliproj/chiliproj.spec --- a/chiliproj/chiliproj.spec Sun Mar 31 17:55:10 2013 +0200 +++ b/chiliproj/chiliproj.spec Mon Apr 01 19:50:38 2013 +0200 @@ -22,6 +22,8 @@ ## # FIXME: GEM_HOME=$HOME/.gem RAILS_ENV=production PATH=$PATH:%{l_prefix}/lib/ruby/gems/1.9.1/bin bundle install --without test development mysql postgres rmagick +# FIXME: Reduce %post by removing RAILS_ENV=production +# FIXME: Consider using imagemagick for Gantt? # FIXME: bundle exec rails s # FIXME: w3m http://localhost:3000/ # FIXME: log in with Login: admin and Password: admin @@ -64,7 +66,7 @@ Class: EVAL Group: Calendar License: GPL -Version: 20130328 +Version: 20130401 Release: 20120800 # list of sources @@ -253,7 +255,8 @@ RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'` export GEM_HOME=$RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION %{l_shtool} mkdir -f -p -m 755 $GEM_HOME - %{l_shtool} mkdir -f -p public/plugin_assets + %{l_shtool} mkdir -f -p $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/public/plugin_assets + %{l_shtool} mkdir -f -p $RPM_BUILD_ROOT%{l_prefix}/var/chiliproj %{l_tar} cf - . | %{l_tar} xf - -C $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj %{l_prefix}/bin/gem install --local %{SOURCE3} %{l_prefix}/bin/gem install --local %{SOURCE4} @@ -282,30 +285,26 @@ # install configuration ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj - %{l_shtool} mkdir -f -p -m 755 .bundle cp %{SOURCE Gemfile.lock} . echo 'gem "thin"' >>Gemfile cp config/configuration.yml.example config/configuration.yml cp config/additional_environment.rb.example config/additional_environment.rb echo "ENV['GEM_PATH'] = '%{l_prefix}/lib/ruby/gems/$RUBY_VERSION:%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION'" >>config/additional_environment.rb - #echo 'config.action_controller.session = { :key => "_chiliproject_session", :secret => "54bbf51a99cbce2a8881af4fa0fa23895e071f8c8c4773e76b09388135bd9d3671534bf4db20c9f3" }' >>config/additional_environment.rb + %{l_shtool} mkdir -f -p -m 755 .bundle # prime bundler with configuration + echo 'BUNDLE_WITHOUT: test:de:development:postgres:mysql:rmagick' >.bundle/config cat >config/database.yml <.bundle/config </dev/null # insert default configuration into database + echo 'Populating ChiliProject initial database...' echo 'en' | \ RAILS_ENV=production \ $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ - exec rake redmine:load_default_data + exec rake redmine:load_default_data >/dev/null + # correct permissions of generated files + chown %{l_nusr}:%{l_mgrp} \ + $RPM_INSTALL_PREFIX/lib/chiliproj/log/production.log \ + $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers/session_store.rb \ + $RPM_INSTALL_PREFIX/lib/chiliproj/db/* \ + $RPM_INSTALL_PREFIX/lib/chiliproj/db/*/* +chown opsw-n db db/* db/migrate/* + chmod 0664 \ + $RPM_INSTALL_PREFIX/lib/chiliproj/log/production.log \ + $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers/session_store.rb \ + $RPM_INSTALL_PREFIX/lib/chiliproj/db/* \ + $RPM_INSTALL_PREFIX/lib/chiliproj/db/*/* ) || exit $? fi - if [ $1 -eq 2 ]; then - # after upgrade - echo NOOP - fi + # after upgrade, restart service + [ $1 -eq 2 ] || exit 0 + eval `%{l_rc} chiliproj status 2>/dev/null` + [ ".$chiliproj_active" = .yes ] && %{l_rc} chiliproj restart + exit 0 +%preun + # before erase, stop service and remove log files + [ $1 -eq 0 ] || exit 0 + %{l_rc} chiliproj stop 2>/dev/null + rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/db 2>/dev/null || true + rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/public 2>/dev/null || true + rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers 2>/dev/null || true + rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/log 2>/dev/null || true + rm -f $RPM_INSTALL_PREFIX/var/chiliproj/*.log 2>/dev/null || true + rm -f $RPM_INSTALL_PREFIX/var/chiliproj/*.pid 2>/dev/null || true + exit 0 + diff -r b3f4be54aeb4 -r 5be956b2db74 chiliproj/rc.chiliproj --- a/chiliproj/rc.chiliproj Sun Mar 31 17:55:10 2013 +0200 +++ b/chiliproj/rc.chiliproj Mon Apr 01 19:50:38 2013 +0200 @@ -6,44 +6,88 @@ %config chili_enable="$openpkg_rc_def" chili_host="localhost" + chili_port=3000 + chili_svcs=1 chili_log_prolog="true" chili_log_epilog="true" chili_log_numfiles="10" chili_log_minsize="1M" chili_log_complevel="9" + chili_logfile="@l_prefix@/lib/chiliproj/log/production.log" + chili_thinpath="@l_prefix@/var/chiliproj" + +%common + chili_pidpath="@l_prefix@/var/chiliproj" + chili_signal () { + for thepid in ${chili_pidpath}/thind.[0-9][0-9]*.pid; do + [ -f $thepid ] && kill -$1 `cat $thepid` + proclive=$? + if [ $proclive = 0 ]; then break; fi + done + [ $proclive = 0 ] + } %status -u @l_susr@ -o chili_usable="unknown" - #chili_active="no" - chili_active="unknown" - # rcService chiliproj enable yes && \ - # check pid or something >/dev/null 2>&1 && \ - # chili_active="yes" + chili_active="no" + rcService chiliproj enable yes && \ + chili_signal 0 && chili_active="yes" echo "chili_enable=\"$chili_enable\"" echo "chili_usable=\"$chili_usable\"" echo "chili_active=\"$chili_active\"" -%start -u @l_nusr@ +%start -u @l_susr@ rcService chiliproj enable yes || exit 0 rcService chiliproj active yes && exit 0 - PATH=$PATH:@l_gempath@/bin bundle exec thin -e production -a $chili_host start +#--ssl +#--ssl-verify +#--ssl-key-file +#--ssl-cert-file + cd @l_chilipath@ && \ + @l_gempath@/bin/bundle exec thin \ + -d \ + -e production \ + -u @l_nusr@ \ + -g @l_mgrp@ \ + -a $chili_host \ + -p $chili_port \ + -s $chili_svcs \ + -P $chili_pidpath/thind.pid \ + -l $chili_thinpath/thind.log \ + start -%stop -u @l_nusr@ +%stop -u @l_susr@ rcService chiliproj enable yes || exit 0 rcService chiliproj active no && exit 0 - # send kill -TERM to pid + cd @l_chilipath@ && \ + @l_gempath@/bin/bundle exec thin \ + -P ${chili_pidpath}/thind.pid stop -%restart -u @l_nusr@ +%restart -u @l_susr@ rcService chiliproj enable yes || exit 0 rcService chiliproj active no && exit 0 - # do stop sleep start + rc chiliproj stop + sleep 2 + rc chiliproj start -%daily -u @l_nusr@ +%daily -u @l_susr@ rcService chiliproj enable yes || exit 0 -# shtool rotate -f \ -# -n ${chili_log_numfiles} -s ${chili_log_minsize} -d \ -# -z ${chili_log_complevel} -m 664 -o @l_rusr@ -g @l_rgrp@ \ -# -P "${chili_log_prolog}" \ -# -E "${chili_log_epilog}; rc chiliproj logrel" \ -# @l_prefix@/lib/chiliproj/log/chiliproject.log + rcTmp -i + hintfile=`rcTmp -f -n hint` + shtool rotate -f \ + -n ${chili_log_numfiles} -s ${chili_log_minsize} -d \ + -z ${chili_log_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ + -P "${chili_log_prolog}" \ + -E "${chili_log_epilog}; echo 1 >$hintfile" \ + ${chili_logfile} + shtool rotate -f \ + -n ${chili_thin_numfiles} -s ${chili_thin_minsize} -d \ + -z ${chili_thin_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ + -P "${chili_thin_prolog}" \ + -E "${chili_thin_epilog}; echo 1 >$hintfile" \ + ${chili_thinpath}/thind.*.log + if [ -s $hintfile ]; then + rc chiliproj restart + fi + rcTmp -k