From ca0e8c2000adaae610e8bfe7fbac3f4086996f44 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 01:48:01 +0200 Subject: [PATCH] Apply last example_ynh --- README.md | 4 ++-- check_process | 6 +++--- issue_template.md | 2 +- manifest.json | 16 ---------------- scripts/backup | 1 - scripts/change_url | 2 +- scripts/install | 22 +++++++++++++--------- scripts/remove | 2 +- scripts/restore | 32 +++++++++++++------------------- scripts/upgrade | 22 +++++++++++++--------- 10 files changed, 47 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 9a16802..78b7ff1 100644 --- a/README.md +++ b/README.md @@ -107,8 +107,8 @@ When disabling Local Login and other authentication services, clicking the `Logi #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/discourse%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/discourse/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/discourse%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/discourse/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/discourse.svg)](https://ci-apps.yunohost.org/ci/apps/discourse/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/discourse.svg)](https://ci-apps-arm.yunohost.org/ci/apps/discourse/) ## Limitations diff --git a/check_process b/check_process index 88d45c7..ad37462 100644 --- a/check_process +++ b/check_process @@ -13,11 +13,11 @@ setup_public=1 upgrade=1 # 2.2.3~ynh1 - upgrade=1 from_commit=de467cfa38791f43215ffea88d4b85460e5c0457 + upgrade=1 from_commit=de467cfa38791f43215ffea88d4b85460e5c0457 # 2.3.10~ynh1 - upgrade=1 from_commit=086de718f49a506c66498d2f7610f5fd0ce07d50 + upgrade=1 from_commit=086de718f49a506c66498d2f7610f5fd0ce07d50 # 2.6.0~ynh1 - upgrade=1 from_commit=b2e6633e0145c7eed2eb8c645ca7dbbd6c26fc06 + upgrade=1 from_commit=b2e6633e0145c7eed2eb8c645ca7dbbd6c26fc06 backup_restore=1 # Activate multi-instance test only if you have more than 2Gb RAM! multi_instance=1 diff --git a/issue_template.md b/issue_template.md index 75fc3f2..52dacef 100644 --- a/issue_template.md +++ b/issue_template.md @@ -8,7 +8,7 @@ about: When creating a bug report, please use the following template to provide 1. *Read this whole template first.* 2. *Determine if you are on the right place:* - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* - - *Otherwise, the issue may be due to discourse itself. Refer to its documentation or repository for help.* + - *Otherwise, the issue may be due to Discourse itself. Refer to its documentation or repository for help.* - *When in doubt, post here and we will figure it out together.* 3. *Delete the italic comments as you write over them below, and remove this guide.* --- diff --git a/manifest.json b/manifest.json index 84adb18..c4a6f45 100644 --- a/manifest.json +++ b/manifest.json @@ -26,38 +26,22 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for Discourse", - "fr": "Choisissez un nom de domaine pour Discourse" - }, "example": "example.com" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for Discourse", - "fr": "Choisissez un chemin pour Discourse" - }, "example": "/forum", "default": "/forum" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l'administrateur" - }, "example": "johndoe" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": true } ] diff --git a/scripts/backup b/scripts/backup index d9f717e..1f4c370 100644 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - # Clean remainings not handled by remove script ynh_clean_check_starting } # Exit if an error occurs during the execution of the script diff --git a/scripts/change_url b/scripts/change_url index 60a3cd5..1a5dbd5 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -36,7 +36,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) unicorn_workers=$(ynh_app_setting_get --app=$app --key=unicorn_workers) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." diff --git a/scripts/install b/scripts/install index e232ce9..b5767f4 100644 --- a/scripts/install +++ b/scripts/install @@ -64,6 +64,14 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies ynh_install_ruby --ruby_version=$RUBY_VERSION +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" --use_shell + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -102,6 +110,10 @@ ynh_setup_source --dest_dir="$final_path" mkdir -p "$final_path/plugins/discourse-ldap-auth" ynh_setup_source --dest_dir="$final_path/plugins/discourse-ldap-auth" --source_id=ldap-auth +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -116,14 +128,6 @@ if [ "$path_url" != "/" ] ; then fi ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path --use_shell - #================================================= # SPECIFIC SETUP #================================================= @@ -331,7 +335,7 @@ ynh_use_logrotate --logfile="$final_path/log/production.log" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log "$final_path/log/unicorn.stderr.log" "$final_path/log/unicorn.stdout.log" "$final_path/log/production.log" +yunohost service add $app --log="$final_path/log/unicorn.stderr.log" "$final_path/log/unicorn.stdout.log" "$final_path/log/production.log" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index d53ebc5..9f8a08c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -28,7 +28,7 @@ redis_db=$(ynh_app_setting_get --app=$app --key=redis_db) # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# 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 >/dev/null then ynh_script_progression --message="Removing $app service integration..." diff --git a/scripts/restore b/scripts/restore index b240d4e..6a2a2e1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - # Clean remainings not handled by remove script ynh_clean_check_starting } # Exit if an error occurs during the execution of the script @@ -24,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -56,6 +55,14 @@ 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 +#================================================= +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" --use_shell + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -63,21 +70,9 @@ 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..." - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path --use_shell - -#================================================= -# RESTORE USER RIGHTS -#================================================= -ynh_script_progression --message="Restoring user rights..." - -# Restore permissions on app files -chown -R $app: $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" #================================================= # SPECIFIC RESTORATION @@ -120,7 +115,6 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl daemon-reload systemctl enable $app.service --quiet #================================================= @@ -128,7 +122,7 @@ systemctl enable $app.service --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log "$final_path/log/unicorn.stderr.log" "$final_path/log/unicorn.stdout.log" "$final_path/log/production.log" +yunohost service add $app --log="$final_path/log/unicorn.stderr.log" "$final_path/log/unicorn.stdout.log" "$final_path/log/production.log" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 15fedd2..1a915b8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -92,6 +92,14 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/log/unicorn.stderr.log" +#================================================= +# 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" --use_shell + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -155,6 +163,10 @@ then ynh_setup_source --dest_dir="$final_path/plugins/discourse-ldap-auth" --source_id=ldap-auth fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -178,14 +190,6 @@ ynh_install_app_dependencies $pkg_dependencies ynh_install_ruby --ruby_version=$RUBY_VERSION ynh_use_ruby -#================================================= -# 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 --use_shell - #================================================= # SPECIFIC UPGRADE #================================================= @@ -384,7 +388,7 @@ ynh_use_logrotate --logfile="$final_path/log/production.log" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log "$final_path/log/unicorn.stderr.log" "$final_path/log/unicorn.stdout.log" "$final_path/log/production.log" +yunohost service add $app --log="$final_path/log/unicorn.stderr.log" "$final_path/log/unicorn.stdout.log" "$final_path/log/production.log" #================================================= # START SYSTEMD SERVICE