# HG changeset patch # User Michael Schloh von Bennewitz # Date 1364928290 -7200 # Node ID 3ee660c5bc4fdb4d5ed20e9cbee20c424e05d36d # Parent fd2bc92f4dee6422e30a90eb5faf8437ed792fa3 Correct initial database generation and improve runcommand script logic. diff -r fd2bc92f4dee -r 3ee660c5bc4f chiliproj/chiliproj.spec --- a/chiliproj/chiliproj.spec Mon Apr 01 20:12:48 2013 +0200 +++ b/chiliproj/chiliproj.spec Tue Apr 02 20:44:50 2013 +0200 @@ -22,6 +22,7 @@ ## # 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: %{l_prefix}/lib/ruby/gems/1.9.1/bin/rake -T (or -D) # FIXME: Reduce %post by removing RAILS_ENV=production # FIXME: Consider using imagemagick for Gantt? # FIXME: bundle exec rails s @@ -248,6 +249,9 @@ %{l_shtool} subst \ -e 's;# \(ENV\[.RAILS_ENV.\] ||= .production.\);\1;' \ config/environment.rb + %{l_shtool} subst \ + -e 's;.*<%= l(:text_powered_by.*;;' \ + app/views/layouts/base.rhtml %build @@ -337,35 +341,51 @@ # install session echo 'Creating ChiliProject session key...' $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ - exec rake generate_session_store + exec rake -s generate_session_store # create initial database - echo 'Creating ChiliProject initial database...' - RAILS_ENV=production \ - $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ - exec rake db:migrate >/dev/null + echo 'Creating ChiliProject data schemas...' + $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ + exec rake db:migrate \ + RAILS_ENV=production VERBOSE=false + #echo 'Creating ChiliProject initial database...' + #$RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ + # exec rake db:setup >/dev/null 2>&1 \ + # exec rake -s db:create \ + # RAILS_ENV=production # 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 >/dev/null + $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ + exec rake redmine:load_default_data >/dev/null \ + RAILS_ENV=production # 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/* \ $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/*/* + chmod 0775 \ + $RPM_INSTALL_PREFIX/lib/chiliproj/db \ + $RPM_INSTALL_PREFIX/lib/chiliproj/db/migrate ) || exit $? - echo 'ChiliProject installation done.' + echo 'ChiliProject postinstallation finished.' fi # after upgrade, restart service [ $1 -eq 2 ] || exit 0 + RUBY_VERSION=`%{l_prefix}/bin/gem which rubygems | sed -e 's;.*/\([^/]*\)/rubygems\.rb$;\1;'` + ( cd $RPM_INSTALL_PREFIX/lib/chiliproj + ## migrate existing database + #echo 'Migrating ChiliProject existing database...' + #VERBOSE=false RAILS_ENV=production \ + # $RPM_INSTALL_PREFIX/lib/ruby/gems/$RUBY_VERSION/bin/bundle \ + # exec rake db:migrate + ) || exit $? eval `%{l_rc} chiliproj status 2>/dev/null` [ ".$chiliproj_active" = .yes ] && %{l_rc} chiliproj restart exit 0 diff -r fd2bc92f4dee -r 3ee660c5bc4f chiliproj/rc.chiliproj --- a/chiliproj/rc.chiliproj Mon Apr 01 20:12:48 2013 +0200 +++ b/chiliproj/rc.chiliproj Tue Apr 02 20:44:50 2013 +0200 @@ -4,22 +4,29 @@ ## %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" + chiliproj_enable="$openpkg_rc_def" + chiliproj_cleartext"="yes" + chiliproj_tlsecured"="no" + #chiliproj_flags="-u @l_nusr@ -g @l_musr@" + chiliproj_flags="" + chiliproj_host="localhost" + chiliproj_port_clt=80 + chiliproj_port_tls=443 + chiliproj_svcs=1 + chiliproj_key="@l_prefix@/etc/openssl/host-ca-rsa-4096-key.pem" + chiliproj_crt="@l_prefix@/etc/openssl/host-ca-rsa-4096-crt.pem" + chiliproj_log_prolog="true" + chiliproj_log_epilog="true" + chiliproj_log_numfiles="10" + chiliproj_log_minsize="1M" + chiliproj_log_complevel="9" + chiliproj_logfile="@l_prefix@/lib/chiliproj/log/production.log" + chiliproj_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 + chiliproj_pidpath="@l_prefix@/var/chiliproj" + chiliproj_signal () { + for thepid in ${chiliproj_pidpath}/thind.[0-9][0-9]*.pid; do [ -f $thepid ] && kill -$1 `cat $thepid` proclive=$? if [ $proclive = 0 ]; then break; fi @@ -28,39 +35,52 @@ } %status -u @l_susr@ -o - chili_usable="unknown" - chili_active="no" + chiliproj_usable="unknown" + chiliproj_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\"" + chiliproj_signal 0 && chiliproj_active="yes" + echo "chiliproj_enable=\"$chiliproj_enable\"" + echo "chiliproj_usable=\"$chiliproj_usable\"" + echo "chiliproj_active=\"$chiliproj_active\"" %start -u @l_susr@ rcService chiliproj enable yes || exit 0 rcService chiliproj active yes && exit 0 -#--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 + if [ "$chiliproj_cleartext" = "yes" ]; then + cd @l_chilipath@ && \ + @l_gempath@/bin/bundle exec thin \ + -d \ + -e production \ + -a $chiliproj_host \ + -p $chiliproj_port_clt \ + -s $chiliproj_svcs \ + -P $chiliproj_pidpath/thind.pid \ + -l $chiliproj_thinpath/thind.log \ + $chiliproj_flags \ + start + fi + if [ "$chiliproj_tlsecured" = "yes" ]; then + cd @l_prefix@/lib/chiliproj && \ + @l_gempath@/bin/bundle exec thin \ + -d \ + -e production \ + -a $chiliproj_host \ + -p $chiliproj_port_tls \ + -s $chiliproj_svcs \ + -P $chiliproj_pidpath/thind.pid \ + -l $chiliproj_thinpath/thind.log \ + --ssl \ + --ssl-key-file $chiliproj_key \ + --ssl-cert-file $chiliproj_crt \ + $chiliproj_flags \ + start + fi %stop -u @l_susr@ rcService chiliproj enable yes || exit 0 rcService chiliproj active no && exit 0 cd @l_chilipath@ - for thepid in ${chili_pidpath}/thind.[0-9][0-9]*.pid; do + for thepid in ${chiliproj_pidpath}/thind.[0-9][0-9]*.pid; do cd @l_prefix@/lib/chiliproj @l_gempath@/bin/bundle exec thin -P $thepid stop done @@ -77,17 +97,17 @@ 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} + -n ${chiliproj_log_numfiles} -s ${chiliproj_log_minsize} -d \ + -z ${chiliproj_log_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ + -P "${chiliproj_log_prolog}" \ + -E "${chiliproj_log_epilog}; echo 1 >$hintfile" \ + ${chiliproj_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 + -n ${chiliproj_thin_numfiles} -s ${chiliproj_thin_minsize} -d \ + -z ${chiliproj_thin_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ + -P "${chiliproj_thin_prolog}" \ + -E "${chiliproj_thin_epilog}; echo 1 >$hintfile" \ + ${chiliproj_thinpath}/thind.*.log if [ -s $hintfile ]; then rc chiliproj restart fi