From 7395ad46a7da5f97ab41e2057bea5093b5d419a7 Mon Sep 17 00:00:00 2001 From: Douze Baie <12b@distrilab.fr> Date: Fri, 14 Jun 2024 10:58:49 +0200 Subject: [PATCH 1/6] Add YunoHost SSO domain to YesWiki config file --- scripts/install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index 95e2405..586583e 100755 --- a/scripts/install +++ b/scripts/install @@ -92,6 +92,8 @@ ynh_setup_source --dest_dir="$install_dir/tools/yunohost" --source_id="yunohostp # Add config at the end of wakka.config.php ynh_replace_string --match_string=");" --replace_string=" 'dataSources' => [\n'yunohost-cli' => [\n'formId' => '5', // form id used in local bazar\n'lang' => 'fr',\n'importer' => 'YunohostCLIApp', // importer class name (without Importer suffix)\n],\n],\n);" --target_file="$install_dir/wakka.config.php" +SSO_DOMAIN = $(yunohost domain main-domain | sed -e 's/.*: //') +ynh_replace_string --match_string=");" --replace_string=" 'ynhSSODomain' => ${SSO_DOMAIN},\n);" --target_file="$install_dir/wakka.config.php" # Ensure that scripts are executable chmod +x $install_dir/tools/yunohost/private/scripts/*.sh From 0ae393d7478530da206289639a30b418344d7217 Mon Sep 17 00:00:00 2001 From: Douze Baie <12b@distrilab.fr> Date: Fri, 14 Jun 2024 11:15:41 +0200 Subject: [PATCH 2/6] fix typo --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 586583e..3373916 100755 --- a/scripts/install +++ b/scripts/install @@ -92,7 +92,7 @@ ynh_setup_source --dest_dir="$install_dir/tools/yunohost" --source_id="yunohostp # Add config at the end of wakka.config.php ynh_replace_string --match_string=");" --replace_string=" 'dataSources' => [\n'yunohost-cli' => [\n'formId' => '5', // form id used in local bazar\n'lang' => 'fr',\n'importer' => 'YunohostCLIApp', // importer class name (without Importer suffix)\n],\n],\n);" --target_file="$install_dir/wakka.config.php" -SSO_DOMAIN = $(yunohost domain main-domain | sed -e 's/.*: //') +SSO_DOMAIN=$(yunohost domain main-domain | sed -e 's/.*: //') ynh_replace_string --match_string=");" --replace_string=" 'ynhSSODomain' => ${SSO_DOMAIN},\n);" --target_file="$install_dir/wakka.config.php" # Ensure that scripts are executable From 8af61e56ee0e7e1257f45a6c4c6d88dc777df44b Mon Sep 17 00:00:00 2001 From: Douze Baie <12b@distrilab.fr> Date: Fri, 14 Jun 2024 11:31:13 +0200 Subject: [PATCH 3/6] Fix $app variable substitution --- scripts/backup | 2 +- scripts/install | 10 +++++----- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 10 +++++----- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/backup b/scripts/backup index f237759..4693a0b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -43,7 +43,7 @@ ynh_backup --src_path="/etc/sudoers.d/$app" # BACKUP THE IMPORTER PLUGIN POST APP INSTALL HOOK #================================================= -ynh_backup --src_path="/etc/yunohost/hooks.d/post_app_install/$app_sync_app_importer.sh" +ynh_backup --src_path="/etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh" #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/install b/scripts/install index 3373916..1645950 100755 --- a/scripts/install +++ b/scripts/install @@ -17,7 +17,7 @@ ynh_script_progression --message="Setting up source files..." --weight=5 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" -chown -R $app:www-data $install_dir +chown -R ${app}:www-data $install_dir chmod -R u=rwX,g=rX,o-rwx $install_dir #================================================= @@ -103,9 +103,9 @@ ynh_add_config --template="sudoers" --destination="/etc/sudoers.d/$app" chown root:root /etc/sudoers.d/$app # Add a post app install hook to sync the app importer -ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/hooks.d/post_app_install/$app_sync_app_importer.sh" -chown root:root /etc/yunohost/hooks.d/post_app_install/$app_sync_app_importer.sh -chmod +x /etc/yunohost/hooks.d/post_app_install/$app_sync_app_importer.sh +ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh" +chown root:root /etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh +chmod +x /etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh # At last, run the YunoHost app importer ynh_script_progression --message="Import YunoHost apps in bazar" --weight=2 @@ -146,7 +146,7 @@ fi # SECURE FILES AND DIRECTORIES #================================================= -chown -R $app:www-data $install_dir +chown -R ${app}:www-data $install_dir chmod -R u=rwX,g=rX,o-rwx $install_dir chmod g-rwx $install_dir/wakka.config.php diff --git a/scripts/remove b/scripts/remove index dce13b4..db4d6eb 100755 --- a/scripts/remove +++ b/scripts/remove @@ -24,7 +24,7 @@ ynh_remove_fpm_config ynh_secure_remove --file="/etc/sudoers/$app" # Remove post app install hook -ynh_secure_remove --file="/etc/yunohost/hooks.d/post_app_install/$app_sync_app_importer.sh" +ynh_secure_remove --file="/etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 87d2b2d..d50e58d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -47,7 +47,7 @@ ynh_restore_file --origin_path="/etc/sudoers.d/$app" #================================================= ynh_script_progression --message="Restoring the app importer post app install hook..." -ynh_restore_file --origin_path="/etc/yunohost/hooks.d/post_app_install/$app_sync_app_importer.sh" +ynh_restore_file --origin_path="/etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh" #================================================= # RESTORE THE MYSQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index 6c1a048..1f794e5 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -35,7 +35,7 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]; then fi chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R ${app}:www-data "$install_dir" #================================================= # PHP-FPM CONFIGURATION @@ -81,9 +81,9 @@ ynh_add_config --template="sudoers" --destination="/etc/sudoers.d/$app" chown root:root /etc/sudoers.d/$app # Add a post app install hook to sync the app importer -ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/hooks.d/post_app_install/$app_sync_app_importer.sh" -chown root:root /etc/yunohost/hooks.d/post_app_install/$app_sync_app_importer.sh -chmod +x /etc/yunohost/hooks.d/post_app_install/$app_sync_app_importer.sh +ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh" +chown root:root /etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh +chmod +x /etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh # ToDo : Add importer config in wakka.config.php if it is not already there ? # if [ ??? ]; then @@ -100,7 +100,7 @@ popd # SECURE FILES AND DIRECTORIES #================================================= -chown -R $app:www-data $install_dir +chown -R ${app}:www-data $install_dir chmod -R u=rwX,g=rX,o-rwx $install_dir chmod g-rwx $install_dir/wakka.config.php From 6125bfcdc5e8a8671627936a4c606668197d4d3f Mon Sep 17 00:00:00 2001 From: Douze Baie <12b@distrilab.fr> Date: Fri, 14 Jun 2024 11:39:10 +0200 Subject: [PATCH 4/6] Create post_app_install hook folder if it does not exist --- scripts/install | 1 + scripts/upgrade | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index 1645950..5db1b72 100755 --- a/scripts/install +++ b/scripts/install @@ -103,6 +103,7 @@ ynh_add_config --template="sudoers" --destination="/etc/sudoers.d/$app" chown root:root /etc/sudoers.d/$app # Add a post app install hook to sync the app importer +mkdir -p /etc/yunohost/hooks.d/post_app_install ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh" chown root:root /etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh chmod +x /etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh diff --git a/scripts/upgrade b/scripts/upgrade index 1f794e5..9ff7715 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,6 +81,7 @@ ynh_add_config --template="sudoers" --destination="/etc/sudoers.d/$app" chown root:root /etc/sudoers.d/$app # Add a post app install hook to sync the app importer +mkdir -p /etc/yunohost/hooks.d/post_app_install ynh_add_config --template="sync_app_importer.sh" --destination="/etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh" chown root:root /etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh chmod +x /etc/yunohost/hooks.d/post_app_install/${app}_sync_app_importer.sh From 93dca9c3eb4b209035131b1efe7dc69d10a98407 Mon Sep 17 00:00:00 2001 From: Douze Baie <12b@distrilab.fr> Date: Fri, 14 Jun 2024 11:50:58 +0200 Subject: [PATCH 5/6] change yunohost SSO domain configuration parameter name --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 5db1b72..8525a51 100755 --- a/scripts/install +++ b/scripts/install @@ -93,7 +93,7 @@ ynh_setup_source --dest_dir="$install_dir/tools/yunohost" --source_id="yunohostp # Add config at the end of wakka.config.php ynh_replace_string --match_string=");" --replace_string=" 'dataSources' => [\n'yunohost-cli' => [\n'formId' => '5', // form id used in local bazar\n'lang' => 'fr',\n'importer' => 'YunohostCLIApp', // importer class name (without Importer suffix)\n],\n],\n);" --target_file="$install_dir/wakka.config.php" SSO_DOMAIN=$(yunohost domain main-domain | sed -e 's/.*: //') -ynh_replace_string --match_string=");" --replace_string=" 'ynhSSODomain' => ${SSO_DOMAIN},\n);" --target_file="$install_dir/wakka.config.php" +ynh_replace_string --match_string=");" --replace_string=" 'yunohost_sso_domain' => ${SSO_DOMAIN},\n);" --target_file="$install_dir/wakka.config.php" # Ensure that scripts are executable chmod +x $install_dir/tools/yunohost/private/scripts/*.sh From f597cef147c53b62c1018dd626b66f85155d9b75 Mon Sep 17 00:00:00 2001 From: Douze Baie <12b@distrilab.fr> Date: Fri, 14 Jun 2024 13:00:28 +0200 Subject: [PATCH 6/6] Fix missing quotes around config param value --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 8525a51..4d93d24 100755 --- a/scripts/install +++ b/scripts/install @@ -93,7 +93,7 @@ ynh_setup_source --dest_dir="$install_dir/tools/yunohost" --source_id="yunohostp # Add config at the end of wakka.config.php ynh_replace_string --match_string=");" --replace_string=" 'dataSources' => [\n'yunohost-cli' => [\n'formId' => '5', // form id used in local bazar\n'lang' => 'fr',\n'importer' => 'YunohostCLIApp', // importer class name (without Importer suffix)\n],\n],\n);" --target_file="$install_dir/wakka.config.php" SSO_DOMAIN=$(yunohost domain main-domain | sed -e 's/.*: //') -ynh_replace_string --match_string=");" --replace_string=" 'yunohost_sso_domain' => ${SSO_DOMAIN},\n);" --target_file="$install_dir/wakka.config.php" +ynh_replace_string --match_string=");" --replace_string=" 'yunohost_sso_domain' => '${SSO_DOMAIN}',\n);" --target_file="$install_dir/wakka.config.php" # Ensure that scripts are executable chmod +x $install_dir/tools/yunohost/private/scripts/*.sh