From bfeeaa4b6fbe4061ab6e418a9e11072dbdbaa4bc Mon Sep 17 00:00:00 2001 From: Fabian Wilkens Date: Sun, 2 May 2021 11:47:41 +0200 Subject: [PATCH] Switch to ynh_exec_as --- scripts/_common.sh | 21 --------------------- scripts/install | 12 ++++++------ scripts/upgrade | 12 ++++++------ 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 7c70401..42bf07a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -18,27 +18,6 @@ pkg_dependencies="\ # PERSONAL HELPERS #================================================= -# Execute a command as another user with login -# (hence in user home dir, with prior loading of .profile, etc.) -# usage: exec_login_as USER COMMAND [ARG ...] -exec_login_as() { - local user=$1 - shift 1 - exec_as $user --login "$@" -} -# Execute a command as another user -# usage: exec_as USER COMMAND [ARG ...] -exec_as() { - local user=$1 - shift 1 - - if [[ $user = $(whoami) ]]; then - eval "$@" - else - sudo -u "$user" "$@" - fi -} - # Check if service is ready is_service_ready() { for ((i = 0 ; i < 15 ; i++)) diff --git a/scripts/install b/scripts/install index c4c4ab1..dd9fc71 100755 --- a/scripts/install +++ b/scripts/install @@ -168,12 +168,12 @@ ynh_script_progression --message="Installing Standard Notes - Syncing Server..." chown -R $app: "$final_path" pushd "$final_path/live" - exec_as $app $ynh_ruby_load_path bin/bundle config set --local path 'vendor/bundle' - exec_as $app $ynh_ruby_load_path bin/bundle config set with 'development' - exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN) - exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:migrate --quiet - exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:seed --quiet -# exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet + ynh_exec_as $app $ynh_ruby_load_path bin/bundle config set --local path 'vendor/bundle' + ynh_exec_as $app $ynh_ruby_load_path bin/bundle config set with 'development' + ynh_exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN) + ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:migrate --quiet + ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:seed --quiet +# ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f226d21..84c428f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -268,12 +268,12 @@ then chown -R $app: "$final_path" pushd "$final_path/live" - exec_as $app $ynh_ruby_load_path bin/bundle config set --local path 'vendor/bundle' - exec_as $app $ynh_ruby_load_path bin/bundle config set with 'development' - exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN) - exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:migrate --quiet - exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:seed --quiet -# exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet + ynh_exec_as $app $ynh_ruby_load_path bin/bundle config set --local path 'vendor/bundle' + ynh_exec_as $app $ynh_ruby_load_path bin/bundle config set with 'development' + ynh_exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN) + ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:migrate --quiet + ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:seed --quiet +# ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet popd fi