1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/discourse_ynh.git synced 2024-09-03 18:26:18 +02:00

Use standard ynh_exec_as helper for login shell too

This commit is contained in:
Salamandar 2024-05-20 23:55:21 +02:00 committed by Salamandar
parent 54befdebed
commit fa3621426e
4 changed files with 17 additions and 26 deletions

View file

@ -17,15 +17,6 @@ nodejs_version="16"
# 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
ynh_exec_as $user --login "$@"
}
# Returns true if a swap partition is enabled, false otherwise # Returns true if a swap partition is enabled, false otherwise
# usage: is_swap_present # usage: is_swap_present
is_swap_present() { is_swap_present() {

View file

@ -134,14 +134,14 @@ UPDATE site_settings SET value = '${new_path}' WHERE name='long_polling_base_url
ynh_use_ruby ynh_use_ruby
# Remap URLs in forum posts # Remap URLs in forum posts
exec_login_as $app RAILS_ENV=production bin/bundle exec script/discourse remap ${old_path%/}/uploads ${new_path%/}/uploads <<< "YES ynh_exec_as $app --login RAILS_ENV=production bin/bundle exec script/discourse remap ${old_path%/}/uploads ${new_path%/}/uploads <<< "YES
# " # "
# Regenerate assets # Regenerate assets
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake assets:precompile ynh_exec_warn_less ynh_exec_as $app --login RAILS_ENV=production bin/rake assets:precompile
# Regenerate all forum posts # Regenerate all forum posts
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/rake posts:rebake ynh_exec_warn_less ynh_exec_as $app --login RAILS_ENV=production bin/rake posts:rebake
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION

View file

@ -172,13 +172,13 @@ popd
if [ -n "$(uname -m | grep arm)" ] ; then if [ -n "$(uname -m | grep arm)" ] ; then
# Define the platform specifically to retrieve binaries # Define the platform specifically to retrieve binaries
# for libv8 because it currently doesn't compile on ARM devices # for libv8 because it currently doesn't compile on ARM devices
exec_login_as $app bin/bundle config specific_platform arm-linux ynh_exec_as $app --login bin/bundle config specific_platform arm-linux
fi fi
# Install dependencies # Install dependencies
exec_login_as $app bin/bundle config set path 'vendor/bundle' ynh_exec_as $app --login bin/bundle config set path 'vendor/bundle'
exec_login_as $app bin/bundle config set with 'development' ynh_exec_as $app --login bin/bundle config set with 'development'
exec_login_as $app MAKEFLAGS=-j2 bin/bundle install --jobs 2 ynh_exec_as $app --login MAKEFLAGS=-j2 bin/bundle install --jobs 2
# On ARM architecture, replace bundled libpsl by system native libpsl # On ARM architecture, replace bundled libpsl by system native libpsl
# because the provided binary isn't compatible # because the provided binary isn't compatible
@ -201,8 +201,8 @@ popd
#================================================= #=================================================
ynh_script_progression --message="Preparing the database..." ynh_script_progression --message="Preparing the database..."
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/bundle exec rake db:migrate ynh_exec_warn_less ynh_exec_as $app --login RAILS_ENV=production bin/bundle exec rake db:migrate
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile ynh_exec_warn_less ynh_exec_as $app --login RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_package_autoremove ynh_package_autoremove
@ -234,7 +234,7 @@ ynh_script_progression --message="Creating Discourse admin user..."
# Create a random password # Create a random password
admin_pwd=$(ynh_string_random) admin_pwd=$(ynh_string_random)
exec_login_as $app RAILS_ENV=production bin/rake admin:create <<< "$admin_mail ynh_exec_as $app --login RAILS_ENV=production bin/rake admin:create <<< "$admin_mail
$admin_pwd $admin_pwd
$admin_pwd $admin_pwd
y y

View file

@ -251,17 +251,17 @@ then
# Install without documentation # Install without documentation
ynh_exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc" ynh_exec_as $app echo "gem: --no-ri --no-rdoc" >> "$final_path/.gemrc"
popd popd
# Specific actions on ARM architecture # Specific actions on ARM architecture
if [ -n "$(uname -m | grep arm)" ] ; then if [ -n "$(uname -m | grep arm)" ] ; then
# Define the platform specifically to retrieve binaries # Define the platform specifically to retrieve binaries
# for libv8 because it currently doesn't compile on ARM devices # for libv8 because it currently doesn't compile on ARM devices
exec_login_as $app bin/bundle config specific_platform arm-linux ynh_exec_as $app --login bin/bundle config specific_platform arm-linux
fi fi
# Install dependencies # Install dependencies
exec_login_as $app bin/bundle config set path 'vendor/bundle' ynh_exec_as $app --login bin/bundle config set path 'vendor/bundle'
exec_login_as $app bin/bundle config set with 'development' ynh_exec_as $app --login bin/bundle config set with 'development'
exec_login_as $app MAKEFLAGS=-j2 bin/bundle install --jobs 2 ynh_exec_as $app --login MAKEFLAGS=-j2 bin/bundle install --jobs 2
# On ARM architecture, replace bundled libpsl by system native libpsl # On ARM architecture, replace bundled libpsl by system native libpsl
# because the provided binary isn't compatible # because the provided binary isn't compatible
@ -290,8 +290,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Preparing the database..." ynh_script_progression --message="Preparing the database..."
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/bundle exec rake db:migrate ynh_exec_warn_less ynh_exec_as $app --login RAILS_ENV=production bin/bundle exec rake db:migrate
ynh_exec_warn_less exec_login_as $app RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile ynh_exec_warn_less ynh_exec_as $app --login RAILS_ENV=production bin/bundle exec rake themes:update assets:precompile
fi fi
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies