1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mastodon_ynh.git synced 2024-09-03 19:46:02 +02:00

Apply last example_ynh

This commit is contained in:
yalh76 2022-09-20 01:57:06 +02:00
parent efa2d62892
commit ff82206caa
9 changed files with 296 additions and 293 deletions

View file

@ -1,9 +1,9 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" domain="domain.tld"
is_public=1
admin="john" admin="john"
language="fr_FR" language="fr_FR"
is_public=1
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=0 setup_sub_dir=0
@ -20,6 +20,8 @@
upgrade=1 from_commit=4d413848bf444586e28f3658de0ebe36d6ebf059 upgrade=1 from_commit=4d413848bf444586e28f3658de0ebe36d6ebf059
# 3.5.3~ynh1 # 3.5.3~ynh1
upgrade=1 from_commit=acdc124f76fb9724cb22acb18c45cf0c3c2e62b5 upgrade=1 from_commit=acdc124f76fb9724cb22acb18c45cf0c3c2e62b5
# 3.5.3~ynh3
upgrade=1 from_commit=efa2d628920edce255ff406b28a97b1dd20e3d74
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
change_url=0 change_url=0

View file

@ -6,7 +6,7 @@
"en": "Libre and federated social network", "en": "Libre and federated social network",
"fr": "Réseau social libre et fédéré" "fr": "Réseau social libre et fédéré"
}, },
"version": "3.5.3~ynh3", "version": "3.5.3~ynh4",
"url": "https://github.com/mastodon/mastodon", "url": "https://github.com/mastodon/mastodon",
"upstream": { "upstream": {
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",

View file

@ -4,32 +4,34 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app (must be on a single line)
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="" build_pkg_dependencies=""
memory_needed="2560" memory_needed="2560"
ruby_version=3.0.3 ruby_version=3.0.3
nodejs_version=12 nodejs_version=16
# 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
if [ "$(lsb_release --codename --short)" = "bullseye" ]; then if [ "$(lsb_release --codename --short)" = "bullseye" ]; then
case $YNH_ARCH in case $YNH_ARCH in
amd64) amd64)
arch="x86_64" ld_preload="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so"
;; ;;
arm64) arm64)
arch="aarch64" ld_preload="LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libjemalloc.so"
;; ;;
armel|armhf) armhf)
arch="arm" ld_preload="LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libjemalloc.so"
;;
armel)
ld_preload="LD_PRELOAD=/usr/lib/arm-linux-gnueabi/libjemalloc.so"
;; ;;
i386) i386)
arch="i386" ld_preload="LD_PRELOAD=/usr/lib/i386-linux-gnu/libjemalloc.so"
;; ;;
esac esac
ld_preload="LD_PRELOAD=/usr/lib/$arch-linux-gnu/libjemalloc.so"
else else
ld_preload="" ld_preload=""
fi fi

View file

