From d9ee68e25b8ea5911e926b587a9fec966344ec59 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 14 Mar 2021 23:48:12 +0100 Subject: [PATCH 1/8] Cleaning up --- README.md | 2 +- README_fr.md | 2 +- manifest.json | 2 +- pull_request_template.md | 4 +--- scripts/install | 19 ++++++++++--------- scripts/upgrade | 33 ++++++++++++++++----------------- 6 files changed, 30 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 9c674c6..7d87946 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ How to configure this app: by an admin panel. ## Documentation * Official documentation: https://thelounge.chat/docs - * YunoHost documentation: https://yunohost.org/#/app_thelounge + * YunoHost documentation: https://yunohost.org/en/app_thelounge ## YunoHost specific features diff --git a/README_fr.md b/README_fr.md index c717791..279c2e2 100644 --- a/README_fr.md +++ b/README_fr.md @@ -28,7 +28,7 @@ Comment configurer cette application : via le panneau d’administration. ## Documentation * Documentation officielle : https://thelounge.chat/docs - * Documentation YunoHost : https://yunohost.org/#/app_thelounge_fr + * Documentation YunoHost : https://yunohost.org/fr/app_thelounge ## Caractéristiques spécifiques YunoHost diff --git a/manifest.json b/manifest.json index 054b760..5f4915c 100644 --- a/manifest.json +++ b/manifest.json @@ -19,7 +19,7 @@ "email": "beudbeud@beudibox.fr" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.1.7" }, "multi_instance": false, "services": [ diff --git a/pull_request_template.md b/pull_request_template.md index f44dbc6..6c28fc5 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -13,6 +13,4 @@ ## Package_check results --- -*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* - -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/thelounge_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/thelounge_ynh%20PR-NUM-%20(USERNAME)/) +* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/install b/scripts/install index dbaa8c6..1308341 100644 --- a/scripts/install +++ b/scripts/install @@ -47,7 +47,6 @@ 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 -ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=config_path --value=$config_path #================================================= @@ -106,12 +105,14 @@ ynh_script_progression --message="Modifying a config file..." mkdir -p $config_path -# Main config File -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" +# # Main config File +# ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" -cp -a ../conf/config.js "$config_path" +# cp -a ../conf/config.js "$config_path" -ynh_store_file_checksum "$config_path/config.js" +# ynh_store_file_checksum "$config_path/config.js" + +ynh_add_config --template="../conf/config.js" --destination="$config_path" #================================================= # INSTALL THE LOUNGE @@ -129,8 +130,8 @@ popd #================================================= ynh_script_progression --message="Configuring a systemd service..." -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" @@ -165,10 +166,10 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring permissions..." # Make app public if necessary or protect it -[ $is_public -eq 0 ] || ynh_permission_update --permission "main" --add "visitors" +[ $is_public -eq 0 ] || ynh_permission_update --permission="main" --add="visitors" #================================================= # RELOAD NGINX diff --git a/scripts/upgrade b/scripts/upgrade index 9ec59bc..30bc6e2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,7 +18,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) config_path=$(ynh_app_setting_get --app=$app --key=config_path) port=$(ynh_app_setting_get --app=$app --key=port) @@ -35,15 +34,6 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - # If final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/var/www/$app @@ -56,6 +46,13 @@ if [ -z "$config_path" ]; then ynh_app_setting_set --app=$app --key=config_path --value=$config_path fi +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -142,20 +139,22 @@ fi #================================================= ynh_script_progression --message="Modifying a config file..." -ynh_backup_if_checksum_is_different --file="$config_path" -# Main config File -ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" +# ynh_backup_if_checksum_is_different --file="$config_path" +# # Main config File +# ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" -cp -a ../conf/config.js "$config_path" -ynh_store_file_checksum "$config_path/config.js" +# cp -a ../conf/config.js "$config_path" +# ynh_store_file_checksum "$config_path/config.js" + +ynh_add_config --template="../conf/config.js" --destination="$config_path" #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Upgrading systemd configuration..." -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" +#ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" From e3734f88f7cee60f622bbcf441e2b0c5aefba7f1 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 15 Mar 2021 09:24:41 +0100 Subject: [PATCH 2/8] Update manifest.json --- manifest.json | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/manifest.json b/manifest.json index 5f4915c..0e8f148 100644 --- a/manifest.json +++ b/manifest.json @@ -31,29 +31,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for The Lounge", - "fr": "Choisissez un nom de domaine pour The Lounge" - }, "example": "example.com" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for The Lounge", - "fr": "Choisissez un chemin pour The Lounge" - }, "example": "/irc", "default": "/irc" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": true } ] From 2ef37ee59480509d3e974e3704827497c3d973fc Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 15 Mar 2021 19:36:29 +0100 Subject: [PATCH 3/8] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 1308341..440d3e1 100644 --- a/scripts/install +++ b/scripts/install @@ -112,7 +112,7 @@ mkdir -p $config_path # ynh_store_file_checksum "$config_path/config.js" -ynh_add_config --template="../conf/config.js" --destination="$config_path" +ynh_add_config --template="../conf/config.js" --destination="$config_path/config.js" #================================================= # INSTALL THE LOUNGE From 95ba236421706d5b85a18f5a20237ead6060ee3c Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 15 Mar 2021 19:38:37 +0100 Subject: [PATCH 4/8] Fix --- scripts/change_url | 1 + scripts/install | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 6375a95..9bd7c46 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -8,6 +8,7 @@ source _common.sh source /usr/share/yunohost/helpers +ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS diff --git a/scripts/install b/scripts/install index 440d3e1..e8e6df6 100644 --- a/scripts/install +++ b/scripts/install @@ -132,8 +132,8 @@ ynh_script_progression --message="Configuring a systemd service..." #ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" #ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" ynh_add_systemd_config @@ -161,7 +161,7 @@ yunohost service add $app --description="Client Web IRC" --log="/var/log/$app/$a ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" +ynh_systemd_action --service_name=$app --action=start --log_path="systemd" --line_match="Available at http" #================================================= # SETUP SSOWAT From 69d7448072f14cd23bc58a520356a7c64725b394 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 22 Mar 2021 09:06:18 +0100 Subject: [PATCH 5/8] Fix --- scripts/change_url | 18 +++++++++++++++++- scripts/install | 25 ++++++++----------------- scripts/restore | 16 ++++++++-------- scripts/upgrade | 29 ++++++++++------------------- 4 files changed, 43 insertions(+), 45 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 9bd7c46..e0dfd7b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -8,7 +8,6 @@ source _common.sh source /usr/share/yunohost/helpers -ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS @@ -31,6 +30,23 @@ ynh_script_progression --message="Loading installation settings..." 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 +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +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 + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= diff --git a/scripts/install b/scripts/install index e8e6df6..5343146 100644 --- a/scripts/install +++ b/scripts/install @@ -71,6 +71,14 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -88,14 +96,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 - #================================================= # SPECIFIC SETUP #================================================= @@ -105,13 +105,6 @@ ynh_script_progression --message="Modifying a config file..." mkdir -p $config_path -# # Main config File -# ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" - -# cp -a ../conf/config.js "$config_path" - -# ynh_store_file_checksum "$config_path/config.js" - ynh_add_config --template="../conf/config.js" --destination="$config_path/config.js" #================================================= @@ -130,8 +123,6 @@ popd #================================================= ynh_script_progression --message="Configuring a systemd service..." -#ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -#ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" diff --git a/scripts/restore b/scripts/restore index 00611d4..f152ca4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -50,6 +50,14 @@ ynh_script_progression --message="Restoring the NGINX configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -64,14 +72,6 @@ ynh_script_progression --message="Restoring the config path..." ynh_restore_file --origin_path="$config_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 - #================================================= # RESTORE USER RIGHTS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 30bc6e2..64f506b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,6 +77,14 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +#================================================= +# 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 #================================================= @@ -110,14 +118,6 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version # Install Yarn ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -#================================================= -# 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 - #================================================= # SPECIFIC UPGRADE #================================================= @@ -139,13 +139,6 @@ fi #================================================= ynh_script_progression --message="Modifying a config file..." -# ynh_backup_if_checksum_is_different --file="$config_path" -# # Main config File -# ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/config.js" - -# cp -a ../conf/config.js "$config_path" -# ynh_store_file_checksum "$config_path/config.js" - ynh_add_config --template="../conf/config.js" --destination="$config_path" #================================================= @@ -153,10 +146,8 @@ ynh_add_config --template="../conf/config.js" --destination="$config_path" #================================================= ynh_script_progression --message="Upgrading systemd configuration..." -#ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/systemd.service" -#ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" -ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" +ynh_replace_string --match_string="__NODE__" --replace_string="$nodejs_path" --target_file="../conf/systemd.service" ynh_add_systemd_config From f0eabf81c7290dcbe796a9bf263ba20ecbdda243 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 22 Mar 2021 09:17:49 +0100 Subject: [PATCH 6/8] Fix --- check_process | 1 - scripts/backup | 3 +-- scripts/install | 14 ++++++-------- scripts/remove | 3 +-- scripts/restore | 7 +++---- scripts/upgrade | 6 +++--- 6 files changed, 14 insertions(+), 20 deletions(-) diff --git a/check_process b/check_process index d5c5b3e..946bdf9 100644 --- a/check_process +++ b/check_process @@ -21,7 +21,6 @@ upgrade=1 from_commit=bd00c8e3ce43563f33fde073cf36b997c348d05c backup_restore=1 multi_instance=0 - port_already_use=0 change_url=1 ;;; Options Email= diff --git a/scripts/backup b/scripts/backup index 3aa23aa..77fc8c4 100644 --- a/scripts/backup +++ b/scripts/backup @@ -23,7 +23,6 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) -config_path=$(ynh_app_setting_get --app=$app --key=config_path) domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= @@ -53,7 +52,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" # BACKUP CONFIG #================================================= -ynh_backup --src_path="$config_path" +ynh_backup --src_path="/home/yunohost.app/$app" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 5343146..bc5b1bc 100644 --- a/scripts/install +++ b/scripts/install @@ -34,7 +34,6 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app -config_path=/home/yunohost.app/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path @@ -45,9 +44,8 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= 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 -ynh_app_setting_set --app=$app --key=config_path --value=$config_path +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url #================================================= # STANDARD MODIFICATIONS @@ -103,9 +101,9 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Modifying a config file..." -mkdir -p $config_path +mkdir -p /home/yunohost.app/$app -ynh_add_config --template="../conf/config.js" --destination="$config_path/config.js" +ynh_add_config --template="../conf/config.js" --destination="/home/yunohost.app/$app/config.js" #================================================= # INSTALL THE LOUNGE @@ -137,7 +135,7 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions to app files chown -R $app: $final_path -chown -R $app: $config_path +chown -R $app: /home/yunohost.app/$app #================================================= # INTEGRATE SERVICE IN YUNOHOST @@ -152,7 +150,7 @@ yunohost service add $app --description="Client Web IRC" --log="/var/log/$app/$a ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action=start --log_path="systemd" --line_match="Available at http" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Available at http" #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index a09d08f..81a9a71 100644 --- a/scripts/remove +++ b/scripts/remove @@ -19,7 +19,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -config_path=$(ynh_app_setting_get --app=$app --key=config_path) #================================================= # STANDARD REMOVE @@ -73,7 +72,7 @@ ynh_remove_nginx_config #================================================= ynh_script_progression --message="Removing the config file..." -ynh_secure_remove --file="$config_path" +ynh_secure_remove --file="/home/yunohost.app/$app" #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index f152ca4..c45d9ff 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,7 +29,6 @@ app=$YNH_APP_INSTANCE_NAME 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) -config_path=$(ynh_app_setting_get --app=$app --key=config_path) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -70,7 +69,7 @@ ynh_restore_file --origin_path="$final_path" #================================================= ynh_script_progression --message="Restoring the config path..." -ynh_restore_file --origin_path="$config_path" +ynh_restore_file --origin_path="/home/yunohost.app/$app" #================================================= # RESTORE USER RIGHTS @@ -79,7 +78,7 @@ ynh_script_progression --message="Restoring user rights..." # Restore permissions to app files chown -R $app: $final_path -chown -R $app: $config_path +chown -R $app: /home/yunohost.app/$app #================================================= # SPECIFIC RESTORATION @@ -114,7 +113,7 @@ yunohost service add $app --description="Client Web IRC" --log="/var/log/$app/$a #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Available at http" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 64f506b..c011556 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -139,7 +139,7 @@ fi #================================================= ynh_script_progression --message="Modifying a config file..." -ynh_add_config --template="../conf/config.js" --destination="$config_path" +ynh_add_config --template="../conf/config.js" --destination="/home/yunohost.app/$app/config.js" #================================================= # SETUP SYSTEMD @@ -160,7 +160,7 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app: $final_path -chown -R $app: $config_path +chown -R $app: /home/yunohost.app/$app #================================================= # GENERIC FINALIZATION @@ -176,7 +176,7 @@ yunohost service add $app --description="Client Web IRC" --log="/var/log/$app/$a #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Available at http" #================================================= # RELOAD NGINX From c8a17eb7431d5bafb33102e79634acea1ec233b5 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 22 Mar 2021 10:00:33 +0100 Subject: [PATCH 7/8] Fix --- scripts/backup | 3 ++- scripts/change_url | 2 +- scripts/install | 6 ++++-- scripts/remove | 3 ++- scripts/restore | 5 +++-- scripts/upgrade | 7 ++++--- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/scripts/backup b/scripts/backup index 77fc8c4..073460e 100644 --- a/scripts/backup +++ b/scripts/backup @@ -24,6 +24,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) +config_path=$(ynh_app_setting_get --app=$app --key=config_path) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -52,7 +53,7 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" # BACKUP CONFIG #================================================= -ynh_backup --src_path="/home/yunohost.app/$app" +ynh_backup --src_path="$config_path" #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index e0dfd7b..2265478 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -109,7 +109,7 @@ fi ynh_script_progression --message="Starting a systemd service..." # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Available at http" +ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Available at http" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index bc5b1bc..28cd8db 100644 --- a/scripts/install +++ b/scripts/install @@ -34,6 +34,7 @@ app=$YNH_APP_INSTANCE_NAME ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app +config_path=/home/yunohost.app/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path @@ -46,6 +47,7 @@ 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 +ynh_app_setting_set --app=$app --key=config_path --value=$config_path #================================================= # STANDARD MODIFICATIONS @@ -103,7 +105,7 @@ ynh_script_progression --message="Modifying a config file..." mkdir -p /home/yunohost.app/$app -ynh_add_config --template="../conf/config.js" --destination="/home/yunohost.app/$app/config.js" +ynh_add_config --template="../conf/config.js" --destination="$config_path/config.js" #================================================= # INSTALL THE LOUNGE @@ -135,7 +137,7 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions to app files chown -R $app: $final_path -chown -R $app: /home/yunohost.app/$app +chown -R $app: $config_path #================================================= # INTEGRATE SERVICE IN YUNOHOST diff --git a/scripts/remove b/scripts/remove index 81a9a71..a09d08f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -19,6 +19,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +config_path=$(ynh_app_setting_get --app=$app --key=config_path) #================================================= # STANDARD REMOVE @@ -72,7 +73,7 @@ ynh_remove_nginx_config #================================================= ynh_script_progression --message="Removing the config file..." -ynh_secure_remove --file="/home/yunohost.app/$app" +ynh_secure_remove --file="$config_path" #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index c45d9ff..8d34e05 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,6 +29,7 @@ app=$YNH_APP_INSTANCE_NAME 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) +config_path=$(ynh_app_setting_get --app=$app --key=config_path) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -69,7 +70,7 @@ ynh_restore_file --origin_path="$final_path" #================================================= ynh_script_progression --message="Restoring the config path..." -ynh_restore_file --origin_path="/home/yunohost.app/$app" +ynh_restore_file --origin_path="$config_path" #================================================= # RESTORE USER RIGHTS @@ -78,7 +79,7 @@ ynh_script_progression --message="Restoring user rights..." # Restore permissions to app files chown -R $app: $final_path -chown -R $app: /home/yunohost.app/$app +chown -R $app: $config_path #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index c011556..0865c5c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -43,6 +43,7 @@ fi # If config_path doesn't exist, create it if [ -z "$config_path" ]; then config_path=/home/yunohost.app/$app + mkdir -p /home/yunohost.app/$app ynh_app_setting_set --app=$app --key=config_path --value=$config_path fi @@ -75,7 +76,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" +ynh_systemd_action --service_name=$app --action=stop --log_path=systemd #================================================= # CREATE DEDICATED USER @@ -139,7 +140,7 @@ fi #================================================= ynh_script_progression --message="Modifying a config file..." -ynh_add_config --template="../conf/config.js" --destination="/home/yunohost.app/$app/config.js" +ynh_add_config --template="../conf/config.js" --destination="$config_path/config.js" #================================================= # SETUP SYSTEMD @@ -160,7 +161,7 @@ ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app: $final_path -chown -R $app: /home/yunohost.app/$app +chown -R $app: $config_path #================================================= # GENERIC FINALIZATION From 82fbc04caa14f2d58de416d13ea3b813ef9b2c4a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 22 Mar 2021 10:52:32 +0100 Subject: [PATCH 8/8] Update change_url --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 2265478..9273ac3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -33,7 +33,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1 +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade