mirror of
https://github.com/YunoHost-Apps/discourse_ynh.git
synced 2024-09-03 18:26:18 +02:00
Wrapper to exec_as with ruby and node in env
This commit is contained in:
parent
8b79775e15
commit
74f05908e4
4 changed files with 24 additions and 20 deletions
|
@ -14,6 +14,10 @@ libjemalloc="$(ldconfig -p | grep libjemalloc | awk 'END {print $NF}')"
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
_exec_as_app_with_ruby_node() {
|
||||||
|
ynh_exec_as "$app" -E env PATH="$nodejs_path:$ruby_path:$PATH" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
# 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() {
|
||||||
|
|
|
@ -46,15 +46,15 @@ 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
|
||||||
ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec script/discourse remap "$old_relative_url_root/uploads" "$new_relative_url_root/uploads" <<< "YES
|
_exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec script/discourse remap "$old_relative_url_root/uploads" "$new_relative_url_root/uploads" <<< "YES
|
||||||
# "
|
# "
|
||||||
|
|
||||||
pushd "$install_dir/discourse"
|
pushd "$install_dir/discourse"
|
||||||
# Regenerate assets
|
# Regenerate assets
|
||||||
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake assets:precompile
|
ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production bin/rake assets:precompile
|
||||||
|
|
||||||
# Regenerate all forum posts
|
# Regenerate all forum posts
|
||||||
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production bin/rake posts:rebake
|
ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production bin/rake posts:rebake
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -131,21 +131,21 @@ pushd "$install_dir/discourse"
|
||||||
if dpkg --print-architecture | grep -q "arm"; then
|
if dpkg --print-architecture | grep -q "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
|
||||||
ynh_exec_as "$app" -E "$install_dir/discourse/bin/bundle" config specific_platform arm-linux
|
_exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config specific_platform arm-linux
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
ynh_exec_as "$app" -E "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle'
|
_exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle'
|
||||||
ynh_exec_as "$app" -E "$install_dir/discourse/bin/bundle" config set without test development
|
_exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config set without test development
|
||||||
ynh_exec_as "$app" -E MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2
|
_exec_as_app_with_ruby_node MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2
|
||||||
popd
|
popd
|
||||||
|
|
||||||
pushd "$install_dir/discourse"
|
pushd "$install_dir/discourse"
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
ynh_npm install --location=global terser
|
ynh_npm install --location=global terser
|
||||||
ynh_npm install --location=global uglify-js
|
ynh_npm install --location=global uglify-js
|
||||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn install --frozen-lockfile
|
ynh_exec_warn_less _exec_as_app_with_ruby_node yarn install --frozen-lockfile
|
||||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn cache clean
|
ynh_exec_warn_less _exec_as_app_with_ruby_node yarn cache clean
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -154,8 +154,8 @@ popd
|
||||||
ynh_script_progression --message="Preparing the database..."
|
ynh_script_progression --message="Preparing the database..."
|
||||||
|
|
||||||
pushd "$install_dir/discourse"
|
pushd "$install_dir/discourse"
|
||||||
ynh_exec_warn_less ynh_exec_as "$app" -E RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate
|
ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate
|
||||||
ynh_exec_warn_less ynh_exec_as "$app" -E RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile
|
ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Set default data (especially to have correct image URLs for subfolder install)
|
# Set default data (especially to have correct image URLs for subfolder install)
|
||||||
|
@ -169,7 +169,7 @@ ynh_secure_remove --file="$install_dir/provisioning.sql"
|
||||||
ynh_script_progression --message="Creating Discourse admin user..."
|
ynh_script_progression --message="Creating Discourse admin user..."
|
||||||
|
|
||||||
pushd "$install_dir/discourse"
|
pushd "$install_dir/discourse"
|
||||||
ynh_exec_as "$app" -E RAILS_ENV=production bin/rake admin:create <<< "$admin_mail
|
_exec_as_app_with_ruby_node RAILS_ENV=production bin/rake admin:create <<< "$admin_mail
|
||||||
$admin_pwd
|
$admin_pwd
|
||||||
$admin_pwd
|
$admin_pwd
|
||||||
y
|
y
|
||||||
|
|
|
@ -152,13 +152,13 @@ popd
|
||||||
if dpkg --print-architecture | grep -q "arm"; then
|
if dpkg --print-architecture | grep -q "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
|
||||||
ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config specific_platform arm-linux
|
_exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config specific_platform arm-linux
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle'
|
_exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config set path 'vendor/bundle'
|
||||||
ynh_exec_as "$app" --login "$install_dir/discourse/bin/bundle" config set with 'development'
|
_exec_as_app_with_ruby_node "$install_dir/discourse/bin/bundle" config set with 'development'
|
||||||
ynh_exec_as "$app" --login MAKEFLAGS=-j2 "$install_dir/discourse/bin/bundle" install --jobs 2
|
_exec_as_app_with_ruby_node MAKEFLAGS=-j2 "$install_dir/discourse/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
|
||||||
|
@ -174,8 +174,8 @@ pushd "$install_dir/discourse"
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
ynh_npm install --location=global terser
|
ynh_npm install --location=global terser
|
||||||
ynh_npm install --location=global uglify-js
|
ynh_npm install --location=global uglify-js
|
||||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn install --production --frozen-lockfile
|
ynh_exec_warn_less _exec_as_app_with_ruby_node yarn install --production --frozen-lockfile
|
||||||
ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" yarn cache clean
|
ynh_exec_warn_less _exec_as_app_with_ruby_node yarn cache clean
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -185,8 +185,8 @@ popd
|
||||||
ynh_script_progression --message="Preparing the database..."
|
ynh_script_progression --message="Preparing the database..."
|
||||||
|
|
||||||
pushd "$install_dir/discourse"
|
pushd "$install_dir/discourse"
|
||||||
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate
|
ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake db:migrate
|
||||||
ynh_exec_warn_less ynh_exec_as "$app" --login RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile
|
ynh_exec_warn_less _exec_as_app_with_ruby_node RAILS_ENV=production "$install_dir/discourse/bin/bundle" exec rake themes:update assets:precompile
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue