From 28e022b96992e7f73f31e59e34687af60d9d7a01 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 20:18:26 +0200 Subject: [PATCH 01/10] Apply last example_ynh --- manifest.json | 10 +--------- scripts/backup | 2 +- scripts/change_url | 4 ++-- scripts/install | 35 +++++++++++++++++----------------- scripts/remove | 4 ++-- scripts/restore | 18 +++++++++--------- scripts/upgrade | 47 +++++++++++++++++++++++----------------------- 7 files changed, 55 insertions(+), 65 deletions(-) diff --git a/manifest.json b/manifest.json index e906f0a..0ba4557 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "An open source, modern and powerful wiki app built on Node.js, Git and Markdown.", "fr": "Un wiki moderne et open source propulsé Node.js, Git et Markdown." }, - "version": "2.5.201~ynh1", + "version": "2.5.201~ynh2", "url": "https://wiki.js.org/", "license": "AGPL-3.0-or-later", "maintainer": { @@ -24,19 +24,11 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for Wiki.js", - "fr": "Choisissez un nom de domaine pour Wiki.js" - }, "example": "example.com" }, { "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 9fcc981..77494ff 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers diff --git a/scripts/change_url b/scripts/change_url index cc7a858..187c25c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -36,7 +36,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) #================================================= -# 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)..." @@ -46,7 +46,7 @@ ynh_clean_setup () { # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - # 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 diff --git a/scripts/install b/scripts/install index 45697eb..a7c1f7d 100644 --- a/scripts/install +++ b/scripts/install @@ -74,6 +74,14 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_use_nodejs ynh_install_app_dependencies $pkg_dependencies +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -97,6 +105,10 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -105,14 +117,6 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # SPECIFIC SETUP #================================================= @@ -131,22 +135,17 @@ ynh_script_progression --message="Configuring a systemd service..." ynh_add_systemd_config --others_var="ynh_node ynh_node_load_PATH" #================================================= -# MODIFY A CONFIG FILE +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Adding a config file..." ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml" +chmod 400 "$final_path/config.yml" +chown $app:$app "$final_path/config.yml" + #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions to app files -chown -R "$app":"$app" "$final_path" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/scripts/remove b/scripts/remove index 9286422..c6b1c8f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -29,7 +29,7 @@ ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user) # 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..." @@ -58,8 +58,8 @@ ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies -ynh_remove_app_dependencies ynh_remove_nodejs +ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/restore b/scripts/restore index f23531c..645c3b5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -51,17 +51,10 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring 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" -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app main directory..." - -ynh_restore_file --origin_path="$final_path" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -70,6 +63,13 @@ 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" +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." + +ynh_restore_file --origin_path="$final_path" + #================================================= # RESTORE USER RIGHTS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 33037ca..2ff52f4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -90,6 +90,14 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line_match="Stopped wikijs service" +#================================================= +# 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 #================================================= @@ -122,12 +130,16 @@ then fi fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -139,23 +151,8 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_use_nodejs ynh_install_app_dependencies $pkg_dependencies -#================================================= -# 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 -#================================================= -# MODIFY A CONFIG FILE -#================================================= -ynh_script_progression --message="Modifying a config file..." - -ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml" - #================================================= # SETUP SYSTEMD #================================================= @@ -164,16 +161,18 @@ ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config --others_var="ynh_node ynh_node_load_PATH" +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a config file..." + +ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path/config.yml" + +chmod 400 "$final_path/config.yml" +chown $app:$app "$final_path/config.yml" + #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions on app files -chown -R "$app":"$app" "$final_path" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= From aa7af4d2d02b324893eb208c213d7530d4fb8d92 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 21:25:01 +0200 Subject: [PATCH 02/10] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 86a7598..238fda0 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ The app can be used by multiple users. #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/wikijs%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/wikijs/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/wikijs%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/wikijs/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/wikijs.svg)](https://ci-apps.yunohost.org/ci/apps/wikijs/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/wikijs.svg)](https://ci-apps-arm.yunohost.org/ci/apps/wikijs/) ## Limitations From c1ec697572a687a2374aee915d3b65c2bc35ad9a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 21:26:14 +0200 Subject: [PATCH 03/10] Update check_process --- check_process | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/check_process b/check_process index 995ff64..4ef7bd9 100644 --- a/check_process +++ b/check_process @@ -32,6 +32,8 @@ upgrade=1 from_commit=f241d2586694d9aff19ae6d67209142faa8b25ca # 2.5.197~ynh1 upgrade=1 from_commit=3c9ab32ee147ef1f39aff2773fc3be506164d873 + # 2.5.201~ynh1 + upgrade=1 from_commit=bce2bfa3f9f0e28ffdde79df17a34bd5302559ea backup_restore=1 multi_instance=1 port_already_use=0 @@ -62,3 +64,5 @@ Notification=yes name=2.5.191~ynh1 ; commit=3c9ab32ee147ef1f39aff2773fc3be506164d873 name=2.5.197~ynh1 + ; commit=bce2bfa3f9f0e28ffdde79df17a34bd5302559ea + name=2.5.201~ynh1 From 81363ac968bb98496a7900b40f7059cedea39bf9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 23:07:01 +0200 Subject: [PATCH 04/10] Update upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2ff52f4..fae532e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -68,7 +68,7 @@ if ynh_legacy_permissions_exists; then fi #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." From fdc0c434804f1e08debb33bcf9ac58d5e1c208d9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 9 Apr 2021 23:34:05 +0200 Subject: [PATCH 05/10] Update restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 645c3b5..e9ac546 100644 --- a/scripts/restore +++ b/scripts/restore @@ -23,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 From f7ca2ab7b3f1affba0997274580b959293a701d8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 18:14:10 +0200 Subject: [PATCH 06/10] Update restore --- scripts/restore | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/restore b/scripts/restore index e9ac546..ef3b689 100644 --- a/scripts/restore +++ b/scripts/restore @@ -70,13 +70,9 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -#================================================= -# RESTORE USER RIGHTS -#================================================= -ynh_script_progression --message="Restoring user rights..." - -# Restore permissions on app files -chown -R "$app":"$app" "$final_path" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" #================================================= # SPECIFIC RESTORATION From d34ee2e9f48465d2ac3fb13e5ad7f828d3c97ade Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 18:14:14 +0200 Subject: [PATCH 07/10] Update upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index fae532e..2ff52f4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -68,7 +68,7 @@ if ynh_legacy_permissions_exists; then fi #================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." From 87e313cd411c862274f548bae2e2787fbf54d383 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 11 Apr 2021 21:09:07 +0200 Subject: [PATCH 08/10] Fix rights --- scripts/install | 18 +++++++++--------- scripts/restore | 2 +- scripts/upgrade | 18 +++++++++--------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/scripts/install b/scripts/install index a7c1f7d..fdc802b 100644 --- a/scripts/install +++ b/scripts/install @@ -107,7 +107,7 @@ ynh_setup_source --dest_dir="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -126,14 +126,6 @@ ynh_script_progression --message="Creating LDAP user..." yunohost user create $ldap_user --firstname "SvcWikijsLdap" --lastname "SvcWikijsLdap" --mail ${ldap_user}@$domain --password $ldap_password -q 0 -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config --others_var="ynh_node ynh_node_load_PATH" - #================================================= # ADD A CONFIGURATION #================================================= @@ -144,6 +136,14 @@ ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path chmod 400 "$final_path/config.yml" chown $app:$app "$final_path/config.yml" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." + +# Create a dedicated systemd config +ynh_add_systemd_config --others_var="ynh_node ynh_node_load_PATH" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index ef3b689..a800bff 100644 --- a/scripts/restore +++ b/scripts/restore @@ -72,7 +72,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 2ff52f4..5727f20 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -132,7 +132,7 @@ fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION @@ -153,14 +153,6 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # SPECIFIC UPGRADE -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." - -# Create a dedicated systemd config -ynh_add_systemd_config --others_var="ynh_node ynh_node_load_PATH" - #================================================= # UPDATE A CONFIG FILE #================================================= @@ -171,6 +163,14 @@ ynh_add_config --template="../conf/config.sample.yml" --destination="$final_path chmod 400 "$final_path/config.yml" chown $app:$app "$final_path/config.yml" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Upgrading systemd configuration..." + +# Create a dedicated systemd config +ynh_add_systemd_config --others_var="ynh_node ynh_node_load_PATH" + #================================================= # GENERIC FINALIZATION #================================================= From 7e0fa6eeebf1b3252959e0074d1ca1e9faaece98 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 15 Apr 2021 20:30:12 +0200 Subject: [PATCH 09/10] Fix chmod --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index fdc802b..a7fdcfc 100644 --- a/scripts/install +++ b/scripts/install @@ -105,7 +105,7 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/restore b/scripts/restore index a800bff..fbfd435 100644 --- a/scripts/restore +++ b/scripts/restore @@ -70,7 +70,7 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 5727f20..79516f6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -130,7 +130,7 @@ then fi fi -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" From 0f7b44a761af3f151470514bc88398c1f7bbd46b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 17 Apr 2021 18:32:39 +0200 Subject: [PATCH 10/10] Fix recursive chmod --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index a7fdcfc..fdc802b 100644 --- a/scripts/install +++ b/scripts/install @@ -105,7 +105,7 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/restore b/scripts/restore index fbfd435..a800bff 100644 --- a/scripts/restore +++ b/scripts/restore @@ -70,7 +70,7 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 79516f6..5727f20 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -130,7 +130,7 @@ then fi fi -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path"