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

apply last example_ynh for ynh_script_progression

This commit is contained in:
yalh76 2020-06-02 18:34:04 +02:00
parent 960d1c7d65
commit 8fea96dcd8
5 changed files with 77 additions and 81 deletions

View file

@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_script_progression --message="Managing script failure..." --weight=1
ynh_clean_setup () {
ynh_clean_check_starting
@ -24,7 +23,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -68,7 +67,7 @@ ynh_backup --src_path="/etc/cron.d/$app"
#=================================================
# BACKUP THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Backing up the PostgreSQL database..." --weight=4
ynh_print_info --message="Backing up the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql
@ -76,4 +75,4 @@ ynh_psql_dump_db --database="$db_name" > db.sql
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_script_progression --message="Managing script failure..." --weight=1
ynh_clean_setup () {
ynh_clean_check_starting
@ -25,7 +24,6 @@ ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
ynh_script_progression --message="Retrieving arguments from the manifest..." --weight=1
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
@ -40,7 +38,7 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=2
ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
@ -51,7 +49,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
@ -64,7 +62,7 @@ ynh_app_setting_set --app=$app --key=language --value=$language
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Configuring firewall..." --weight=1
ynh_script_progression --message="Configuring firewall..."
# Find an available port
port_web=$(ynh_find_port --port=3000)
@ -76,7 +74,7 @@ ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=86
ynh_script_progression --message="Installing dependencies..."
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_install_app_dependencies $pkg_dependencies
@ -85,7 +83,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=5
ynh_script_progression --message="Creating a MySQL database..."
# Create postgresql database
db_name="${app}_production"
@ -100,7 +98,7 @@ ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=5
ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
@ -113,7 +111,7 @@ ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_strin
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring nginx web server..." --weight=3
ynh_script_progression --message="Configuring nginx web server..."
# Create a dedicated nginx config
ynh_add_nginx_config 'port_web port_stream'
@ -121,7 +119,7 @@ ynh_add_nginx_config 'port_web port_stream'
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=4
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
@ -131,7 +129,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# ADD SWAP IF NEEDED
#=================================================
ynh_script_progression --message="Adding swap is needed..." --weight=4
ynh_script_progression --message="Adding swap is needed..."
total_memory=$(ynh_get_ram --total)
swap_needed=0
@ -141,13 +139,13 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then
swap_needed=$(($MEMORY_NEEDED - $total_memory))
fi
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
ynh_add_swap --size=$swap_needed
#=================================================
# INSTALLING RUBY AND BUNDLER
#=================================================
ynh_script_progression --message="Installing Ruby..." --weight=424
ynh_script_progression --message="Installing Ruby..."
ynh_install_ruby --ruby_version=$RUBY_VERSION
pushd "$final_path/live"
@ -158,7 +156,7 @@ popd
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=2
ynh_script_progression --message="Modifying a config file..."
config="$final_path/live/.env.production"
cp -f ../conf/.env.production.sample "$config"
@ -189,7 +187,7 @@ ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="m
#=================================================
# INSTALLING MASTODON
#=================================================
ynh_script_progression --message="Installing Mastodon..." --weight=2230
ynh_script_progression --message="Installing Mastodon..."
chown -R "$app": "$final_path"
@ -221,7 +219,7 @@ ynh_secure_remove --file="$final_path/live/key.txt"
#=================================================
# SETUP THE CRON FILE
#=================================================
ynh_script_progression --message="Setuping the cron file..." --weight=1
ynh_script_progression --message="Setuping the cron file..."
ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron"
cp -f ../conf/cron /etc/cron.d/$app
@ -229,7 +227,7 @@ cp -f ../conf/cron /etc/cron.d/$app
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=5
ynh_script_progression --message="Configuring a systemd service..."
# Create a dedicated systemd config
ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service"
@ -244,7 +242,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_script_progression --message="Storing the config file checksum..." --weight=1
ynh_script_progression --message="Storing the config file checksum..."
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$config"
@ -254,7 +252,7 @@ ynh_store_file_checksum --file="$config"
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..." --weight=9
ynh_script_progression --message="Securing files and directories..."
# Set permissions to app files
chown -R "$app": "$final_path"
@ -262,7 +260,7 @@ chown -R "$app": "$final_path"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=3
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add "$app-web" --description "$app web service" --log_type "systemd"
yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd"
@ -271,7 +269,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" --l
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=47
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp"
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing"
@ -280,7 +278,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring SSOwat..." --weight=2
ynh_script_progression --message="Configuring SSOwat..."
# Make app public if necessary
if [ $is_public -eq 1 ]
@ -292,7 +290,7 @@ fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=2
ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload
@ -300,4 +298,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed" --last
ynh_script_progression --message="Installation of $app completed"

View file

@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=6
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -28,31 +28,30 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
ynh_script_progression --message="Removing service integration in YunoHost..." --weight=2
# 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
then
ynh_script_progression --message="Removing $app-web service..." --weight=2
ynh_script_progression --message="Removing $app-web service..."
yunohost service remove "$app-web"
fi
if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null
then
ynh_script_progression --message="Removing $app-sidekiq service..." --weight=2
ynh_script_progression --message="Removing $app-sidekiq service..."
yunohost service remove "$app-sidekiq"
fi
if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null
then
ynh_script_progression --message="Removing $app-streaming service..." --weight=2
ynh_script_progression --message="Removing $app-streaming service..."
yunohost service remove "$app-streaming"
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=27
ynh_script_progression --message="Stopping and removing the systemd service..."
# Remove the dedicated systemd config
ynh_remove_systemd_config --service="$app-web"
@ -62,7 +61,7 @@ ynh_remove_systemd_config --service="$app-streaming"
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4
ynh_script_progression --message="Removing the PostgreSQL database..."
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
@ -70,7 +69,7 @@ ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name"
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=28
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_ruby
@ -81,7 +80,7 @@ ynh_remove_extra_repo
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=16
ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
@ -89,7 +88,7 @@ ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing nginx web server configuration..." --weight=2
ynh_script_progression --message="Removing nginx web server configuration..."
# Remove the dedicated nginx config
ynh_remove_nginx_config
@ -99,7 +98,7 @@ ynh_remove_nginx_config
#=================================================
# REMOVE THE CRON FILE
#=================================================
ynh_script_progression --message="Removing the cron file..." --weight=2
ynh_script_progression --message="Removing the cron file..."
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
@ -112,7 +111,7 @@ ynh_del_swap
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=2
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app
@ -121,4 +120,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed" --last
ynh_script_progression --message="Removal of $app completed"

View file

@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_script_progression --message="Managing script failure..." --weight=2
ynh_script_progression --message="Managing script failure..."
ynh_clean_setup () {
ynh_clean_check_starting
@ -26,7 +26,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --weight=2
ynh_script_progression --message="Loading settings..."
app=$YNH_APP_INSTANCE_NAME
@ -40,7 +40,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2
ynh_script_progression --message="Validating restoration parameters..."
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
@ -52,21 +52,21 @@ test ! -d $final_path \
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring nginx configuration..." --weight=1
ynh_script_progression --message="Restoring the nginx configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=105
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=5
ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
@ -74,7 +74,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# RESTORE USER RIGHTS
#=================================================
ynh_script_progression --message="Restoring users rights..." --weight=4
ynh_script_progression --message="Restoring user rights..."
# Restore permissions on app files
chown -R $app: $final_path
@ -84,7 +84,7 @@ chown -R $app: $final_path
#=================================================
# ADD SWAP IF NEEDED
#=================================================
ynh_script_progression --message="Adding swap if needed..." --weight=4
ynh_script_progression --message="Adding swap if needed..."
total_memory=$(ynh_get_ram --total)
swap_needed=0
@ -94,13 +94,13 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then
swap_needed=$(($MEMORY_NEEDED - $total_memory))
fi
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
ynh_add_swap --size=$swap_needed
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=63
ynh_script_progression --message="Reinstalling dependencies..."
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
ynh_install_app_dependencies $pkg_dependencies
@ -109,7 +109,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
#=================================================
# INSTALLING RUBY AND BUNDLER
#=================================================
ynh_script_progression --message="Installing Ruby..." --weight=393
ynh_script_progression --message="Installing Ruby..."
ynh_install_ruby --ruby_version=$RUBY_VERSION
pushd "$final_path/live"
@ -120,7 +120,7 @@ popd
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=18
ynh_script_progression --message="Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
@ -130,7 +130,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=3
ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service"
ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service"
@ -140,7 +140,7 @@ systemctl enable "$app-web" "$app-sidekiq" "$app-streaming"
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=3
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add "$app-web" --description "$app web service" --log_type "systemd"
yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd"
@ -149,7 +149,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" --l
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=41
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp"
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing"
@ -158,7 +158,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
#=================================================
# RESTORE THE CRON FILE
#=================================================
ynh_script_progression --message="Restoring the cron file..." --weight=2
ynh_script_progression --message="Restoring the cron file..."
ynh_restore_file --origin_path="/etc/cron.d/$app"
@ -167,7 +167,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=2
ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload
@ -175,4 +175,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app" --last
ynh_script_progression --message="Restoration completed for $app"

View file

@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=4
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
@ -40,14 +40,14 @@ vapid_public_key=$(ynh_app_setting_get --app=$app --key=vapid_public_key)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..." --weight=1
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
ynh_script_progression --message="Ensuring downward compatibility..."
config="$final_path/live/.env.production"
@ -131,7 +131,7 @@ ynh_remove_extra_repo
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=442
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
@ -160,7 +160,7 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url)
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=22
ynh_script_progression --message="Stopping a systemd service..."
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"
@ -172,7 +172,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=sy
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=14
ynh_script_progression --message="Upgrading source files..."
# Download Mastodon
tmpdir="$(mktemp -d)"
@ -201,14 +201,14 @@ fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=3
ynh_script_progression --message="Upgrading nginx web server configuration..."
ynh_add_nginx_config 'port_web port_stream'
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=24
ynh_script_progression --message="Upgrading dependencies..."
ynh_remove_nodejs
ynh_install_nodejs --nodejs_version=$NODEJS_VERSION
@ -218,7 +218,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=7
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
@ -228,7 +228,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# ADD SWAP IF NEEDED
#=================================================
ynh_script_progression --message="Adding swap if needed..." --weight=7
ynh_script_progression --message="Adding swap if needed..."
total_memory=$(ynh_get_ram --total)
swap_needed=0
@ -238,13 +238,13 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then
swap_needed=$(($MEMORY_NEEDED - $total_memory))
fi
ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1
ynh_script_progression --message="Adding $swap_needed Mo to swap..."
ynh_add_swap --size=$swap_needed
#=================================================
# INSTALLING RUBY AND BUNDLER
#=================================================
ynh_script_progression --message="Installing Ruby..." --weight=424
ynh_script_progression --message="Installing Ruby..."
ynh_install_ruby --ruby_version=$RUBY_VERSION
pushd "$final_path/live"
@ -255,7 +255,7 @@ popd
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Modifying a config file..." --weight=1
ynh_script_progression --message="Modifying a config file..."
ynh_backup_if_checksum_is_different --file="$config"
cp -f ../conf/.env.production.sample "$config"
@ -280,7 +280,7 @@ ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapi
#=================================================
# UPGRADE MASTODON
#=================================================
ynh_script_progression --message="Upgrading Mastodon..." --weight=2640
ynh_script_progression --message="Upgrading Mastodon..."
chown -R "$app": "$final_path"
@ -302,7 +302,7 @@ ynh_store_file_checksum --file="$config"
#=================================================
# SETUP THE CRON FILE
#=================================================
ynh_script_progression --message="Setuping the cron file..." --weight=1
ynh_script_progression --message="Setuping the cron file..."
ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron"
cp -f ../conf/cron /etc/cron.d/$app
@ -310,7 +310,7 @@ cp -f ../conf/cron /etc/cron.d/$app
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=13
ynh_script_progression --message="Upgrading systemd configuration..."
# Create a dedicated systemd config
ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service"
@ -325,7 +325,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=3
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add "$app-web" --description "$app web service" --log_type "systemd"
yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd"
@ -336,7 +336,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" --l
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..." --weight=9
ynh_script_progression --message="Securing files and directories..."
# Set permissions on app files
chown -R $app: $final_path
@ -344,7 +344,7 @@ chown -R $app: $final_path
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1
ynh_script_progression --message="Upgrading SSOwat configuration..."
# Make app public if necessary
if [ $is_public -eq 1 ]
@ -356,7 +356,7 @@ fi
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=48
ynh_script_progression --message="Starting a systemd service..."
ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp"
ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing"
@ -365,7 +365,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading nginx web server..." --weight=2
ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload
@ -373,4 +373,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression --message="Upgrade of $app completed"