mirror of
https://github.com/YunoHost-Apps/snserver_ynh.git
synced 2024-09-03 20:26:22 +02:00
Switch to ynh_exec_as
This commit is contained in:
parent
ff55a8a696
commit
bfeeaa4b6f
3 changed files with 12 additions and 33 deletions
|
@ -18,27 +18,6 @@ pkg_dependencies="\
|
||||||
# PERSONAL HELPERS
|
# 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
|
# Check if service is ready
|
||||||
is_service_ready() {
|
is_service_ready() {
|
||||||
for ((i = 0 ; i < 15 ; i++))
|
for ((i = 0 ; i < 15 ; i++))
|
||||||
|
|
|
@ -168,12 +168,12 @@ ynh_script_progression --message="Installing Standard Notes - Syncing Server..."
|
||||||
chown -R $app: "$final_path"
|
chown -R $app: "$final_path"
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
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 --local path 'vendor/bundle'
|
||||||
exec_as $app $ynh_ruby_load_path bin/bundle config set with 'development'
|
ynh_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)
|
ynh_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
|
ynh_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
|
ynh_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 RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -268,12 +268,12 @@ then
|
||||||
chown -R $app: "$final_path"
|
chown -R $app: "$final_path"
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
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 --local path 'vendor/bundle'
|
||||||
exec_as $app $ynh_ruby_load_path bin/bundle config set with 'development'
|
ynh_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)
|
ynh_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
|
ynh_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
|
ynh_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 RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue