aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryalh76 <yalh@yahoo.com>2022-01-14 19:38:00 +0100
committerGitHub <noreply@github.com>2022-01-14 19:38:00 +0100
commit4d413848bf444586e28f3658de0ebe36d6ebf059 (patch)
tree19ecc95d4b3b68a0d74f3f1591a248b8de6ded47
parentfa8a9d4eed460fa73926e7874313091dffb7b9fc (diff)
parent536f2d51f2dade739c2e2ed3df96f472a2ad951b (diff)
downloadmastodon_ynh-4d413848bf444586e28f3658de0ebe36d6ebf059.tar.gz
mastodon_ynh-4d413848bf444586e28f3658de0ebe36d6ebf059.tar.bz2
mastodon_ynh-4d413848bf444586e28f3658de0ebe36d6ebf059.zip
Merge pull request #293 from YunoHost-Apps/testing
Full upgrade
-rw-r--r--check_process4
-rw-r--r--conf/.env.production.sample6
-rw-r--r--conf/app.src1
-rw-r--r--conf/mastodon-sidekiq.service30
-rw-r--r--conf/mastodon-streaming.service30
-rw-r--r--conf/mastodon-web.service30
-rw-r--r--scripts/backup2
-rw-r--r--scripts/install25
-rw-r--r--scripts/remove28
-rw-r--r--scripts/restore54
-rw-r--r--scripts/upgrade80
11 files changed, 200 insertions, 90 deletions
diff --git a/check_process b/check_process
index 0216939..2998fd0 100644
--- a/check_process
+++ b/check_process
@@ -14,6 +14,8 @@
upgrade=1
# 3.4.1~ynh1
upgrade=1 from_commit=efbdbb05350b820c6e59a7bbbf70f57cf679fff8
+ # 3.4.1~ynh4
+ upgrade=1 from_commit=adec07db890dec787416e1b7c4493d24391d3500
backup_restore=1
multi_instance=0
change_url=0
@@ -23,3 +25,5 @@ Notification=all
;;; Upgrade options
; commit=efbdbb05350b820c6e59a7bbbf70f57cf679fff8
name=3.4.1~ynh1
+ ; commit=adec07db890dec787416e1b7c4493d24391d3500
+ name=3.4.1~ynh4
diff --git a/conf/.env.production.sample b/conf/.env.production.sample
index 937a59e..21cc8e5 100644
--- a/conf/.env.production.sample
+++ b/conf/.env.production.sample
@@ -4,6 +4,12 @@
# not demonstrate all available configuration options. Please look at
# https://docs.joinmastodon.org/admin/config/ for the full documentation.
+# Note that this file accepts slightly different syntax depending on whether
+# you are using `docker-compose` or not. In particular, if you use
+# `docker-compose`, the value of each declared variable will be taken verbatim,
+# including surrounding quotes.
+# See: https://github.com/mastodon/mastodon/issues/16895
+
# Federation
# ----------
# This identifies your server and cannot be changed safely later
diff --git a/conf/app.src b/conf/app.src
index 1c9fc19..0bc40e6 100644
--- a/conf/app.src
+++ b/conf/app.src
@@ -3,4 +3,5 @@ SOURCE_SUM=567e57cc9d35306cbd708a33bc0bf1adf7981f3706ca4eced0d0c2b4f980034d
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
+SOURCE_FILENAME=
SOURCE_EXTRACT=true
diff --git a/conf/mastodon-sidekiq.service b/conf/mastodon-sidekiq.service
index 094813f..7fe2cc9 100644
--- a/conf/mastodon-sidekiq.service
+++ b/conf/mastodon-sidekiq.service
@@ -14,5 +14,35 @@ TimeoutSec=15
Restart=always
StandardError=syslog
+# Sandboxing options to harden security
+# Depending on specificities of your service/app, you may need to tweak these
+# .. but this should be a good baseline
+# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
+NoNewPrivileges=yes
+PrivateTmp=yes
+PrivateDevices=yes
+RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
+RestrictNamespaces=yes
+RestrictRealtime=yes
+DevicePolicy=closed
+ProtectSystem=full
+ProtectControlGroups=yes
+ProtectKernelModules=yes
+ProtectKernelTunables=yes
+LockPersonality=yes
+SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
+
+# Denying access to capabilities that should not be relevant for webapps
+# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
+CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
+CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
+CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
+CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
+CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
+CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
+CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
+CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
+CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
+
[Install]
WantedBy=multi-user.target
diff --git a/conf/mastodon-streaming.service b/conf/mastodon-streaming.service
index 673b7ae..19dd472 100644
--- a/conf/mastodon-streaming.service
+++ b/conf/mastodon-streaming.service
@@ -15,5 +15,35 @@ TimeoutSec=15
Restart=always
StandardError=syslog
+# Sandboxing options to harden security
+# Depending on specificities of your service/app, you may need to tweak these
+# .. but this should be a good baseline
+# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
+NoNewPrivileges=yes
+PrivateTmp=yes
+PrivateDevices=yes
+RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
+RestrictNamespaces=yes
+RestrictRealtime=yes
+DevicePolicy=closed
+ProtectSystem=full
+ProtectControlGroups=yes
+ProtectKernelModules=yes
+ProtectKernelTunables=yes
+LockPersonality=yes
+SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
+
+# Denying access to capabilities that should not be relevant for webapps
+# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
+CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
+CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
+CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
+CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
+CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
+CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
+CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
+CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
+CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
+
[Install]
WantedBy=multi-user.target
diff --git a/conf/mastodon-web.service b/conf/mastodon-web.service
index e853df5..3285e76 100644
--- a/conf/mastodon-web.service
+++ b/conf/mastodon-web.service
@@ -14,5 +14,35 @@ TimeoutSec=15
Restart=always
StandardError=syslog
+# Sandboxing options to harden security
+# Depending on specificities of your service/app, you may need to tweak these
+# .. but this should be a good baseline
+# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
+NoNewPrivileges=yes
+PrivateTmp=yes
+PrivateDevices=yes
+RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
+RestrictNamespaces=yes
+RestrictRealtime=yes
+DevicePolicy=closed
+ProtectSystem=full
+ProtectControlGroups=yes
+ProtectKernelModules=yes
+ProtectKernelTunables=yes
+LockPersonality=yes
+SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
+
+# Denying access to capabilities that should not be relevant for webapps
+# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
+CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
+CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
+CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
+CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
+CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
+CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
+CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
+CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
+CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
+
[Install]
WantedBy=multi-user.target
diff --git a/scripts/backup b/scripts/backup
index 590ce0f..2a64b32 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -59,7 +59,7 @@ ynh_backup --src_path="/etc/systemd/system/$app-sidekiq.service"
ynh_backup --src_path="/etc/systemd/system/$app-streaming.service"
#=================================================
-# BACKUP A CRON FILE
+# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/cron.d/$app"
diff --git a/scripts/install b/scripts/install
index e6960d1..3100891 100644
--- a/scripts/install
+++ b/scripts/install
@@ -86,7 +86,7 @@ ynh_install_ruby --ruby_version=$RUBY_VERSION
ynh_script_progression --message="Configuring 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
@@ -99,6 +99,7 @@ db_name=$(ynh_sanitize_dbid --db_name="${app}_production")
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_user --value=$db_user
ynh_app_setting_set --app=$app --key=db_pwd --value=$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;"
@@ -122,7 +123,7 @@ chown -R $app:www-data "$final_path"
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated NGINX config
-ynh_add_nginx_config 'port_web port_stream'
+ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
@@ -156,7 +157,7 @@ popd
#=================================================
# ADD A CONFIGURATION
#=================================================
-ynh_script_progression --message="Adding a config file..."
+ynh_script_progression --message="Adding a configuration file..."
config="$final_path/live/.env.production"
@@ -203,17 +204,17 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming
ynh_script_progression --message="Installing Mastodon..."
pushd "$final_path/live"
- sudo -u $app $ynh_ruby_load_path bin/bundle config deployment 'true'
- sudo -u $app $ynh_ruby_load_path bin/bundle config without 'development test'
- sudo -u $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
+ ynh_exec_as $app $ynh_ruby_load_path bin/bundle config deployment 'true'
+ ynh_exec_as $app $ynh_ruby_load_path bin/bundle config without 'development test'
+ ynh_exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
ynh_use_nodejs
- ynh_exec_warn_less sudo -u $app $ynh_node_load_PATH yarn install --pure-lockfile
+ ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH yarn install --pure-lockfile
echo "SAFETY_ASSURED=1">> $config
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:setup --quiet
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts modify "$admin" --approve
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:setup --quiet
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts modify "$admin" --approve
popd
vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt")
diff --git a/scripts/remove b/scripts/remove
index 42b0109..d6d2afd 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -20,7 +20,7 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$(ynh_sanitize_dbid --db_name=$app)
+db_user=$(ynh_app_setting_get --app=$app --key=db_user)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
@@ -67,17 +67,6 @@ ynh_script_progression --message="Removing the PostgreSQL database..."
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
-# REMOVE DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Removing dependencies..."
-
-# Remove metapackage and its dependencies
-ynh_remove_ruby
-ynh_remove_nodejs
-ynh_remove_app_dependencies
-ynh_remove_extra_repo
-
-#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..."
@@ -94,11 +83,22 @@ ynh_script_progression --message="Removing NGINX web server configuration..."
ynh_remove_nginx_config
#=================================================
+# REMOVE DEPENDENCIES
+#=================================================
+ynh_script_progression --message="Removing dependencies..."
+
+# Remove metapackage and its dependencies
+ynh_remove_ruby
+ynh_remove_nodejs
+ynh_remove_app_dependencies
+ynh_remove_extra_repo
+
+#=================================================
# SPECIFIC REMOVE
#=================================================
-# REMOVE THE CRON FILE
+# REMOVE VARIOUS FILES
#=================================================
-ynh_script_progression --message="Removing the cron file..."
+ynh_script_progression --message="Removing various files..."
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
diff --git a/scripts/restore b/scripts/restore
index aacb7f0..dbabb6c 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -33,7 +33,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$(ynh_sanitize_dbid --db_name=$app)
+db_user=$(ynh_app_setting_get --app=$app --key=db_user)
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
@@ -41,7 +41,8 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
-test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
+test ! -d $final_path \
+ || ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
@@ -58,7 +59,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
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"
+ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# RESTORE THE APP MAIN DIR
@@ -74,6 +75,27 @@ chown -R $app:www-data "$final_path"
#=================================================
# SPECIFIC RESTORATION
#=================================================
+# REINSTALL DEPENDENCIES
+#=================================================
+ynh_script_progression --message="Reinstalling dependencies..."
+
+# Define and install dependencies
+ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
+ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_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_install_ruby --ruby_version=$RUBY_VERSION
+
+#=================================================
+# RESTORE THE POSTGRESQL DATABASE
+#=================================================
+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
+ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;"
+ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name"
+
+#=================================================
# ADD SWAP IF NEEDED
#=================================================
ynh_script_progression --message="Adding swap if needed..."
@@ -90,23 +112,6 @@ ynh_script_progression --message="Adding $swap_needed Mo to swap..."
ynh_add_swap --size=$swap_needed
#=================================================
-# RESTORE THE CRON FILE
-#=================================================
-ynh_script_progression --message="Restoring the cron file..."
-
-ynh_restore_file --origin_path="/etc/cron.d/$app"
-
-#=================================================
-# REINSTALL DEPENDENCIES
-#=================================================
-ynh_script_progression --message="Reinstalling dependencies..."
-
-ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
-ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$NODEJS_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_install_ruby --ruby_version=$RUBY_VERSION
-
-#=================================================
# INSTALLING RUBY AND BUNDLER
#=================================================
ynh_script_progression --message="Installing Ruby..."
@@ -118,14 +123,11 @@ pushd "$final_path/live"
popd
#=================================================
-# RESTORE THE POSTGRESQL DATABASE
+# RESTORE VARIOUS FILES
#=================================================
-ynh_script_progression --message="Restoring the PostgreSQL database..."
+ynh_script_progression --message="Restoring various files..."
-ynh_psql_test_if_first_run
-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_file_as_root --file="./db.sql" --database="$db_name"
+ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# RESTORE SYSTEMD
diff --git a/scripts/upgrade b/scripts/upgrade
index a386514..ea95ffa 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -25,7 +25,7 @@ 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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-db_user=$(ynh_sanitize_dbid --db_name=$app)
+db_user=$(ynh_app_setting_get --app=$app --key=db_user)
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
admin_mail=$(ynh_user_get_info --username=$admin --key='mail')
port_web=$(ynh_app_setting_get --app=$app --key=port_web)
@@ -46,6 +46,32 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
+# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
+#=================================================
+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
+ynh_clean_setup () {
+ ynh_clean_check_starting
+ # Restore it if the upgrade fails
+ ynh_restore_upgradebackup
+}
+# Exit if an error occurs during the execution of the script
+ynh_abort_if_errors
+
+#=================================================
+# STANDARD UPGRADE STEPS
+#=================================================
+# STOP SYSTEMD SERVICE
+#=================================================
+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"
+ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=systemd --line_match="Stopped"
+
+#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
@@ -74,6 +100,12 @@ if [[ -z "$port_stream" ]]; then
ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream
fi
+# If db_user doesn't exist, create it, needed for old install
+if [[ -z "$db_user" ]]; then
+ db_user=$(ynh_sanitize_dbid --db_name=$app)
+ ynh_app_setting_set --app=$app --key=db_user --value=$db_user
+fi
+
# If db_pwd doesn't exist, create it, needed for old install
if [[ -z "$db_pwd" ]]; then
db_pwd=$(ynh_string_random)
@@ -122,38 +154,12 @@ fi
ynh_remove_extra_repo
#=================================================
-# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
-#=================================================
-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
-ynh_clean_setup () {
- ynh_clean_check_starting
- # Restore it if the upgrade fails
- ynh_restore_upgradebackup
-}
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
-
-#=================================================
-# STANDARD UPGRADE STEPS
-#=================================================
-# STOP SYSTEMD SERVICE
-#=================================================
-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"
-ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=systemd --line_match="Stopped"
-
-#=================================================
# CREATE DEDICATED USER
#=================================================
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"
+ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@@ -195,7 +201,7 @@ chown -R $app:www-data "$final_path"
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
-ynh_add_nginx_config 'port_web port_stream'
+ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
@@ -264,15 +270,15 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming
ynh_script_progression --message="Upgrading Mastodon..."
pushd "$final_path/live"
- sudo -u $app $ynh_ruby_load_path bin/bundle config deployment 'true'
- sudo -u $app $ynh_ruby_load_path bin/bundle config without 'development test'
- sudo -u $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
+ ynh_exec_as $app $ynh_ruby_load_path bin/bundle config deployment 'true'
+ ynh_exec_as $app $ynh_ruby_load_path bin/bundle config without 'development test'
+ ynh_exec_as $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN)
ynh_use_nodejs
- sudo -u $app $ynh_node_load_PATH yarn install --pure-lockfile
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:clean
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:migrate
- ynh_exec_warn_less sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl cache clear
+ 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 bin/bundle exec rails assets:clean
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:migrate
+ ynh_exec_warn_less ynh_exec_as $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl cache clear
popd
#=================================================