@ -16,7 +16,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
@ -31,14 +31,14 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE language=$YNH_APP_ARG_LANGUAGE
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#================================================= #=================================================
ynh_script_progression --message="Validating installation parameters..." ynh_script_progression --message="Validating installation parameters..." --weight=1
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
@ -49,7 +49,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Storing installation settings..." ynh_script_progression --message="Storing installation settings..." --weight=1
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
@ -61,7 +61,7 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Finding an available port..." ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port # Find an available port
port_web=$(ynh_find_port --port=3000) port_web=$(ynh_find_port --port=3000)
@ -73,7 +73,7 @@ ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
@ -83,7 +83,7 @@ ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yar
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." ynh_script_progression --message="Configuring system user..." --weight=1
# 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"
@ -91,7 +91,7 @@ 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..." --weight=1
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)
@ -105,7 +105,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
@ -118,7 +118,7 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configuring NGINX web server..." ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
@ -128,7 +128,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# ADD SWAP IF NEEDED # ADD SWAP IF NEEDED
#================================================= #=================================================
ynh_script_progression --message="Adding swap if needed..." ynh_script_progression --message="Adding swap if needed..." --weight=1
total_memory=$(ynh_get_ram --total) total_memory=$(ynh_get_ram --total)
swap_needed=0 swap_needed=0
@ -144,7 +144,7 @@ ynh_add_swap --size=$swap_needed
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." ynh_script_progression --message="Adding a configuration file..." --weight=1
config="$final_path/live/.env.production" config="$final_path/live/.env.production"
@ -178,7 +178,7 @@ chown $app:$app "$final_path/live/config/settings.yml"
#================================================= #=================================================
# BUILD APP # BUILD APP
#================================================= #=================================================
ynh_script_progression --message="Building app..." ynh_script_progression --message="Building app..." --weight=1
pushd "$final_path/live" pushd "$final_path/live"
ynh_use_ruby ynh_use_ruby
@ -219,7 +219,7 @@ ynh_package_autoremove
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configuring a systemd service..." ynh_script_progression --message="Configuring a systemd service..." --weight=1
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
@ -229,7 +229,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming
#================================================= #=================================================
# SETUP THE CRON FILE # SETUP THE CRON FILE
#================================================= #=================================================
ynh_script_progression --message="Setuping the cron file..." ynh_script_progression --message="Setuping the cron file..." --weight=1
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
@ -238,7 +238,7 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "$app-web" --description="$app web service" yunohost service add "$app-web" --description="$app web service"
yunohost service add "$app-sidekiq" --description="$app sidekiq service" yunohost service add "$app-sidekiq" --description="$app sidekiq service"
@ -247,7 +247,7 @@ yunohost service add "$app-streaming" --description="$app streaming service"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on" ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded" ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
@ -256,7 +256,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
@ -271,7 +271,7 @@ ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --aut
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -279,4 +279,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" ynh_script_progression --message="Installation of $app completed" --last

View file

@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -32,26 +32,26 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null
then then
ynh_script_progression --message="Removing $app-web service integration..." ynh_script_progression --message="Removing $app-web service integration..." --weight=1
yunohost service remove "$app-web" yunohost service remove "$app-web"
fi fi
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null
then then
ynh_script_progression --message="Removing $app-sidekiq service integration..." ynh_script_progression --message="Removing $app-sidekiq service integration..." --weight=1
yunohost service remove "$app-sidekiq" yunohost service remove "$app-sidekiq"
fi fi
if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null
then then
ynh_script_progression --message="Removing $app-streaming service integration..." ynh_script_progression --message="Removing $app-streaming service integration..." --weight=1
yunohost service remove "$app-streaming" yunohost service remove "$app-streaming"
fi fi
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config --service="$app-web" ynh_remove_systemd_config --service="$app-web"
@ -61,7 +61,7 @@ ynh_remove_systemd_config --service="$app-streaming"
#================================================= #=================================================
# REMOVE THE POSTGRESQL DATABASE # REMOVE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
@ -69,7 +69,7 @@ ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
@ -77,7 +77,7 @@ ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -85,7 +85,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_ruby ynh_remove_ruby
@ -97,7 +97,7 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE VARIOUS FILES # REMOVE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Removing various files..." ynh_script_progression --message="Removing various files..." --weight=1
# Remove a cron file # Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app" ynh_secure_remove --file="/etc/cron.d/$app"
@ -110,7 +110,7 @@ ynh_del_swap
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app ynh_system_user_delete --username=$app
@ -119,4 +119,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" ynh_script_progression --message="Removal of $app completed" --last

View file

