#!/bin/bash

export PATH=<%= install_dir %>/bin:<%= install_dir %>/embedded/bin:$PATH

# default to RAILS_ENV=production
if [[ -z $RAILS_ENV ]]; then
  export RAILS_ENV=production
fi

gitlab_user=$(ls -lLd <%= install_dir %>/embedded/service/gitlab-rails/log | awk '{ print $3 }')

cd <%= install_dir %>/embedded/service/gitlab-rails
exec <%= install_dir %>/embedded/bin/chpst -u $gitlab_user -U $gitlab_user <%= install_dir %>/embedded/bin/bundle exec <%= command %>

#!/bin/bash

export PATH=<%= install_dir %>/bin:<%= install_dir %>/embedded/bin:$PATH

# default to RAILS_ENV=production
if [[ -z $RAILS_ENV ]]; then
  export RAILS_ENV=production
fi

gitlab_user=$(ls -lLd <%= install_dir %>/embedded/service/gitlab-rails/log | awk '{ print $3 }')

export HOME=$(eval echo ~${gitlab_user})

cd <%= install_dir %>/embedded/service/gitlab-rails
exec <%= install_dir %>/embedded/bin/chpst -u $gitlab_user -U $gitlab_user <%= install_dir %>/embedded/bin/bundle exec <%= command %>

Set HOME for the GitLab user in wrapper script
Set HOME for the GitLab user in wrapper script

Whenever we `bundle exec` a command as the GitLab user, set the HOME
environment variable accordingly. This is the moral equivalent of the
`-H` in `sudo -u git -H bundle exec ...`.
