From 0207126bd2875eb8d1c8fefff40ed24a4c904d07 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 23 Dec 2020 12:05:22 +0100 Subject: [PATCH] Fix --- scripts/_common.sh | 13 +++++++++++++ scripts/install | 11 ++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c3c6841..45b85de 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -19,6 +19,19 @@ BUNDLER_VERSION="2.2.3" # EXPERIMENTAL HELPERS #================================================= +# Execute a command as another user +# usage: ynh_exec_as USER COMMAND [ARG ...] +ynh_exec_as() { + local USER=$1 + shift 1 + + if [[ $USER = $(whoami) ]]; then + eval "$@" + else + sudo -u "$USER" "$@" + fi +} + #================================================= # FUTURE OFFICIAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 7f06011..abd313a 100644 --- a/scripts/install +++ b/scripts/install @@ -76,8 +76,6 @@ ynh_script_progression --message="Installing Rails & Bunlder..." --time --weight ynh_install_ruby --ruby_version=$RUBY_VERSION -gem install bundler - #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -133,9 +131,11 @@ cp -a ../conf/configuration.example.yml $final_path/config/configuration.yml ynh_print_info "Compile Redmine..." pushd $final_path - bundle install --without development test rmagick - RAILS_ENV=production bin/rake generate_secret_token - RAILS_ENV=production bin/rake db:migrate + gem install bundler + ynh_exec_as $app bundle install --without development test --path vendor/bundle + ynh_exec_as $app bundle exec rake generate_secret_token + ynh_exec_as $app RAILS_ENV=production bundle exec rake db:migrate + ynh_exec_as $app RAILS_ENV=production REDMINE_LANG=en bundle exec rake redmine:load_default_data popd #================================================= @@ -160,6 +160,7 @@ ynh_add_nginx_config # Set permissions to app files chown -R $app:$app $final_path +chmod -R 755 $final_path #================================================= # SETUP SSOWAT