mirror of
https://github.com/YunoHost-Apps/mastodon_ynh.git
synced 2024-09-03 19:46:02 +02:00
Merge pull request #329 from YunoHost-Apps/example
Apply last example_ynh
This commit is contained in:
commit
319abe79a2
10 changed files with 88 additions and 93 deletions
|
@ -10,7 +10,8 @@ Environment="__LD_PRELOAD__"
|
||||||
Environment="RAILS_ENV=production"
|
Environment="RAILS_ENV=production"
|
||||||
Environment="DB_POOL=25"
|
Environment="DB_POOL=25"
|
||||||
Environment="MALLOC_ARENA_MAX=2"
|
Environment="MALLOC_ARENA_MAX=2"
|
||||||
ExecStart=__RBENV_ROOT__/versions/__APP__/bin/bundle exec sidekiq -c 25
|
Environment="__YNH_RUBY_LOAD_PATH__"
|
||||||
|
ExecStart=__FINALPATH__/live/bin/bundle exec sidekiq -c 25
|
||||||
TimeoutSec=15
|
TimeoutSec=15
|
||||||
Restart=always
|
Restart=always
|
||||||
StandardError=syslog
|
StandardError=syslog
|
||||||
|
|
|
@ -9,7 +9,8 @@ WorkingDirectory=__FINALPATH__/live
|
||||||
Environment="__LD_PRELOAD__"
|
Environment="__LD_PRELOAD__"
|
||||||
Environment="RAILS_ENV=production"
|
Environment="RAILS_ENV=production"
|
||||||
Environment="PORT=__PORT_WEB__"
|
Environment="PORT=__PORT_WEB__"
|
||||||
ExecStart=__RBENV_ROOT__/versions/__APP__/bin/bundle exec puma -C config/puma.rb
|
Environment="__YNH_RUBY_LOAD_PATH__"
|
||||||
|
ExecStart=__FINALPATH__/live/bin/bundle exec puma -C config/puma.rb
|
||||||
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
||||||
TimeoutSec=15
|
TimeoutSec=15
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
|
@ -42,10 +42,6 @@
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "domain"
|
"type": "domain"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "admin",
|
|
||||||
"type": "user"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
@ -63,6 +59,10 @@
|
||||||
"fr_FR"
|
"fr_FR"
|
||||||
],
|
],
|
||||||
"default": "fr_FR"
|
"default": "fr_FR"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "admin",
|
||||||
|
"type": "user"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,11 @@
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3|libgdbm6 libgdbm-dev redis-tools redis-server postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https"
|
pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3|libgdbm6 libgdbm-dev redis-tools redis-server postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https"
|
||||||
|
build_pkg_dependencies=""
|
||||||
|
|
||||||
MEMORY_NEEDED="2560"
|
memory_needed="2560"
|
||||||
|
ruby_version=2.7.2
|
||||||
RUBY_VERSION="2.7.2"
|
nodejs_version=12
|
||||||
|
|
||||||
NODEJS_VERSION="12"
|
|
||||||
|
|
||||||
# Workaround for Mastodon on Bullseye
|
# Workaround for Mastodon on Bullseye
|
||||||
# See https://github.com/mastodon/mastodon/issues/15751#issuecomment-873594463
|
# See https://github.com/mastodon/mastodon/issues/15751#issuecomment-873594463
|
||||||
|
|
|
@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
ynh_clean_check_starting
|
true
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
|
@ -27,11 +27,11 @@ ynh_abort_if_errors
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url="/"
|
path_url="/"
|
||||||
admin=$YNH_APP_ARG_ADMIN
|
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
language=$YNH_APP_ARG_LANGUAGE
|
language=$YNH_APP_ARG_LANGUAGE
|
||||||
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
|
|
||||||
admin_mail=$(ynh_user_get_info $admin 'mail')
|
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ ynh_script_progression --message="Storing installation settings..."
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
|
||||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||||
|
ynh_app_setting_set --app=$app --key=admin --value=$admin
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
|
@ -75,10 +75,10 @@ ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing dependencies..."
|
ynh_script_progression --message="Installing dependencies..."
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
|
@ -86,24 +86,21 @@ ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||||
ynh_script_progression --message="Configuring system user..."
|
ynh_script_progression --message="Configuring system user..."
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A POSTGRESQL DATABASE
|
# CREATE A POSTGRESQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a PostgreSQL database..."
|
ynh_script_progression --message="Creating a PostgreSQL database..."
|
||||||
|
|
||||||
|
|
||||||
# Create PostgreSQL database
|
|
||||||
db_name=$(ynh_sanitize_dbid --db_name="${app}_production")
|
db_name=$(ynh_sanitize_dbid --db_name="${app}_production")
|
||||||
db_user=$(ynh_sanitize_dbid --db_name=$app)
|
db_user=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
db_pwd=$(ynh_string_random --length=30)
|
|
||||||
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
|
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
|
||||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
|
||||||
ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
|
ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
|
||||||
|
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -136,25 +133,14 @@ ynh_script_progression --message="Adding swap if needed..."
|
||||||
total_memory=$(ynh_get_ram --total)
|
total_memory=$(ynh_get_ram --total)
|
||||||
swap_needed=0
|
swap_needed=0
|
||||||
|
|
||||||
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
if [ $total_memory -lt $memory_needed ]; then
|
||||||
# Need a minimum of 2.5Go of memory
|
# Need a minimum of 2.5Go of memory
|
||||||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
swap_needed=$(($memory_needed - $total_memory))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||||
ynh_add_swap --size=$swap_needed
|
ynh_add_swap --size=$swap_needed
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INSTALLING RUBY AND BUNDLER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Installing Ruby..."
|
|
||||||
|
|
||||||
pushd "$final_path/live"
|
|
||||||
ynh_use_ruby
|
|
||||||
ynh_gem update --system
|
|
||||||
ynh_gem install bundler --no-document
|
|
||||||
popd
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADD A CONFIGURATION
|
# ADD A CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -190,21 +176,14 @@ chmod 400 "$final_path/live/config/settings.yml"
|
||||||
chown $app:$app "$final_path/live/config/settings.yml"
|
chown $app:$app "$final_path/live/config/settings.yml"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Configuring a systemd service..."
|
ynh_script_progression --message="Building app..."
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
|
||||||
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
|
|
||||||
ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service"
|
|
||||||
ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INSTALLING MASTODON
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Installing Mastodon..."
|
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
|
ynh_use_ruby
|
||||||
|
ynh_gem update --system
|
||||||
|
ynh_gem install bundler --no-document
|
||||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config deployment 'true'
|
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config deployment 'true'
|
||||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config without 'development test'
|
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config without 'development test'
|
||||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config set force_ruby_platform true
|
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config set force_ruby_platform true
|
||||||
|
@ -234,6 +213,19 @@ ynh_add_config --template="../conf/.env.production.sample" --destination="$confi
|
||||||
chmod 400 "$config"
|
chmod 400 "$config"
|
||||||
chown $app:$app "$config"
|
chown $app:$app "$config"
|
||||||
|
|
||||||
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
ynh_package_autoremove
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SYSTEMD
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring a systemd service..."
|
||||||
|
|
||||||
|
# Create a dedicated systemd config
|
||||||
|
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
|
||||||
|
ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service"
|
||||||
|
ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP THE CRON FILE
|
# SETUP THE CRON FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -91,7 +91,6 @@ ynh_script_progression --message="Removing dependencies..."
|
||||||
ynh_remove_ruby
|
ynh_remove_ruby
|
||||||
ynh_remove_nodejs
|
ynh_remove_nodejs
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
ynh_remove_extra_repo
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC REMOVE
|
# SPECIFIC REMOVE
|
||||||
|
|
|
@ -34,7 +34,6 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
@ -59,7 +58,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
ynh_script_progression --message="Recreating the dedicated system user..."
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
# Create the dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE APP MAIN DIR
|
# RESTORE THE APP MAIN DIR
|
||||||
|
@ -80,10 +79,10 @@ chown -R $app:www-data "$final_path"
|
||||||
ynh_script_progression --message="Reinstalling dependencies..."
|
ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
|
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE POSTGRESQL DATABASE
|
# RESTORE THE POSTGRESQL DATABASE
|
||||||
|
@ -91,6 +90,7 @@ ynh_install_ruby --ruby_version=$RUBY_VERSION
|
||||||
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
ynh_script_progression --message="Restoring the PostgreSQL database..."
|
||||||
|
|
||||||
ynh_psql_test_if_first_run
|
ynh_psql_test_if_first_run
|
||||||
|
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||||
ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
|
ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
|
||||||
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
|
||||||
|
@ -103,18 +103,18 @@ ynh_script_progression --message="Adding swap if needed..."
|
||||||
total_memory=$(ynh_get_ram --total)
|
total_memory=$(ynh_get_ram --total)
|
||||||
swap_needed=0
|
swap_needed=0
|
||||||
|
|
||||||
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
if [ $total_memory -lt $memory_needed ]; then
|
||||||
# Need a minimum of 8Go of memory
|
# Need a minimum of 8Go of memory
|
||||||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
swap_needed=$(($memory_needed - $total_memory))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||||
ynh_add_swap --size=$swap_needed
|
ynh_add_swap --size=$swap_needed
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALLING RUBY AND BUNDLER
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing Ruby..."
|
ynh_script_progression --message="Building app..."
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
ynh_use_ruby
|
ynh_use_ruby
|
||||||
|
@ -123,6 +123,9 @@ pushd "$final_path/live"
|
||||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install --redownload -j$(getconf _NPROCESSORS_ONLN)
|
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install --redownload -j$(getconf _NPROCESSORS_ONLN)
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
ynh_package_autoremove
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE VARIOUS FILES
|
# RESTORE VARIOUS FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -20,13 +20,13 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
language=$(ynh_app_setting_get --app=$app --key=language)
|
||||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
language=$(ynh_app_setting_get --app=$app --key=language)
|
|
||||||
redis_namespace=$(ynh_app_setting_get --app=$app --key=db_name)
|
redis_namespace=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
db_user=$(ynh_app_setting_get --app=$app --key=db_user)
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
|
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
|
||||||
admin_mail=$(ynh_user_get_info --username=$admin --key='mail')
|
admin_mail=$(ynh_user_get_info --username=$admin --key='mail')
|
||||||
port_web=$(ynh_app_setting_get --app=$app --key=port_web)
|
port_web=$(ynh_app_setting_get --app=$app --key=port_web)
|
||||||
port_stream=$(ynh_app_setting_get --app=$app --key=port_stream)
|
port_stream=$(ynh_app_setting_get --app=$app --key=port_stream)
|
||||||
|
@ -159,7 +159,7 @@ ynh_remove_extra_repo
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
ynh_script_progression --message="Making sure dedicated system user exists..."
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
# Create a dedicated user (if not existing)
|
||||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -208,10 +208,10 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..."
|
ynh_script_progression --message="Upgrading dependencies..."
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
|
||||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
|
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
|
||||||
ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||||
ynh_install_ruby --ruby_version=$RUBY_VERSION
|
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
|
@ -223,25 +223,38 @@ ynh_script_progression --message="Adding swap if needed..."
|
||||||
total_memory=$(ynh_get_ram --total)
|
total_memory=$(ynh_get_ram --total)
|
||||||
swap_needed=0
|
swap_needed=0
|
||||||
|
|
||||||
if [ $total_memory -lt $MEMORY_NEEDED ]; then
|
if [ $total_memory -lt $memory_needed ]; then
|
||||||
# Need a minimum of 8Go of memory
|
# Need a minimum of 8Go of memory
|
||||||
swap_needed=$(($MEMORY_NEEDED - $total_memory))
|
swap_needed=$(($memory_needed - $total_memory))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
|
||||||
ynh_add_swap --size=$swap_needed
|
ynh_add_swap --size=$swap_needed
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALLING RUBY AND BUNDLER
|
# BUILD APP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing Ruby..."
|
ynh_script_progression --message="Building app..."
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
ynh_use_ruby
|
ynh_use_ruby
|
||||||
ynh_gem update --system
|
ynh_gem update --system
|
||||||
ynh_gem install bundler --no-document
|
ynh_gem install bundler --no-document
|
||||||
|
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config deployment 'true'
|
||||||
|
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config without 'development test'
|
||||||
|
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config set force_ruby_platform true --quiet
|
||||||
|
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
|
||||||
|
ynh_use_nodejs
|
||||||
|
ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile
|
||||||
|
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:clean
|
||||||
|
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:precompile
|
||||||
|
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:migrate
|
||||||
|
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl cache clear
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
ynh_package_autoremove
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# UPDATE A CONFIG FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -264,24 +277,6 @@ ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
|
||||||
ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service"
|
ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service"
|
||||||
ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service"
|
ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# UPGRADE MASTODON
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading Mastodon..."
|
|
||||||
|
|
||||||
pushd "$final_path/live"
|
|
||||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config deployment 'true'
|
|
||||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config without 'development test'
|
|
||||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle config set force_ruby_platform true --quiet
|
|
||||||
ynh_exec_as $app $ynh_ruby_load_path $ld_preload bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
|
|
||||||
ynh_use_nodejs
|
|
||||||
ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile
|
|
||||||
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:clean
|
|
||||||
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails assets:precompile
|
|
||||||
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/bundle exec rails db:migrate
|
|
||||||
ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path $ld_preload bin/tootctl cache clear
|
|
||||||
popd
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP THE CRON FILE
|
# SETUP THE CRON FILE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -14,6 +14,11 @@ ruby_version_path="$rbenv_install_dir/versions"
|
||||||
export RBENV_ROOT="$rbenv_install_dir"
|
export RBENV_ROOT="$rbenv_install_dir"
|
||||||
export rbenv_root="$rbenv_install_dir"
|
export rbenv_root="$rbenv_install_dir"
|
||||||
|
|
||||||
|
ruby_dependencies=""
|
||||||
|
build_ruby_dependencies="libjemalloc-dev curl build-essential libreadline-dev zlib1g-dev libsqlite3-dev libssl-dev libxml2-dev libxslt-dev autoconf automake bison libtool"
|
||||||
|
pkg_dependencies="$pkg_dependencies $ruby_dependencies"
|
||||||
|
build_pkg_dependencies="$build_pkg_dependencies $build_ruby_dependencies"
|
||||||
|
|
||||||
# Load the version of Ruby for an app, and set variables.
|
# Load the version of Ruby for an app, and set variables.
|
||||||
#
|
#
|
||||||
# ynh_use_ruby has to be used in any app scripts before using Ruby for the first time.
|
# ynh_use_ruby has to be used in any app scripts before using Ruby for the first time.
|
||||||
|
@ -37,9 +42,9 @@ export rbenv_root="$rbenv_install_dir"
|
||||||
# Finally, to start a Ruby service with the correct version, 2 solutions
|
# Finally, to start a Ruby service with the correct version, 2 solutions
|
||||||
# Either the app is dependent of Ruby or gem, but does not called it directly.
|
# Either the app is dependent of Ruby or gem, but does not called it directly.
|
||||||
# In such situation, you need to load PATH
|
# In such situation, you need to load PATH
|
||||||
# `Environment="__YNH_RUBY_LOAD_ENV_PATH__"`
|
# `Environment="__YNH_RUBY_LOAD_PATH__"`
|
||||||
# `ExecStart=__FINALPATH__/my_app`
|
# `ExecStart=__FINALPATH__/my_app`
|
||||||
# You will replace __YNH_RUBY_LOAD_ENV_PATH__ with $ynh_ruby_load_path
|
# You will replace __YNH_RUBY_LOAD_PATH__ with $ynh_ruby_load_path
|
||||||
#
|
#
|
||||||
# Or Ruby start the app directly, then you don't need to load the PATH variable
|
# Or Ruby start the app directly, then you don't need to load the PATH variable
|
||||||
# `ExecStart=__YNH_RUBY__ my_app run`
|
# `ExecStart=__YNH_RUBY__ my_app run`
|
||||||
|
|
Loading…
Reference in a new issue