diff options
| author | yalh76 <yalh@yahoo.com> | 2021-04-21 20:32:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-21 20:32:02 +0200 |
| commit | 00d4516409fae2e6e3afec092e491bc8dba5fff4 (patch) | |
| tree | 7b9c1e4e210ce073680ab449d080985600d77cd8 /scripts/upgrade | |
| parent | 2e9f19e75a4b047702fcab3c2b0325ee03e97045 (diff) | |
| parent | 799587668ba8d57ab579092b76ce2e39c7373257 (diff) | |
| download | mastodon_ynh-00d4516409fae2e6e3afec092e491bc8dba5fff4.tar.gz mastodon_ynh-00d4516409fae2e6e3afec092e491bc8dba5fff4.tar.bz2 mastodon_ynh-00d4516409fae2e6e3afec092e491bc8dba5fff4.zip | |
Merge pull request #264 from YunoHost-Apps/example
Apply example_ynh
Diffstat (limited to 'scripts/upgrade')
| -rw-r--r-- | scripts/upgrade | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/scripts/upgrade b/scripts/upgrade index aa96bef..86555dc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,7 +49,6 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." - # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -124,7 +123,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take ynh_backup_before_upgrade ynh_clean_setup () { ynh_clean_check_starting - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -142,6 +141,14 @@ ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=syst 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" + +#================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -171,10 +178,14 @@ then ynh_secure_remove --file="$final_path/live/config/initializers/timeout.rb" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_add_nginx_config 'port_web port_stream' @@ -190,14 +201,6 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= -# 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 - -#================================================= # SPECIFIC UPGRADE #================================================= # ADD SWAP IF NEEDED @@ -227,14 +230,27 @@ pushd "$final_path/live" popd #================================================= -# MODIFY A CONFIG FILE +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Updating a config file..." language="$(echo $language | head -c 2)" ynh_add_config --template="../conf/.env.production.sample" --destination="$config" +chmod 400 "$config" +chown $app:$app "$config" + +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Upgrading systemd configuration..." + +# Create a dedicated systemd config +ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT" +ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT" +ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" + #================================================= # UPGRADE MASTODON #================================================= @@ -262,33 +278,15 @@ ynh_script_progression --message="Setuping the cron file..." ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" #================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." - -# Create a dedicated systemd config -ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT" -ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT" -ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" - -#================================================= # GENERIC FINALIZATION #================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions on app files -chown -R $app: $final_path - -#================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add "$app-web" --description "$app web service" -yunohost service add "$app-sidekiq" --description "$app sidekiq service" -yunohost service add "$app-streaming" --description "$app streaming service" +yunohost service add "$app-web" --description="$app web service" +yunohost service add "$app-sidekiq" --description="$app sidekiq service" +yunohost service add "$app-streaming" --description="$app streaming service" #================================================= # START SYSTEMD SERVICE @@ -302,7 +300,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload |
