Commit 4a1cb592235912a9ab6a900bc48e600617f0c13f

Authored by Jacob Vosmaer
1 parent 3bc9cb58

Create wrapper script using an ERB template

config/software/gitlab-core.rb
@@ -61,21 +61,8 @@ build do @@ -61,21 +61,8 @@ build do
61 command "#{install_dir}/embedded/bin/rsync -a --delete --exclude=.git/*** --exclude=.gitignore ./ #{install_dir}/embedded/service/gitlab-core/" 61 command "#{install_dir}/embedded/bin/rsync -a --delete --exclude=.git/*** --exclude=.gitignore ./ #{install_dir}/embedded/service/gitlab-core/"
62 62
63 # Create a wrapper for the rake tasks of the Rails app 63 # Create a wrapper for the rake tasks of the Rails app
64 - block do  
65 - open("#{install_dir}/bin/gitlab-rake", "w") do |file|  
66 - file.print <<-EOH  
67 -#!/bin/bash  
68 -export PATH=/opt/gitlab/bin:/opt/gitlab/embedded/bin:$PATH  
69 -  
70 -# default to RAILS_ENV=production  
71 -if [[ -z $RAILS_ENV ]]; then  
72 - export RAILS_ENV=production  
73 -fi  
74 -  
75 -cd /opt/gitlab/embedded/service/gitlab-core  
76 -/opt/gitlab/embedded/bin/chpst -u git -U git /opt/gitlab/embedded/bin/bundle exec rake "$@"  
77 -EOH  
78 - end  
79 - end  
80 - command "chmod +x #{install_dir}/bin/gitlab-rake" 64 + erb :dest => "#{install_dir}/bin/gitlab-rake",
  65 + :source => "bundle_exec_wrapper.erb",
  66 + :mode => "775",
  67 + :vars => {:command => 'rake "$@"'}
81 end 68 end
config/templates/gitlab-core/bundle_exec_wrapper.erb 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +#!/bin/bash
  2 +export PATH=/opt/gitlab/bin:/opt/gitlab/embedded/bin:$PATH
  3 +
  4 +# default to RAILS_ENV=production
  5 +if [[ -z $RAILS_ENV ]]; then
  6 + export RAILS_ENV=production
  7 +fi
  8 +
  9 +gitlab_user=$(ls -lLd /opt/gitlab/embedded/service/gitlab-core/log | awk '{ print $3 }')
  10 +
  11 +cd /opt/gitlab/embedded/service/gitlab-core
  12 +/opt/gitlab/embedded/bin/chpst -u $gitlab_user -U $gitlab_user /opt/gitlab/embedded/bin/bundle exec <%= @command %>