Mon, 01 Apr 2013 19:50:38 +0200
Complete packaging along with specification and runcommand improvements.
chiliproj/chiliproj.spec | file | annotate | diff | comparison | revisions | |
chiliproj/rc.chiliproj | file | annotate | diff | comparison | revisions |
1.1 --- a/chiliproj/chiliproj.spec Sun Mar 31 17:55:10 2013 +0200 1.2 +++ b/chiliproj/chiliproj.spec Mon Apr 01 19:50:38 2013 +0200 1.3 @@ -22,6 +22,8 @@ 1.4 ## 1.5 1.6 # 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 1.7 +# FIXME: Reduce %post by removing RAILS_ENV=production 1.8 +# FIXME: Consider using imagemagick for Gantt? 1.9 # FIXME: bundle exec rails s 1.10 # FIXME: w3m http://localhost:3000/ 1.11 # FIXME: log in with Login: admin and Password: admin 1.12 @@ -64,7 +66,7 @@ 1.13 Class: EVAL 1.14 Group: Calendar 1.15 License: GPL 1.16 -Version: 20130328 1.17 +Version: 20130401 1.18 Release: 20120800 1.19 1.20 # list of sources 1.21 @@ -253,7 +255,8 @@ 1.22 RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'` 1.23 export GEM_HOME=$RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION 1.24 %{l_shtool} mkdir -f -p -m 755 $GEM_HOME 1.25 - %{l_shtool} mkdir -f -p public/plugin_assets 1.26 + %{l_shtool} mkdir -f -p $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj/public/plugin_assets 1.27 + %{l_shtool} mkdir -f -p $RPM_BUILD_ROOT%{l_prefix}/var/chiliproj 1.28 %{l_tar} cf - . | %{l_tar} xf - -C $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj 1.29 %{l_prefix}/bin/gem install --local %{SOURCE3} 1.30 %{l_prefix}/bin/gem install --local %{SOURCE4} 1.31 @@ -282,30 +285,26 @@ 1.32 1.33 # install configuration 1.34 ( cd $RPM_BUILD_ROOT%{l_prefix}/lib/chiliproj 1.35 - %{l_shtool} mkdir -f -p -m 755 .bundle 1.36 cp %{SOURCE Gemfile.lock} . 1.37 echo 'gem "thin"' >>Gemfile 1.38 cp config/configuration.yml.example config/configuration.yml 1.39 cp config/additional_environment.rb.example config/additional_environment.rb 1.40 echo "ENV['GEM_PATH'] = '%{l_prefix}/lib/ruby/gems/$RUBY_VERSION:%{l_prefix}/lib/chiliproj/gems/$RUBY_VERSION'" >>config/additional_environment.rb 1.41 - #echo 'config.action_controller.session = { :key => "_chiliproject_session", :secret => "54bbf51a99cbce2a8881af4fa0fa23895e071f8c8c4773e76b09388135bd9d3671534bf4db20c9f3" }' >>config/additional_environment.rb 1.42 + %{l_shtool} mkdir -f -p -m 755 .bundle # prime bundler with configuration 1.43 + echo 'BUNDLE_WITHOUT: test:de:development:postgres:mysql:rmagick' >.bundle/config 1.44 cat >config/database.yml <<EOF 1.45 production: 1.46 adapter: sqlite3 1.47 database: db/prod.sqlite 1.48 EOF 1.49 - # try this block with --- 1.50 - cat >.bundle/config <<EOF 1.51 ---- 1.52 -BUNDLE_WITHOUT: test:de:development:postgres:mysql:rmagick 1.53 -EOF 1.54 ) || exit $? 1.55 1.56 # install run command script 1.57 %{l_shtool} mkdir -f -p -m 755 \ 1.58 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d 1.59 %{l_shtool} install -c -m 755 %{l_value -s -a} \ 1.60 - -e 's;@l_gempath@;$RPM_BUILD_ROOT%{l_prefix}/lib/ruby/gems/$RUBY_VERSION;g' \ 1.61 + -e "s;@l_chilipath@;%{l_prefix}/lib/chiliproj;" \ 1.62 + -e "s;@l_gempath@;%{l_prefix}/lib/ruby/gems/$RUBY_VERSION;" \ 1.63 %{SOURCE rc.chiliproj} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ 1.64 1.65 # clean up white spaces 1.66 @@ -314,18 +313,20 @@ 1.67 # problem with typical name 'files', existing in this case 1.68 %{l_rpmtool} files -v -oaltfiles -r$RPM_BUILD_ROOT \ 1.69 %{l_files_std} \ 1.70 - '%config %{l_prefix}/lib/chiliproj/config/*' 1.71 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files' \ 1.72 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files/*' \ 1.73 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log' \ 1.74 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log/*' \ 1.75 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp' \ 1.76 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/*' \ 1.77 - #'%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets' \ 1.78 - #'%attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets/*' 1.79 + '%config %{l_prefix}/lib/chiliproj/config/*' \ 1.80 + '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files' \ 1.81 + '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/files/*' \ 1.82 + '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log' \ 1.83 + '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/log/*' \ 1.84 + '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp' \ 1.85 + '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/*' \ 1.86 + '%attr(664,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/tmp/test/*' \ 1.87 + '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets' \ 1.88 + '%attr(664,%{l_nusr},%{l_ngrp}) %{l_prefix}/lib/chiliproj/public/plugin_assets/*' \ 1.89 + '%attr(775,%{l_nusr},%{l_mgrp}) %{l_prefix}/var/chiliproj' 1.90 1.91 %files -f altfiles 1.92 - # problem with typical name 'files', existing in this case 1.93 + # problem with typical name 'files' which preexists 1.94 1.95 %clean 1.96 1.97 @@ -334,21 +335,49 @@ 1.98 RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'` 1.99 ( cd $RPM_INSTALL_PREFIX/lib/chiliproj 1.100 # install session 1.101 + echo 'Creating ChiliProject session key...' 1.102 $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ 1.103 exec rake generate_session_store 1.104 # create initial database 1.105 + echo 'Creating ChiliProject initial database...' 1.106 RAILS_ENV=production \ 1.107 $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ 1.108 - exec rake db:migrate 1.109 + exec rake db:migrate >/dev/null 1.110 # insert default configuration into database 1.111 + echo 'Populating ChiliProject initial database...' 1.112 echo 'en' | \ 1.113 RAILS_ENV=production \ 1.114 $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ 1.115 - exec rake redmine:load_default_data 1.116 + exec rake redmine:load_default_data >/dev/null 1.117 + # correct permissions of generated files 1.118 + chown %{l_nusr}:%{l_mgrp} \ 1.119 + $RPM_INSTALL_PREFIX/lib/chiliproj/log/production.log \ 1.120 + $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers/session_store.rb \ 1.121 + $RPM_INSTALL_PREFIX/lib/chiliproj/db/* \ 1.122 + $RPM_INSTALL_PREFIX/lib/chiliproj/db/*/* 1.123 +chown opsw-n db db/* db/migrate/* 1.124 + chmod 0664 \ 1.125 + $RPM_INSTALL_PREFIX/lib/chiliproj/log/production.log \ 1.126 + $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers/session_store.rb \ 1.127 + $RPM_INSTALL_PREFIX/lib/chiliproj/db/* \ 1.128 + $RPM_INSTALL_PREFIX/lib/chiliproj/db/*/* 1.129 ) || exit $? 1.130 fi 1.131 - if [ $1 -eq 2 ]; then 1.132 - # after upgrade 1.133 - echo NOOP 1.134 - fi 1.135 + # after upgrade, restart service 1.136 + [ $1 -eq 2 ] || exit 0 1.137 + eval `%{l_rc} chiliproj status 2>/dev/null` 1.138 + [ ".$chiliproj_active" = .yes ] && %{l_rc} chiliproj restart 1.139 + exit 0 1.140 1.141 +%preun 1.142 + # before erase, stop service and remove log files 1.143 + [ $1 -eq 0 ] || exit 0 1.144 + %{l_rc} chiliproj stop 2>/dev/null 1.145 + rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/db 2>/dev/null || true 1.146 + rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/public 2>/dev/null || true 1.147 + rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/config/initializers 2>/dev/null || true 1.148 + rm -rf $RPM_INSTALL_PREFIX/lib/chiliproj/log 2>/dev/null || true 1.149 + rm -f $RPM_INSTALL_PREFIX/var/chiliproj/*.log 2>/dev/null || true 1.150 + rm -f $RPM_INSTALL_PREFIX/var/chiliproj/*.pid 2>/dev/null || true 1.151 + exit 0 1.152 +
2.1 --- a/chiliproj/rc.chiliproj Sun Mar 31 17:55:10 2013 +0200 2.2 +++ b/chiliproj/rc.chiliproj Mon Apr 01 19:50:38 2013 +0200 2.3 @@ -6,44 +6,88 @@ 2.4 %config 2.5 chili_enable="$openpkg_rc_def" 2.6 chili_host="localhost" 2.7 + chili_port=3000 2.8 + chili_svcs=1 2.9 chili_log_prolog="true" 2.10 chili_log_epilog="true" 2.11 chili_log_numfiles="10" 2.12 chili_log_minsize="1M" 2.13 chili_log_complevel="9" 2.14 + chili_logfile="@l_prefix@/lib/chiliproj/log/production.log" 2.15 + chili_thinpath="@l_prefix@/var/chiliproj" 2.16 + 2.17 +%common 2.18 + chili_pidpath="@l_prefix@/var/chiliproj" 2.19 + chili_signal () { 2.20 + for thepid in ${chili_pidpath}/thind.[0-9][0-9]*.pid; do 2.21 + [ -f $thepid ] && kill -$1 `cat $thepid` 2.22 + proclive=$? 2.23 + if [ $proclive = 0 ]; then break; fi 2.24 + done 2.25 + [ $proclive = 0 ] 2.26 + } 2.27 2.28 %status -u @l_susr@ -o 2.29 chili_usable="unknown" 2.30 - #chili_active="no" 2.31 - chili_active="unknown" 2.32 - # rcService chiliproj enable yes && \ 2.33 - # check pid or something >/dev/null 2>&1 && \ 2.34 - # chili_active="yes" 2.35 + chili_active="no" 2.36 + rcService chiliproj enable yes && \ 2.37 + chili_signal 0 && chili_active="yes" 2.38 echo "chili_enable=\"$chili_enable\"" 2.39 echo "chili_usable=\"$chili_usable\"" 2.40 echo "chili_active=\"$chili_active\"" 2.41 2.42 -%start -u @l_nusr@ 2.43 +%start -u @l_susr@ 2.44 rcService chiliproj enable yes || exit 0 2.45 rcService chiliproj active yes && exit 0 2.46 - PATH=$PATH:@l_gempath@/bin bundle exec thin -e production -a $chili_host start 2.47 +#--ssl 2.48 +#--ssl-verify 2.49 +#--ssl-key-file <path> 2.50 +#--ssl-cert-file <path> 2.51 + cd @l_chilipath@ && \ 2.52 + @l_gempath@/bin/bundle exec thin \ 2.53 + -d \ 2.54 + -e production \ 2.55 + -u @l_nusr@ \ 2.56 + -g @l_mgrp@ \ 2.57 + -a $chili_host \ 2.58 + -p $chili_port \ 2.59 + -s $chili_svcs \ 2.60 + -P $chili_pidpath/thind.pid \ 2.61 + -l $chili_thinpath/thind.log \ 2.62 + start 2.63 2.64 -%stop -u @l_nusr@ 2.65 +%stop -u @l_susr@ 2.66 rcService chiliproj enable yes || exit 0 2.67 rcService chiliproj active no && exit 0 2.68 - # send kill -TERM to pid 2.69 + cd @l_chilipath@ && \ 2.70 + @l_gempath@/bin/bundle exec thin \ 2.71 + -P ${chili_pidpath}/thind.pid stop 2.72 2.73 -%restart -u @l_nusr@ 2.74 +%restart -u @l_susr@ 2.75 rcService chiliproj enable yes || exit 0 2.76 rcService chiliproj active no && exit 0 2.77 - # do stop sleep start 2.78 + rc chiliproj stop 2.79 + sleep 2 2.80 + rc chiliproj start 2.81 2.82 -%daily -u @l_nusr@ 2.83 +%daily -u @l_susr@ 2.84 rcService chiliproj enable yes || exit 0 2.85 -# shtool rotate -f \ 2.86 -# -n ${chili_log_numfiles} -s ${chili_log_minsize} -d \ 2.87 -# -z ${chili_log_complevel} -m 664 -o @l_rusr@ -g @l_rgrp@ \ 2.88 -# -P "${chili_log_prolog}" \ 2.89 -# -E "${chili_log_epilog}; rc chiliproj logrel" \ 2.90 -# @l_prefix@/lib/chiliproj/log/chiliproject.log 2.91 + rcTmp -i 2.92 + hintfile=`rcTmp -f -n hint` 2.93 + shtool rotate -f \ 2.94 + -n ${chili_log_numfiles} -s ${chili_log_minsize} -d \ 2.95 + -z ${chili_log_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ 2.96 + -P "${chili_log_prolog}" \ 2.97 + -E "${chili_log_epilog}; echo 1 >$hintfile" \ 2.98 + ${chili_logfile} 2.99 + shtool rotate -f \ 2.100 + -n ${chili_thin_numfiles} -s ${chili_thin_minsize} -d \ 2.101 + -z ${chili_thin_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ 2.102 + -P "${chili_thin_prolog}" \ 2.103 + -E "${chili_thin_epilog}; echo 1 >$hintfile" \ 2.104 + ${chili_thinpath}/thind.*.log 2.105 + if [ -s $hintfile ]; then 2.106 + rc chiliproj restart 2.107 + fi 2.108 + rcTmp -k 2.109