diff --git a/README.md b/README.md index b9b96ed..843c7bf 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ However, with a YesWiki we can build a website with multiple uses: - Cultivate a bit of freedom... -**Shipped version:** 4.4.4~ynh6 +**Shipped version:** 4.4.4~ynh7 **Demo:** diff --git a/README_es.md b/README_es.md index 65eee5c..907a0a1 100644 --- a/README_es.md +++ b/README_es.md @@ -26,7 +26,7 @@ However, with a YesWiki we can build a website with multiple uses: - Cultivate a bit of freedom... -**Versión actual:** 4.4.4~ynh6 +**Versión actual:** 4.4.4~ynh7 **Demo:** diff --git a/README_eu.md b/README_eu.md index 1e24381..832909b 100644 --- a/README_eu.md +++ b/README_eu.md @@ -26,7 +26,7 @@ However, with a YesWiki we can build a website with multiple uses: - Cultivate a bit of freedom... -**Paketatutako bertsioa:** 4.4.4~ynh6 +**Paketatutako bertsioa:** 4.4.4~ynh7 **Demoa:** diff --git a/README_fr.md b/README_fr.md index 97a09af..f6adf49 100644 --- a/README_fr.md +++ b/README_fr.md @@ -26,7 +26,7 @@ Néanmoins, avec un YesWiki on peut fabriquer un site internet aux usages multip - Cultiver un bout de liberté... -**Version incluse :** 4.4.4~ynh6 +**Version incluse :** 4.4.4~ynh7 **Démo :** diff --git a/README_gl.md b/README_gl.md index d305b9c..7170669 100644 --- a/README_gl.md +++ b/README_gl.md @@ -26,7 +26,7 @@ However, with a YesWiki we can build a website with multiple uses: - Cultivate a bit of freedom... -**Versión proporcionada:** 4.4.4~ynh6 +**Versión proporcionada:** 4.4.4~ynh7 **Demo:** diff --git a/README_zh_Hans.md b/README_zh_Hans.md index 510a5ec..ae07f8d 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -26,7 +26,7 @@ However, with a YesWiki we can build a website with multiple uses: - Cultivate a bit of freedom... -**分发版本:** 4.4.4~ynh6 +**分发版本:** 4.4.4~ynh7 **演示:** diff --git a/conf/sync_app_importer.sh b/conf/sync_app_importer.sh new file mode 100644 index 0000000..620d6d1 --- /dev/null +++ b/conf/sync_app_importer.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +sudo -u __USER__ bash -c "cd __INSTALL_DIR__ && ./yeswicli importer:sync -s yunohost-cli" diff --git a/manifest.toml b/manifest.toml index 4d98338..6ca1819 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "YesWiki" description.en = "Wiki that is quick and easy to use" description.fr = "Wiki facile et rapide à prendre en main" -version = "4.4.4~ynh6" +version = "4.4.4~ynh7" maintainers = ["Florian Schmitt", "Nils Van Zuijlen", "Plumf"] @@ -72,7 +72,7 @@ ask.fr = "Choisissez le nom de votre wiki" help.en = "If you want a name with spaces: replace them with %20 for each space." help.fr = "Si vous souhaitez un nom avec des espacements : remplacez les par %20 pour chaque espace" type = "string" -default = "MyYunoHostWiki" +default = "YesWiki" [resources] [resources.sources.main] @@ -81,8 +81,8 @@ sha256 = "0b4e97bdd01ab627a8a9cb5bf652708e34a9322509cb8fcb9db0fb12b6a3e6ef" autoupdate.strategy = "latest_github_tag" [resources.sources.yunohostplugin] -url = "https://repository.yeswiki.net/doryphore/extension-yunohost-1.0.0.zip" -sha256 = "60032781016d2bdcecce4ad5ae91e72407e64a994f63661e27a7a935ba52d50b" +url = "https://repository.yeswiki.net/doryphore/extension-yunohost-1.0.1.zip" +sha256 = "43012db78928dd59539c764029880e3f74f82972e494f7ebf1e365d5f8763c6a" [resources.sources.importerplugin] url = "https://repository.yeswiki.net/doryphore/extension-importer-1.0.1.zip" diff --git a/scripts/backup b/scripts/backup index 214b288..4693a0b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -33,6 +33,18 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +#================================================= +# BACKUP THE IMPORTER PLUGIN SUDOERS FILE +#================================================= + +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" + #================================================= # BACKUP THE MYSQL DATABASE #================================================= diff --git a/scripts/install b/scripts/install index a697833..4d93d24 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 #================================================= @@ -77,7 +77,7 @@ ynh_replace_string --match_string="'allow_raw_html' => false," --replace_string= #================================================= ynh_script_progression --message="Configure importer plugin" --weight=1 -# Download yeswiki plugin from yeswiki repository +# Download importer plugin from yeswiki repository mkdir -p "$install_dir/tools/importer" ynh_setup_source --dest_dir="$install_dir/tools/importer" --source_id="importerplugin" @@ -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=" '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 @@ -100,6 +102,12 @@ chmod +x $install_dir/tools/yunohost/private/scripts/*.sh 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 + # At last, run the YunoHost app importer ynh_script_progression --message="Import YunoHost apps in bazar" --weight=2 pushd $install_dir @@ -139,7 +147,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 03fafa5..db4d6eb 100755 --- a/scripts/remove +++ b/scripts/remove @@ -20,7 +20,11 @@ ynh_remove_nginx_config # Remove the dedicated PHP-FPM config ynh_remove_fpm_config -# TODO: remove /etc/sudoers/$app +# Remove sudoers file +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" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 2dff91d..d50e58d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -35,6 +35,20 @@ ynh_script_progression --message="Restoring the NGINX web server configuration.. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RESTORE THE IMPORTER PLUGIN SUDOERS FILE +#================================================= +ynh_script_progression --message="Restoring the app importer plugin sudoers file..." + +ynh_restore_file --origin_path="/etc/sudoers.d/$app" + +#================================================= +# RESTORE THE IMPORTER PLUGIN POST APP INSTALL HOOK +#================================================= +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" + #================================================= # RESTORE THE MYSQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b453b76..02272bd 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 @@ -73,11 +73,39 @@ ynh_secure_remove "$install_dir/tools/importer" mkdir -p "$install_dir/tools/importer" ynh_setup_source --dest_dir="$install_dir/tools/importer" --source_id="importerplugin" +# Ensure that scripts are executable +chmod +x $install_dir/tools/yunohost/private/scripts/*.sh + +# Add app user in sudoers to authorize to launch yunohost cli commands without password +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 + +if [ $(grep yunohost_sso_domain "$install_dir/wakka.config.php" | wc -l) = "0" ]; then + SSO_DOMAIN=$(yunohost domain main-domain | sed -e 's/.*: //') + ynh_replace_string --match_string="'wakka_version'" --replace_string="'yunohost_sso_domain' => '${SSO_DOMAIN}',\n 'wakka_version'" --target_file="$install_dir/wakka.config.php" +fi + +# ToDo : Add app importer config in wakka.config.php if it is not already there ? + +# At last, run the YunoHost app importer if its data source is configured +if [ $(grep yunohost-cli "$install_dir/wakka.config.php" | wc -l) != "0" ]; then + ynh_script_progression --message="Import YunoHost apps in bazar" --weight=2 + pushd $install_dir + ynh_exec_as $app ./yeswicli importer:sync -s yunohost-cli + popd +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