From 6d8090cae94945718b7c11b153e263f24e0ec6b3 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 31 Oct 2023 14:09:47 +0000 Subject: [PATCH 01/14] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f877b73..08b0c6b 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ This version of Etherpad is preconfigured with a collection of plugins: * Official app website: * Official admin documentation: * Upstream app code repository: -* YunoHost documentation for this app: +* YunoHost Store: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index b97b773..06c11f1 100644 --- a/README_fr.md +++ b/README_fr.md @@ -48,7 +48,7 @@ Cette version d'Etherpad est préconfigurée avec une collection de plugins: * Site officiel de l’app : * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : -* Documentation YunoHost pour cette app : +* YunoHost Store: * Signaler un bug : ## Informations pour les développeurs From 69eba155eec90f133b3072131705801aa54b3552 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 28 Nov 2023 08:59:54 +0000 Subject: [PATCH 02/14] Auto-update README --- README.md | 3 ++- README_fr.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ca79108..1b5993f 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ This version of Etherpad is preconfigured with a collection of plugins: - [ep_subscript_and_superscript](https://www.npmjs.com/package/ep_subscript_and_superscript) - *Support for subscript and superscript* -**Shipped version:** 1.9.3~ynh1 +**Shipped version:** 1.9.4~ynh1 **Demo:** https://video.etherpad.com @@ -47,6 +47,7 @@ This version of Etherpad is preconfigured with a collection of plugins: * Official app website: * Official admin documentation: * Upstream app code repository: +* YunoHost Store: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index aa4d64f..3837642 100644 --- a/README_fr.md +++ b/README_fr.md @@ -34,7 +34,7 @@ Cette version d'Etherpad est préconfigurée avec une collection de plugins: - [ep_subscript_and_superscript](https://www.npmjs.com/package/ep_subscript_and_superscript) - *Support des exposants et indices* -**Version incluse :** 1.9.3~ynh1 +**Version incluse :** 1.9.4~ynh1 **Démo :** https://video.etherpad.com @@ -47,6 +47,7 @@ Cette version d'Etherpad est préconfigurée avec une collection de plugins: * Site officiel de l’app : * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : +* YunoHost Store: * Signaler un bug : ## Informations pour les développeurs From f5a61802a859fae32d5e05a82fb3623c65f77df4 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sun, 10 Dec 2023 22:11:06 +0100 Subject: [PATCH 03/14] sources: There's been many node dependency bump so let's try using a more recent commit ... --- manifest.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index 84f5eef..2404549 100644 --- a/manifest.toml +++ b/manifest.toml @@ -80,8 +80,8 @@ ram.runtime = "50M" [resources.sources] [resources.sources.main] - url = "https://github.com/ether/etherpad-lite/archive/1.9.4.tar.gz" - sha256 = "5b8ccf2a3c92cbd9bb578f684bc52d2ea27fc3fb30cdc76341f9ccffe0c0ff7f" + url = "https://github.com/ether/etherpad-lite/archive/bbaa6a7e8dee3223dfed7a73397d599e3194c9a6.tar.gz" + sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" autoupdate.strategy = "latest_github_tag" [resources.system_user] From cd67c087cef18e850104cc8039241275284f9804 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sun, 10 Dec 2023 22:19:48 +0100 Subject: [PATCH 04/14] We probably want to use ETHERPAD_PRODUCTION=true rather than having dev dependencies.. --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 27f6a55..58912c2 100644 --- a/scripts/install +++ b/scripts/install @@ -156,7 +156,7 @@ popd ynh_script_progression --message="Installing Etherpad..." --weight=90 pushd $install_dir - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH src/bin/installDeps.sh + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH ETHERPAD_PRODUCTION=true src/bin/installDeps.sh popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b9d3dfc..0d41435 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -300,7 +300,7 @@ popd ynh_script_progression --message="Upgrading Etherpad..." --weight=10 pushd $install_dir - ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH src/bin/installDeps.sh + ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH ETHERPAD_PRODUCTION=true src/bin/installDeps.sh popd #================================================= From 20420635539d03ab819df79b5e827c564261a0a6 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sun, 10 Dec 2023 22:23:59 +0100 Subject: [PATCH 05/14] sources: fix checksum --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 2404549..d533efb 100644 --- a/manifest.toml +++ b/manifest.toml @@ -81,7 +81,7 @@ ram.runtime = "50M" [resources.sources.main] url = "https://github.com/ether/etherpad-lite/archive/bbaa6a7e8dee3223dfed7a73397d599e3194c9a6.tar.gz" - sha256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + sha256 = "83a5c24e27e93e26d660f60724400d3f47e2780e4ec07a7a080310948836a589" autoupdate.strategy = "latest_github_tag" [resources.system_user] From f1de672c820ef81f6c2a9c15aeef10821894c841 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sun, 10 Dec 2023 23:26:05 +0100 Subject: [PATCH 06/14] Update scripts/_common.sh: revert to node 14 in the hope to fix the package json hell with express-session --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 53abd29..e2d83e7 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # NodeJS version -nodejs_version=16 +nodejs_version=14 # MyPads version # This variable is mostly used to force an upgrade of the package in case of new versions of MyPads. From 77f8435fb3badfd77249e537039bcf264cec375d Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sun, 10 Dec 2023 23:27:23 +0100 Subject: [PATCH 07/14] Update conf/systemd.service: production=true --- conf/systemd.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/systemd.service b/conf/systemd.service index e92b888..df09538 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,7 +7,7 @@ Type=simple User=__APP__ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/ -Environment=NODE_ENV=production +Environment=ETHERPAD_PRODUCTION=true Environment="__YNH_NODE_LOAD_PATH__" ExecStart=__INSTALL_DIR__/src/bin/run.sh #ExecStart=__YNH_NODE__ __INSTALL_DIR__/src/node/server.js From 2d56a02f9d57a531d1b0fe73f6e1d6fb087e22b4 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sun, 10 Dec 2023 23:50:06 +0100 Subject: [PATCH 08/14] Update conf/systemd.service: revert to previous ExecStart syntax that seemed to be working in current master branch... --- conf/systemd.service | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index df09538..0684052 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -9,8 +9,7 @@ Group=__APP__ WorkingDirectory=__INSTALL_DIR__/ Environment=ETHERPAD_PRODUCTION=true Environment="__YNH_NODE_LOAD_PATH__" -ExecStart=__INSTALL_DIR__/src/bin/run.sh -#ExecStart=__YNH_NODE__ __INSTALL_DIR__/src/node/server.js +ExecStart=__YNH_NODE__ __INSTALL_DIR__/src/node/server.js StandardOutput=append:/var/log/__APP__/etherpad.log StandardError=inherit Restart=always From 016825ae3e9d07754c3e9f1889649e9cb34b9151 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 11 Dec 2023 00:04:31 +0100 Subject: [PATCH 09/14] sources: back to the real 1.9.4 ? x_x --- manifest.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.toml b/manifest.toml index d533efb..49ce555 100644 --- a/manifest.toml +++ b/manifest.toml @@ -80,8 +80,8 @@ ram.runtime = "50M" [resources.sources] [resources.sources.main] - url = "https://github.com/ether/etherpad-lite/archive/bbaa6a7e8dee3223dfed7a73397d599e3194c9a6.tar.gz" - sha256 = "83a5c24e27e93e26d660f60724400d3f47e2780e4ec07a7a080310948836a589" + url = "https://github.com/ether/etherpad-lite/archive/1.9.4.tar.gz" + sha256 = "5b8ccf2a3c92cbd9bb578f684bc52d2ea27fc3fb30cdc76341f9ccffe0c0ff7f" autoupdate.strategy = "latest_github_tag" [resources.system_user] @@ -112,4 +112,4 @@ ram.runtime = "50M" [resources.database] type = "mysql" - \ No newline at end of file + From 10e2bfe5bcaa90043b3036cda0e75424f49b431c Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 11 Dec 2023 00:10:40 +0100 Subject: [PATCH 10/14] Cleanup tests.toml --- tests.toml | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/tests.toml b/tests.toml index 2d300eb..acca843 100644 --- a/tests.toml +++ b/tests.toml @@ -2,37 +2,38 @@ test_format = 1.0 [default] + exclude = ["install.private"] + # ------------------------------- # Default args to use for install # ------------------------------- - - args.export = "libreoffice" + + args.export = "none" args.mypads = 0 args.useldap = 0 - args.password = "admin!42" + args.password = "##SuperAdminPassword##" # ------------------------------- # Commits to test upgrade from # ------------------------------- - test_upgrade_from.4d613658.name = "Upgrade from 1.8.17" + test_upgrade_from.4d613658.name = "1.8.17" -# This is an additional test suite [with_mypads] args.export = "libreoffice" args.mypads = 1 args.useldap = 1 only = ["install.root"] -#[with_abiword] -# args.export = "abiword" -# args.mypads = 1 -# args.useldap = 1 -# only = ["install.root"] +[with_abiword] + args.export = "libreoffice" + args.mypads = 0 + args.useldap = 0 + only = ["install.root"] -#[without_export] -# args.export = "none" -# args.mypads = 1 -# args.useldap = 0 -# only = ["install.root"] +[with_libreoffice] + args.export = "libreoffice" + args.mypads = 0 + args.useldap = 0 + only = ["install.root"] From 3b19355854fdaa29043f9fa8437d276d8f82b0b9 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 11 Dec 2023 00:17:43 +0100 Subject: [PATCH 11/14] Revert again to 1.9.1 ... --- manifest.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index 49ce555..2cfbc3f 100644 --- a/manifest.toml +++ b/manifest.toml @@ -80,8 +80,8 @@ ram.runtime = "50M" [resources.sources] [resources.sources.main] - url = "https://github.com/ether/etherpad-lite/archive/1.9.4.tar.gz" - sha256 = "5b8ccf2a3c92cbd9bb578f684bc52d2ea27fc3fb30cdc76341f9ccffe0c0ff7f" + url = "https://github.com/ether/etherpad-lite/archive/1.9.1.tar.gz" + sha256 = "667741235a2bcd8d28a32f5e611b82fb2ea7d11525ff41b8b5478b05a987b047" autoupdate.strategy = "latest_github_tag" [resources.system_user] From f1c517ef341d867437c01217e83f08bf2cc7cdd7 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 11 Dec 2023 00:52:20 +0100 Subject: [PATCH 12/14] Simplify ynh_replace_string madness to handle configuration --- conf/settings.json | 50 ++++++++++++------------- scripts/install | 26 ++++++------- scripts/upgrade | 91 ++++++++++++++-------------------------------- 3 files changed, 64 insertions(+), 103 deletions(-) diff --git a/conf/settings.json b/conf/settings.json index baf5fc3..99f4736 100644 --- a/conf/settings.json +++ b/conf/settings.json @@ -246,29 +246,29 @@ "highlightSelectedText": false }, // ep_mypads -//noldap "ep_mypads": { -//noldap "ldap": { -//noldap // Your LDAP URL -//noldap "url": "ldap://127.0.0.1", -//noldap // Where to search your users -//noldap "searchBase": "ou=users,dc=yunohost,dc=org", -//noldap // A LDAP filter ({{username}} is replaced by user's login) -//noldap "searchFilter": "(&(|(objectclass=posixAccount))(uid={{username}}))", -//noldap // LDAP properties mapping for MyPads -//noldap "properties": { -//noldap // Which LDAP property will be used as user's login? -//noldap "login": "uid", -//noldap // as user's email -//noldap "email": "mail", -//noldap // as user's firstname -//noldap "firstname": "givenName", -//noldap // as users's lastname -//noldap "lastname": "sn" -//noldap }, -//noldap // Default langage for LDAP created users -//noldap "defaultLang": "__LANGUAGE__" -//noldap } -//noldap }, +__COMMENT_IF_LDAP_DISABLED__ "ep_mypads": { +__COMMENT_IF_LDAP_DISABLED__ "ldap": { +__COMMENT_IF_LDAP_DISABLED__ // Your LDAP URL +__COMMENT_IF_LDAP_DISABLED__ "url": "ldap://127.0.0.1", +__COMMENT_IF_LDAP_DISABLED__ // Where to search your users +__COMMENT_IF_LDAP_DISABLED__ "searchBase": "ou=users,dc=yunohost,dc=org", +__COMMENT_IF_LDAP_DISABLED__ // A LDAP filter ({{username}} is replaced by user's login) +__COMMENT_IF_LDAP_DISABLED__ "searchFilter": "(&(|(objectclass=posixAccount))(uid={{username}}))", +__COMMENT_IF_LDAP_DISABLED__ // LDAP properties mapping for MyPads +__COMMENT_IF_LDAP_DISABLED__ "properties": { +__COMMENT_IF_LDAP_DISABLED__ // Which LDAP property will be used as user's login? +__COMMENT_IF_LDAP_DISABLED__ "login": "uid", +__COMMENT_IF_LDAP_DISABLED__ // as user's email +__COMMENT_IF_LDAP_DISABLED__ "email": "mail", +__COMMENT_IF_LDAP_DISABLED__ // as user's firstname +__COMMENT_IF_LDAP_DISABLED__ "firstname": "givenName", +__COMMENT_IF_LDAP_DISABLED__ // as users's lastname +__COMMENT_IF_LDAP_DISABLED__ "lastname": "sn" +__COMMENT_IF_LDAP_DISABLED__ }, +__COMMENT_IF_LDAP_DISABLED__ // Default langage for LDAP created users +__COMMENT_IF_LDAP_DISABLED__ "defaultLang": "__LANGUAGE__" +__COMMENT_IF_LDAP_DISABLED__ } +__COMMENT_IF_LDAP_DISABLED__ }, /* * Should we suppress errors from being visible in the default Pad Text? @@ -312,7 +312,7 @@ * it to null disables Abiword and will only allow plain text and HTML * import/exports. */ - "abiword" : null, + "abiword" : __ABIWORD_PATH__, /* * This is the absolute path to the soffice executable. @@ -320,7 +320,7 @@ * LibreOffice can be used in lieu of Abiword to export pads. * Setting it to null disables LibreOffice exporting. */ - "soffice" : null, + "soffice" : __SOFFICE_PATH__, /* * Path to the Tidy executable. diff --git a/scripts/install b/scripts/install index 58912c2..ce29600 100644 --- a/scripts/install +++ b/scripts/install @@ -73,34 +73,30 @@ chown $app -R /var/log/$app #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=6 +ynh_script_progression --message="Configure etherpad..." -ynh_add_config --template="../conf/settings.json" --destination="$install_dir/settings.json" +abiword_path="null" +soffice_path="null" -if [ "$export" = "abiword" ] +if [[ "$export" == "abiword" ]] then - # Get Abiword binary path - abiword_path=`which abiword` - # Set the path of abiword into Etherpad config - ynh_replace_string --match_string="\"abiword\" : null" --replace_string="\"abiword\" : \"$abiword_path\"" --target_file="$install_dir/settings.json" -elif [ "$export" = "libreoffice" ] + abiword_path="\"$(which abiword)\"" +elif [[ "$export" == "libreoffice" ]] then - # Get soffice binary path - soffice_path=`which soffice` - # Set the path of soffice into Etherpad config - ynh_replace_string --match_string="\"soffice\" : null" --replace_string="\"soffice\" : \"$soffice_path\"" --target_file="$install_dir/settings.json" + soffice_path="\"$(which soffice)\"" fi # Use ldap for mypads +comment_if_ldap_disabled="//ldap_disabled" if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] then - ynh_replace_string --match_string="//noldap\(.*\)" --replace_string="\1 //useldap" --target_file="$install_dir/settings.json" + comment_if_ldap_disabled="" fi # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$install_dir/settings.json" -ynh_add_config --template="../conf/credentials.json" --destination="$install_dir/credentials.json" +ynh_add_config --template="settings.json" --destination="$install_dir/settings.json" +ynh_add_config --template="credentials.json" --destination="$install_dir/credentials.json" chmod 600 "$install_dir/settings.json" chown $app:$app "$install_dir/settings.json" diff --git a/scripts/upgrade b/scripts/upgrade index 0d41435..c92b8cb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,6 +77,12 @@ if [ -n "${abiword:-}" ]; then ynh_app_setting_delete --app=$app --key=abiword fi +if [ -z "${language:-}" ]; then + # If upgrading from a version which doesn't support translations, set language to English by default + language=en + ynh_app_setting_set --app=$app --key=language --value=$language +fi + # If export setting doesn't exist if [ -z "${export:-}" ]; then export=none @@ -177,72 +183,31 @@ chown $app -R /var/log/$app # CONFIGURE ETHERPAD #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] +ynh_script_progression --message="Configure etherpad..." + +abiword_path="null" +soffice_path="null" + +if [[ "$export" == "abiword" ]] then - ynh_script_progression --message="Reconfiguring Etherpad..." --weight=3 - - # Overwrite the settings config file only if it's allowed - if [ $overwrite_settings -eq 1 ] - then - # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. - ynh_backup_if_checksum_is_different --file="$install_dir/settings.json" - - ynh_add_config --template="../conf/settings.json" --destination="$install_dir/settings.json" - - if [ "$export" = "abiword" ] - then - # Get abiword binary path - abiword_path=`which abiword` - # Set the path of Abiword into Etherpad config - ynh_replace_string --match_string="\"abiword\" : null" --replace_string="\"abiword\" : \"$abiword_path\"" --target_file="$install_dir/settings.json" - elif [ "$export" = "libreoffice" ] - then - # Get soffice binary path - soffice_path=`which soffice` - # Set the path of soffice into Etherpad config - ynh_replace_string --match_string="\"soffice\" : null" --replace_string="\"soffice\" : \"$soffice_path\"" --target_file="$install_dir/settings.json" - fi - - if test -z "$language"; then - # If upgrading from a version which doesn't support translations, set language to English by default - language=en - ynh_app_setting_set --app=$app --key=language --value=$language - fi - - # Use LDAP for MyPads - if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] - then - ynh_replace_string --match_string="//noldap" --replace_string="" --target_file="$install_dir/settings.json" - fi - - # Optional parameters from config-panel feature - if [ -n "$pad_config_nocolors" ]; then - ynh_replace_string --match_string="\(\"noColors\" *: \).*," --replace_string="\1$pad_config_nocolors," --target_file="$install_dir/settings.json" - fi - if [ -n "$pad_config_showlinenumbers" ]; then - ynh_replace_string --match_string="\(\"showLineNumbers\" *: \).*," --replace_string="\1$pad_config_showlinenumbers," --target_file="$install_dir/settings.json" - fi - if [ -n "$pad_config_chatandusers" ]; then - ynh_replace_string --match_string="\(\"chatAndUsers\" *: \).*," --replace_string="\1$pad_config_chatandusers," --target_file="$install_dir/settings.json" - fi - if [ -n "$pad_config_alwaysshowchat" ]; then - ynh_replace_string --match_string="\(\"alwaysShowChat\" *: \).*," --replace_string="\1$pad_config_alwaysshowchat," --target_file="$install_dir/settings.json" - fi - if [ -n "$pad_config_show_markdown" ]; then - ynh_replace_string --match_string="\(\"ep_markdown_default\" *: \).*," --replace_string="\1$pad_config_show_markdown," --target_file="$install_dir/settings.json" - fi - - # Recalculate and store the checksum of the file for the next upgrade. - ynh_store_file_checksum --file="$install_dir/settings.json" - fi - - # Overwrite the credentials config file only if it's allowed - if [ $overwrite_credentials -eq 1 ] - then - ynh_add_config --template="../conf/credentials.json" --destination="$install_dir/credentials.json" - fi + abiword_path="\"$(which abiword)\"" +elif [[ "$export" == "libreoffice" ]] +then + soffice_path="\"$(which soffice)\"" fi +# Use ldap for mypads +comment_if_ldap_disabled="//ldap_disabled" +if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] +then + comment_if_ldap_disabled="" +fi + +# Calculate and store the config file checksum into the app settings + +ynh_add_config --template="settings.json" --destination="$install_dir/settings.json" +ynh_add_config --template="credentials.json" --destination="$install_dir/credentials.json" + chmod 600 "$install_dir/settings.json" chown $app:$app "$install_dir/settings.json" From 3e5cd682e4cb97a3e528e39fe3f858c15bc10bf1 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 11 Dec 2023 01:08:57 +0100 Subject: [PATCH 13/14] More madness cleanup ... the whole thing about config panel is unmainained, trash it, simplify everything --- config_panel.toml.example | 84 ------------ scripts/_common.sh | 16 --- scripts/config | 264 -------------------------------------- scripts/install | 19 +-- scripts/remove | 7 - scripts/restore | 31 ++--- scripts/upgrade | 94 +------------- 7 files changed, 15 insertions(+), 500 deletions(-) delete mode 100644 config_panel.toml.example delete mode 100644 scripts/config diff --git a/config_panel.toml.example b/config_panel.toml.example deleted file mode 100644 index 604bb12..0000000 --- a/config_panel.toml.example +++ /dev/null @@ -1,84 +0,0 @@ -version = "1.0" - -[main] -name = "Etherpad configuration" - - - [main.export] - name = "Export" - - [main.export.export] - ask = "Use AbiWord (~260 Mo) or LibreOffice (~400 Mo) (more stable) to expand export possibilities (PDF, doc)?" - choices = ["none", "abiword", "libreoffice"] - default = "none" - - - [main.pad_configuration] - name = "Default pad configuration" - - [main.pad_configuration.pad_config_nocolors] - ask = "Hide authorship colors?" - type = "boolean" - default = false - - [main.pad_configuration.pad_config_showlinenumbers] - ask = "Show line numbers?" - type = "boolean" - default = true - - [main.pad_configuration.pad_config_chatandusers] - ask = "Show chat and users?" - type = "boolean" - default = false - - [main.pad_configuration.pad_config_alwaysshowchat] - ask = "Always show chat?" - type = "boolean" - default = false - - [main.pad_configuration.pad_config_show_markdown] - ask = "Show markdown syntax?" - type = "boolean" - default = false - - - [main.mypads_configuration] - name = "MyPads configuration" - - [main.mypads_configuration.mypads] - ask = "Enable MyPads plugin?" - type = "boolean" - default = true - - [main.mypads_configuration.useldap] - ask = "Use LDAP with MyPads?" - type = "boolean" - default = true - - - [main.overwrite_files] - name = "Overwriting config files during an upgrade" - - [main.overwrite_files.overwrite_settings] - ask = "Overwrite the config file settings.json?" - type = "boolean" - default = true - help = "If the file is overwritten, a backup will be created." - - [main.overwrite_files.overwrite_credentials] - ask = "Overwrite the config file credentials.json?" - type = "boolean" - default = true - help = "If the file is overwritten, a backup will be created." - - [main.overwrite_files.overwrite_nginx] - ask = "Overwrite the NGINX config file?" - type = "boolean" - default = true - help = "If the file is overwritten, a backup will be created." - - [main.overwrite_files.overwrite_systemd] - ask = "Overwrite the systemd config file?" - type = "boolean" - default = true - help = "If the file is overwritten, a backup will be created." diff --git a/scripts/_common.sh b/scripts/_common.sh index e2d83e7..d8e6290 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -33,14 +33,6 @@ ep_font_size_version=0.4.44 #================================================= ynh_maintenance_mode_ON () { - # Load value of $path and $domain from the config if their not set - if [ -z $path ]; then - path=$(ynh_app_setting_get $app path) - fi - if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) - fi - mkdir -p /var/www/html/ # Create an html to serve as maintenance notice @@ -89,14 +81,6 @@ include conf.d/yunohost_panel.conf.inc; } ynh_maintenance_mode_OFF () { - # Load value of $path and $domain from the config if their not set - if [ -z $path ]; then - path=$(ynh_app_setting_get $app path) - fi - if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) - fi - # Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app. echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" systemctl reload nginx diff --git a/scripts/config b/scripts/config deleted file mode 100644 index fc3a7d0..0000000 --- a/scripts/config +++ /dev/null @@ -1,264 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -# Load common variables for all scripts. -source _common.sh -source /usr/share/yunohost/helpers - -#================================================= -# SPECIFIC CODE -#================================================= -# DECLARE GENERIC FUNCTION -#================================================= - -config_file="$final_path/settings.json" - -get_config_value() { - option_name="$1" - # Get the value of this option in the config file - grep "^ *\"$option_name\" *:" "$config_file" | cut -d':' -f2 | sed s'/[ \"]//g' | cut -d',' -f1 -} - -#================================================= -# LOAD VALUES -#================================================= - -# Load the real value from the app config or elsewhere. -# Then get the value from the form. -# If the form has a value for a variable, take the value from the form, -# Otherwise, keep the value from the app config. - -# Export -old_export="$(ynh_app_setting_get $app export)" -export="${YNH_CONFIG_MAIN_EXPORT_EXPORT:-$old_export}" - -# padOptions noColors -old_pad_config_nocolors="$(get_config_value noColors)" -pad_config_nocolors="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_NOCOLORS:-$old_pad_config_nocolors}" - -# padOptions showLineNumbers -old_pad_config_showlinenumbers="$(get_config_value showLineNumbers)" -pad_config_showlinenumbers="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOWLINENUMBERS:-$old_pad_config_showlinenumbers}" - -# padOptions chatAndUsers -old_pad_config_chatandusers="$(get_config_value chatAndUsers)" -pad_config_chatandusers="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_CHATANDUSERS:-$old_pad_config_chatandusers}" - -# padOptions alwaysShowChat -old_pad_config_alwaysshowchat="$(get_config_value alwaysShowChat)" -pad_config_alwaysshowchat="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_ALWAYSSHOWCHAT:-$old_pad_config_alwaysshowchat}" - -# Plugin option ep_markdown_default -old_pad_config_show_markdown="$(get_config_value ep_markdown_default)" -pad_config_show_markdown="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOW_MARKDOWN:-$old_pad_config_show_markdown}" - -# MyPads -if [ -d $final_path/node_modules/ep_mypads ] -then - # Enable - old_mypads=1 -else - # Disable - old_mypads=0 -fi -mypads="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS:-$old_mypads}" - -# LDAP for MyPads -if grep -q "//noldap" $config_file -then - # Disable - old_useldap=0 -else - # Enable - old_useldap=1 -fi -useldap="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP:-$old_useldap}" - -# Overwrite settings.json file -old_overwrite_settings="$(ynh_app_setting_get --app=$app --key=overwrite_settings)" -overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}" - -# Overwrite credentials.json file -old_overwrite_credentials="$(ynh_app_setting_get --app=$app --key=overwrite_credentials)" -overwrite_credentials="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CREDENTIALS:-$old_overwrite_credentials}" - -# Overwrite nginx configuration -old_overwrite_nginx="$(ynh_app_setting_get --app=$app --key=overwrite_nginx)" -overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}" - -# Overwrite systemd configuration -old_overwrite_systemd="$(ynh_app_setting_get --app=$app --key=overwrite_systemd)" -overwrite_systemd="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD:-$old_overwrite_systemd}" - -#================================================= -# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND -#================================================= - -show_config() { - # here you are supposed to read some config file/database/other then print the values - # ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value" - - ynh_return "YNH_CONFIG_MAIN_EXPORT_EXPORT=$export" - - ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_NOCOLORS=$pad_config_nocolors" - ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOWLINENUMBERS=$pad_config_showlinenumbers" - ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_CHATANDUSERS=$pad_config_chatandusers" - ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_ALWAYSSHOWCHAT=$pad_config_alwaysshowchat" - ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOW_MARKDOWN=$pad_config_show_markdown" - ynh_return "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS=$mypads" - ynh_return "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP=$useldap" - ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings" - ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CREDENTIALS=$overwrite_credentials" - ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx" - ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd" -} - -#================================================= -# MODIFY THE CONFIGURATION -#================================================= - -apply_config() { - - #================================================= - # MODIFY ETHERPAD CONFIG - #================================================= - - restart_etherpad=0 - - # Change configuration if needed - # padOptions noColors - if [ "$pad_config_nocolors" != "$old_pad_config_nocolors" ] - then - ynh_replace_string --match_string="\(\"noColors\" *: \).*," --replace_string="\1$pad_config_nocolors," --target_file="$config_file" - ynh_app_setting_set --app=$app --key=pad_config_nocolors --value="$pad_config_nocolors" - restart_etherpad=1 - fi - - # padOptions showLineNumbers - if [ "$pad_config_showlinenumbers" != "$old_pad_config_showlinenumbers" ] - then - ynh_replace_string --match_string="\(\"showLineNumbers\" *: \).*," --replace_string="\1$pad_config_showlinenumbers," --target_file="$config_file" - ynh_app_setting_set --app=$app --key=pad_config_showlinenumbers --value="$pad_config_showlinenumbers" - restart_etherpad=1 - fi - - # padOptions chatAndUsers - if [ "$pad_config_chatandusers" != "$old_pad_config_chatandusers" ] - then - ynh_replace_string --match_string="\(\"chatAndUsers\" *: \).*," --replace_string="\1$pad_config_chatandusers," --target_file="$config_file" - ynh_app_setting_set --app=$app --key=pad_config_chatandusers --value="$pad_config_chatandusers" - restart_etherpad=1 - fi - - # padOptions alwaysShowChat - if [ "$pad_config_alwaysshowchat" != "$old_pad_config_alwaysshowchat" ] - then - ynh_replace_string --match_string="\(\"alwaysShowChat\" *: \).*," --replace_string="\1$pad_config_alwaysshowchat," --target_file="$config_file" - ynh_app_setting_set --app=$app --key=pad_config_alwaysshowchat --value="$pad_config_alwaysshowchat" - restart_etherpad=1 - fi - - # Plugin option ep_markdown_default - if [ "$pad_config_show_markdown" != "$old_pad_config_show_markdown" ] - then - ynh_replace_string --match_string="\(\"ep_markdown_default\" *: \).*," --replace_string="\1$pad_config_show_markdown," --target_file="$config_file" - ynh_app_setting_set --app=$app --key=pad_config_show_markdown --value="$pad_config_show_markdown" - restart_etherpad=1 - fi - - # Export - if [ "$export" != "$old_export" ] - then - if [ "$export" = "abiword" ] - then - # if Abiword isn't installed, call the action add_remove_abiword. - if ! which abiword > /dev/null - then - yunohost app action run $app add_remove_abiword - fi - ynh_replace_string --match_string="\(\"abiword\" *: \).*," --replace_string="\1\"$(which abiword)\"," --target_file="$config_file" - ynh_replace_string --match_string="\(\"soffice\" *: \).*," --replace_string="\1null," --target_file="$config_file" - elif [ "$export" = "libreoffice" ] - then - # if LibreOffice isn't installed, call the action add_remove_libreoffice. - if ! which soffice > /dev/null - then - yunohost app action run $app add_remove_libreoffice - fi - ynh_replace_string --match_string="\(\"abiword\" *: \).*," --replace_string="\1null," --target_file="$config_file" - ynh_replace_string --match_string="\(\"soffice\" *: \).*," --replace_string="\1\"$(which soffice)\"," --target_file="$config_file" - else - ynh_replace_string --match_string="\(\"abiword\" *: \).*," --replace_string="\1null," --target_file="$config_file" - ynh_replace_string --match_string="\(\"soffice\" *: \).*," --replace_string="\1null," --target_file="$config_file" - fi - - ynh_app_setting_set --app=$app --key=export --value="$export" - - restart_etherpad=1 - fi - - # MyPads - if [ "$mypads" != "$old_mypads" ] - then - ynh_use_nodejs - #pushd "$final_path/src" - #ynh_secure_remove --file="$final_path/src/package-lock.json" #added to fix saveError ENOENT: no such file or directory - if [ "$mypads" = "1" ] - then - ynh_exec_as $app env "$ynh_node_load_PATH" npm install ep_mypads@${mypads_version} - else - ynh_exec_as $app env "$ynh_node_load_PATH" npm uninstall ep_mypads - fi - popd - chown -R $app: $final_path/node_modules - - ynh_app_setting_set --app=$app --key=mypads --value="$mypads" - - restart_etherpad=1 - fi - - # LDAP for MyPads - if [ "$useldap" != "$old_useldap" ] - then - if [ "$useldap" = "1" ] - then - ynh_replace_string --match_string="//noldap\(.*\)" --replace_string="\1 //useldap" --target_file="$final_path/settings.json" - else - ynh_replace_string --match_string="\(.*\) //useldap" --replace_string="//noldap\1" --target_file="$final_path/settings.json" - fi - - ynh_app_setting_set --app=$app --key=useldap --value="$useldap" - - restart_etherpad=1 - fi - - - if [ $restart_etherpad -eq 1 ] - then - # Wait for etherpad to be fully started - ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" - fi - - #================================================= - # MODIFY OVERWRITTING SETTINGS - #================================================= - - # Set overwrite_settings - ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings" - # Set overwrite_credentials - ynh_app_setting_set --app=$app --key=overwrite_credentials --value="$overwrite_credentials" - # Set overwrite_nginx - ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx" - # Set overwrite_systemd - ynh_app_setting_set --app=$app --key=overwrite_systemd --value="$overwrite_systemd" -} - -#================================================= -# GENERIC FINALIZATION -#================================================= -ynh_app_config_run $1 diff --git a/scripts/install b/scripts/install index ce29600..5595ee1 100644 --- a/scripts/install +++ b/scripts/install @@ -1,29 +1,12 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then - sleep 60 + sleep 10 fi source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -password="$YNH_APP_ARG_PASSWORD" - -ynh_app_setting_set --app=$app --key=overwrite_settings --value="1" -ynh_app_setting_set --app=$app --key=overwrite_credentials --value="1" -ynh_app_setting_set --app=$app --key=overwrite_nginx --value="1" -ynh_app_setting_set --app=$app --key=overwrite_systemd --value="1" - #================================================= # INSTALL DEPENDENCIES #================================================= diff --git a/scripts/remove b/scripts/remove index 5008d7e..60e0cd2 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,13 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=3 - -export=$(ynh_app_setting_get --app=$app --key=export) - #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= diff --git a/scripts/restore b/scripts/restore index 7005a1c..78789ad 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,26 +1,13 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -# 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 -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=3 - -password=$(ynh_app_setting_get --app=$app --key=password) - #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=2 +# +ynh_script_progression --message="Restoring the app main directory..." --weight=5 ynh_restore_file --origin_path="$install_dir" @@ -38,11 +25,7 @@ chown $app:$app "$install_dir/credentials.json" #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 - -ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" -ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" -ynh_systemd_action --action=restart --service_name=fail2ban +ynh_script_progression --message="Restoring system configurations related to $app..." ynh_install_nodejs --nodejs_version=$nodejs_version ynh_use_nodejs @@ -60,10 +43,14 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" yunohost service add $app --description="Collaborative editor" --log="/var/log/$app/etherpad.log" +ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" +ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" +ynh_systemd_action --action=restart --service_name=fail2ban + #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=2 +ynh_script_progression --message="Restoring the MySQL database..." --weight=5 echo "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" | ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql @@ -73,7 +60,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./ #================================================= # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." ynh_systemd_action --service_name=$app --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" diff --git a/scripts/upgrade b/scripts/upgrade index c92b8cb..ed0dab2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,44 +1,8 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=20 - -export=$(ynh_app_setting_get --app=$app --key=export) -password=$(ynh_app_setting_get --app=$app --key=password) -mypads=$(ynh_app_setting_get --app=$app --key=mypads) -useldap=$(ynh_app_setting_get --app=$app --key=useldap) -abiword=$(ynh_app_setting_get --app=$app --key=abiword) -overwrite_settings=$(ynh_app_setting_get --app=$app --key=overwrite_settings) -overwrite_credentials=$(ynh_app_setting_get --app=$app --key=overwrite_credentials) -overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx) -overwrite_systemd=$(ynh_app_setting_get --app=$app --key=overwrite_systemd) - -# Optional parameters from config-panel feature -pad_config_nocolors=$(ynh_app_setting_get --app=$app --key=pad_config_nocolors) -pad_config_showlinenumbers=$(ynh_app_setting_get --app=$app --key=pad_config_showlinenumbers) -pad_config_chatandusers=$(ynh_app_setting_get --app=$app --key=pad_config_chatandusers) -pad_config_alwaysshowchat=$(ynh_app_setting_get --app=$app --key=pad_config_alwaysshowchat) -pad_config_show_markdown=$(ynh_app_setting_get --app=$app --key=pad_config_show_markdown) - -#================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." --weight=1 - -# Wait for etherpad to be fully started -ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" - upgrade_type=$(ynh_check_app_version_changed) #================================================= @@ -46,6 +10,9 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Activating maintenance mode..." --weight=2 +# Wait for etherpad to be fully started # (... but why ???) +ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" + ynh_maintenance_mode_ON #================================================= @@ -62,75 +29,32 @@ ynh_systemd_action --service_name=$app --action="stop" #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=2 -# If abiword setting doesn't exist -if [ -z "${abiword:-}" ]; then - abiword=0 - ynh_app_setting_set --app=$app --key=abiword --value=$abiword -fi - -# If abiword setting exists -if [ -n "${abiword:-}" ]; then - if [ $abiword -eq 1 ]; then - export=abiword - fi - ynh_app_setting_set --app=$app --key=export --value=$export - ynh_app_setting_delete --app=$app --key=abiword -fi - if [ -z "${language:-}" ]; then # If upgrading from a version which doesn't support translations, set language to English by default language=en ynh_app_setting_set --app=$app --key=language --value=$language fi -# If export setting doesn't exist if [ -z "${export:-}" ]; then export=none ynh_app_setting_set --app=$app --key=export --value=$export fi -# If mypads setting doesn't exist if [ -z "${mypads:-}" ]; then mypads=1 ynh_app_setting_set --app=$app --key=mypads --value=$mypads fi -# If useldap setting doesn't exist if [ -z "${useldap:-}" ]; then useldap=0 ynh_app_setting_set --app=$app --key=useldap --value=$useldap fi -# If path setting doesn't exist if [ -z "${path:-}" ]; then path="/" ynh_app_setting_set --app=$app --key=path --value=$path fi -# If overwrite_settings doesn't exist, create it -if [ -z "${overwrite_settings:-}" ]; then - overwrite_settings=1 - ynh_app_setting_set --app=$app --key=overwrite_settings --value=$overwrite_settings -fi - -# If overwrite_credentials doesn't exist, create it -if [ -z "${overwrite_credentials:-}" ]; then - overwrite_credentials=1 - ynh_app_setting_set --app=$app --key=overwrite_credentials --value=$overwrite_credentials -fi - -# If overwrite_nginx doesn't exist, create it -if [ -z "${overwrite_nginx:-}" ]; then - overwrite_nginx=1 - ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx -fi - -# If overwrite_systemd doesn't exist, create it -if [ -z "${overwrite_systemd:-}" ]; then - overwrite_systemd=1 - ynh_app_setting_set --app=$app --key=overwrite_systemd --value=$overwrite_systemd -fi - # Support full Unicode in MySQL databases ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \ <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;" @@ -163,11 +87,7 @@ ynh_use_nodejs #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 -# Overwrite the NGINX configuration only if it's allowed -if [ $overwrite_nginx -eq 1 ] -then - ynh_add_nginx_config -fi +ynh_add_nginx_config #================================================= # SPECIFIC UPGRADE @@ -219,11 +139,7 @@ chown $app:$app "$install_dir/credentials.json" #================================================= ynh_script_progression --message="Upgrading systemd configuration..." --weight=2 -# Create a dedicated systemd config -if [ $overwrite_systemd -eq 1 ] -then - ynh_add_systemd_config -fi +ynh_add_systemd_config #================================================= # INSTALL ETHERPAD'S PLUGINS From 648503a3661764478029ba254af1dc04ab740986 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 11 Dec 2023 01:48:52 +0100 Subject: [PATCH 14/14] Save the password as setting to be able to later regenerate the conf file --- scripts/install | 3 +++ scripts/upgrade | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/scripts/install b/scripts/install index 5595ee1..99e7840 100644 --- a/scripts/install +++ b/scripts/install @@ -7,6 +7,9 @@ fi source _common.sh source /usr/share/yunohost/helpers +# Save the passord (not saved automatically by the core) +ynh_app_setting_set --app=$app --key=password --value="$password" + #================================================= # INSTALL DEPENDENCIES #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index ed0dab2..6a43c06 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,6 +55,11 @@ if [ -z "${path:-}" ]; then ynh_app_setting_set --app=$app --key=path --value=$path fi +if [ -z "${password:-}" ]; then + password=$(ynh_string_random --length=32) + ynh_app_setting_set --app=$app --key=password --value="$password" +fi + # Support full Unicode in MySQL databases ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \ <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"