@ -17,7 +17,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
@ -25,7 +25,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -38,24 +38,17 @@ db_user=$(ynh_app_setting_get --app=$app --key=db_user)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# 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"
@ -63,7 +56,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
@ -76,7 +69,7 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies # Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
@ -84,10 +77,17 @@ ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_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" 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 NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
@ -98,7 +98,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
#================================================= #=================================================
# ADD SWAP IF NEEDED # ADD SWAP IF NEEDED
#================================================= #=================================================
ynh_script_progression --message="Adding swap if needed..." ynh_script_progression --message="Adding swap if needed..." --weight=1
total_memory=$(ynh_get_ram --total) total_memory=$(ynh_get_ram --total)
swap_needed=0 swap_needed=0
@ -108,13 +108,13 @@ if [ $total_memory -lt $memory_needed ]; then
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..." --weight=1
ynh_add_swap --size=$swap_needed ynh_add_swap --size=$swap_needed
#================================================= #=================================================
# BUILD APP # BUILD APP
#================================================= #=================================================
ynh_script_progression --message="Building app..." ynh_script_progression --message="Building app..." --weight=1
pushd "$final_path/live" pushd "$final_path/live"
ynh_use_ruby ynh_use_ruby
@ -129,14 +129,14 @@ ynh_package_autoremove
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Restoring various files..." ynh_script_progression --message="Restoring various files..." --weight=1
ynh_restore_file --origin_path="/etc/cron.d/$app" ynh_restore_file --origin_path="/etc/cron.d/$app"
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service"
@ -146,7 +146,7 @@ systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "$app-web" --description="$app web service" yunohost service add "$app-web" --description="$app web service"
yunohost service add "$app-sidekiq" --description="$app sidekiq service" yunohost service add "$app-sidekiq" --description="$app sidekiq service"
@ -155,7 +155,7 @@ yunohost service add "$app-streaming" --description="$app streaming service"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on" ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded" ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
@ -166,7 +166,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -174,4 +174,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -41,19 +41,18 @@ config="$final_path/live/.env.production"
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..." ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
@ -65,7 +64,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped" ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped"
ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped" ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped"
@ -74,7 +73,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=sy
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Cleaning legacy permissions # Cleaning legacy permissions
if ynh_legacy_permissions_exists; then if ynh_legacy_permissions_exists; then
@ -156,7 +155,7 @@ ynh_remove_extra_repo
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# 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"
@ -167,7 +166,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." ynh_script_progression --message="Upgrading source files..." --weight=1
# Download Mastodon # Download Mastodon
tmpdir="$(mktemp -d)" tmpdir="$(mktemp -d)"
@ -195,30 +194,30 @@ chmod 750 "$final_path"
chmod -R o-rwx "$final_path" chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies
ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version ynh_exec_warn_less ynh_install_ruby --ruby_version=$ruby_version
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_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" 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"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# ADD SWAP IF NEEDED # ADD SWAP IF NEEDED
#================================================= #=================================================
ynh_script_progression --message="Adding swap if needed..." ynh_script_progression --message="Adding swap if needed..." --weight=1
total_memory=$(ynh_get_ram --total) total_memory=$(ynh_get_ram --total)
swap_needed=0 swap_needed=0
@ -234,7 +233,7 @@ ynh_add_swap --size=$swap_needed
#================================================= #=================================================
# BUILD APP # BUILD APP
#================================================= #=================================================
ynh_script_progression --message="Building app..." ynh_script_progression --message="Building app..." --weight=1
pushd "$final_path/live" pushd "$final_path/live"
ynh_use_ruby ynh_use_ruby
@ -258,7 +257,7 @@ ynh_package_autoremove
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a config file..." ynh_script_progression --message="Updating a config file..." --weight=1
language="$(echo $language | head -c 2)" language="$(echo $language | head -c 2)"
@ -270,7 +269,7 @@ chown $app:$app "$config"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Upgrading systemd configuration..." ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service"
@ -280,7 +279,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming
#================================================= #=================================================
# SETUP THE CRON FILE # SETUP THE CRON FILE
#================================================= #=================================================
ynh_script_progression --message="Setuping the cron file..." ynh_script_progression --message="Setuping the cron file..." --weight=1
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
@ -289,7 +288,7 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add "$app-web" --description="$app web service" yunohost service add "$app-web" --description="$app web service"
yunohost service add "$app-sidekiq" --description="$app sidekiq service" yunohost service add "$app-sidekiq" --description="$app sidekiq service"
@ -298,7 +297,7 @@ yunohost service add "$app-streaming" --description="$app streaming service"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on" ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on"
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded" ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded"
@ -307,7 +306,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server..." ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -315,4 +314,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" ynh_script_progression --message="Upgrade of $app completed" --last