diff --git a/CHANGELOG.md b/CHANGELOG.md index 93ea3bf..b03d4e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,26 @@ ------------ +# [2022.07.31a~ynh1] - 2022-09-XX + +## Added + +- New DokuWiki version `2022-07-31a "Igor"` with **Hotfix 2022-07-31a** +- New automated tests for "check_process" CI + +## Changed + +- Use PHP8.1 as default (PHP7.4 is bulleyes will be EOL "28 Nov 2022" so bump the version) +- Change method to "automatic upgrade" of plugins +- Cleanning 'admin permission' handling +- redo how php is managed: ynh_add_fpm_config + php config files +- Sync with reference package 'example_ynh' + +## Removed + +- automatic installation of plugin "logautherror" (not compatible) +- support for YunoHost below 11 (no time to test against older versions) + # [2020-07-29~ynh4] - 2021-01-19 ### Added diff --git a/README.md b/README.md index 6b752a3..71eccc6 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ DokuWiki is a simple to use and highly versatile Open Source wiki software that * During the upgrade, official plugins are also upgraded. We recommend that you should check that they run properly in the administration panel after the upgrade. We cannot know if some plugins are broken... -**Shipped version:** 2020.07.29~ynh6 +**Shipped version:** 2022.07.31a~ynh1 + **Demo:** https://demo.yunohost.org/dokuwiki/doku.php?id=start&do=login&u=demo&p=demo diff --git a/README_fr.md b/README_fr.md index ea9408a..3fa688b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -25,7 +25,8 @@ DokuWiki est un logiciel wiki Open Source simple à utiliser et très polyvalent * Lors de la mise à jour, les plugins officiels sont également mis à jour. Nous vous recommandons toutefois de vérifier le bon fonctionnement des plugins dans le panneau d'administration après cette opération. Nous ne pouvons pas savoir si des plugins spéciaux posent problèmes... -**Version incluse :** 2020.07.29~ynh6 +**Version incluse :** 2022.07.31a~ynh1 + **Démo :** https://demo.yunohost.org/dokuwiki/doku.php?id=start&do=login&u=demo&p=demo diff --git a/check_process b/check_process index 084fa0f..5ff09b0 100644 --- a/check_process +++ b/check_process @@ -14,15 +14,20 @@ setup_private=1 setup_public=1 upgrade=1 - # Laster released version. See https://github.com/YunoHost-Apps/dokuwiki_ynh/commits/master + # Latest released version. See https://github.com/YunoHost-Apps/dokuwiki_ynh/commits/master upgrade=1 from_commit=500a7d3fa9c008a2b75d0f6bec519e41fed97da0 + upgrade=1 from_commit=f45c459b287c8f045c08e65cea412cfc2cae38f4 backup_restore=1 multi_instance=1 change_url=1 + actions=0 + config_panel=0 ;;; Options Email= Notification=none ;;; Upgrade options - ; commit=01add99d3d903ca6d07f863045edf2ba46cf18d5 - name=Create check_process + ; commit=500a7d3fa9c008a2b75d0f6bec519e41fed97da0 + name=[fix] dedicated named location per $app (#63) manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=Yes&language=en& + ; commit=f45c459b287c8f045c08e65cea412cfc2cae38f4 + name=add config panel diff --git a/conf/app.src b/conf/app.src index 78012a6..8339df0 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/splitbrain/dokuwiki/archive/release_stable_2020-07-29.tar.gz -SOURCE_SUM=cc1cd9f00095fea327baa79d8f02c904fe1c37bc3f8fd9999eaf646ee9928884 +SOURCE_URL=https://download.dokuwiki.org/src/dokuwiki/dokuwiki-2022-07-31a.tgz +SOURCE_SUM=48ed2ae11fa4a0ae8338af9aedc837601b34e21c0be15d16e2d6228ca7a91f23 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf new file mode 100644 index 0000000..db2ca45 --- /dev/null +++ b/conf/extra_php-fpm.conf @@ -0,0 +1,7 @@ +; Additional 'php.ini' parameters for this YunoHost package/application + +; Common values to change to increase file upload limit +; Tips: you need to do modify nginx config too: "client_max_body_size" +php_admin_value[upload_max_filesize] = 25M +php_admin_value[post_max_size] = 25M +;source: https://www.dokuwiki.org/faq:uploadsize diff --git a/conf/logautherror.src b/conf/logautherror.src deleted file mode 100644 index f68bd07..0000000 --- a/conf/logautherror.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/mallchin/dokuwiki_plugin_logautherror/archive/master.zip -SOURCE_SUM=bc51d4da781d0aabab8e086e51f3cb77ac983eb4366f4c8f5247bb863d4a3bb2 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/manifest.json b/manifest.json index 02c097c..65f05d4 100644 --- a/manifest.json +++ b/manifest.json @@ -9,14 +9,15 @@ "es": "Sistema de Wiki de uso sencillicimo y compatible con los estándares", "it": "Wiki aderente agli standard, semplice da usare, finalizzato principalmente alla creazione di documentazione di qualsiasi tipo" }, - "version": "2020.07.29~ynh6", + "version": "2022.07.31a~ynh1", "url": "https://www.dokuwiki.org", "upstream": { "license": "GPL-2.0-or-later", "website": "https://www.dokuwiki.org", "demo": "https://demo.yunohost.org/dokuwiki/doku.php?id=start&do=login&u=demo&p=demo", "admindoc": "https://www.dokuwiki.org/manual", - "code": "https://github.com/splitbrain/dokuwiki" + "code": "https://github.com/splitbrain/dokuwiki", + "cpe": "cpe:2.3:a:dokuwiki:dokuwiki" }, "license": "GPL-2.0-or-later", "maintainer": { @@ -24,20 +25,21 @@ "email": "gofannon@riseup.net" }, "previous_maintainers": [ - { - "name": "opi", - "email": "opi@zeropi.net" - }], + { + "name": "opi", + "email": "opi@zeropi.net" + } + ], "requirements": { - "yunohost": ">= 4.3.0" + "yunohost": ">= 11.0.0" }, "multi_instance": true, "services": [ "nginx", - "php7.3-fpm" + "php8.1-fpm" ], "arguments": { - "install" : [ + "install": [ { "name": "domain", "type": "domain" @@ -55,7 +57,11 @@ { "name": "is_public", "type": "boolean", - "default": true + "default": true, + "help": { + "en": "Makes the wiki accessible directly from the Internet for everyone, without intermediate YunoHost authentication", + "fr": "Rend le wiki accessible directement depuis Internet pour tout le monde, sans authentification YunoHost intermédiaire" + } }, { "name": "language", @@ -64,9 +70,12 @@ "en": "Choose the application language", "fr": "Choisissez la langue de l'application" }, - "choices": ["en", "fr"], + "choices": [ + "en", + "fr" + ], "default": "en" } ] } -} +} \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index 80e5275..07ff399 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,10 +3,26 @@ #================================================= # COMMON VARIABLES #================================================= +# PHP APP SPECIFIC +#================================================= +# Depending on its version, YunoHost uses different default PHP version: +## YunoHost version "11.X" => PHP 7.4 +## YunoHost version "4.X" => PHP 7.3 +# +# This behaviour can be overridden by setting the YNH_PHP_VERSION variable +#YNH_PHP_VERSION=7.3 +#YNH_PHP_VERSION=7.4 +#YNH_PHP_VERSION=8.0 +YNH_PHP_VERSION=8.1 +# For more information, see the PHP application helper: https://github.com/YunoHost/yunohost/blob/dev/helpers/php#L3-L6 +# Or this app package depending on PHP: https://github.com/YunoHost-Apps/grav_ynh/blob/master/scripts/_common.sh +# PHP dependencies used by the app (must be on a single line) +php_dependencies="php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-cli" +# or, if you do not need a custom YNH_PHP_VERSION: +###php_dependencies="php$YNH_DEFAULT_PHP_VERSION-deb1 php$YNH_DEFAULT_PHP_VERSION-deb2" -YNH_PHP_VERSION="7.3" - -pkg_dependencies="php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-gd" +# dependencies used by the app (must be on a single line) +pkg_dependencies="$php_dependencies" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index 0f75316..72bf387 100755 --- a/scripts/install +++ b/scripts/install @@ -78,6 +78,16 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 + +# Create a dedicated PHP-FPM config +fpm_usage=low +fpm_footprint=low +ynh_add_fpm_config --usage="$fpm_usage" --footprint="$fpm_footprint" + #================================================= # NGINX CONFIGURATION #================================================= @@ -86,15 +96,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=2 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 - -# Create a dedicated PHP-FPM config -ynh_add_fpm_config --usage=low --footprint=low -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - #================================================= # SPECIFIC SETUP #================================================= @@ -117,8 +118,6 @@ ynh_script_progression --message="Configuring DokuWiki..." --weight=2 # This File cannot be modified directly by DokuWiki, only by hand or by YunoHost # It will only be updated by YunoHost package or directly by adventurous users -# Create the "admin" group and add the "admin" user -ynh_permission_create --permission "admin" --allowed "$admin_user" # Customize admin group in case of multiple wiki install managed by different admins # dokuwiki.admin; dokuwiki__1.admin; etc @@ -143,20 +142,20 @@ ynh_add_config --template="../conf/acl.auth.php" --destination="$final_path/conf # Other files will be read ony and owned by root. # See https://www.dokuwiki.org/install:permissions -cp $final_path/conf/local.php.dist $final_path/conf/local.php.bak -cp $final_path/conf/users.auth.php.dist $final_path/conf/users.auth.php +cp --archive $final_path/conf/local.php.dist $final_path/conf/local.php.bak +cp --archive $final_path/conf/users.auth.php.dist $final_path/conf/users.auth.php # This file might be used by plugins like https://www.dokuwiki.org/plugin:siteexport # Create it to be more "user friendly" as over the top security is not the main goal here # This file could be use for bad behaviour. # See https://www.dokuwiki.org/devel:preload?s[]=preload -cp $final_path/inc/preload.php.dist $final_path/inc/preload.php +cp --archive $final_path/inc/preload.php.dist $final_path/inc/preload.php # There is no template .dist provided inside DokuWiki installation folder # Create "empty" files to be able to manage linux permissions # Files content is taken from an existing DokuWiki installation -cp ../conf/plugins.local.php $final_path/conf -cp ../conf/plugins.local.php $final_path/conf/plugins.local.php.bak +cp --archive ../conf/plugins.local.php $final_path/conf +cp --archive ../conf/plugins.local.php $final_path/conf/plugins.local.php.bak #================================================= # STORE THE CHECKSUM OF THE CONFIG FILE @@ -166,13 +165,6 @@ cp ../conf/plugins.local.php $final_path/conf/plugins.local.php.bak #ynh_store_file_checksum --file="$final_path/conf/local.protected.php" ### Files '$final_path/conf/local.php' and '$final_path/conf/acl.auth.php' can be modified by user, no need to store checksum as they cannot be overwritten safely by the upgrade script -#================================================= -# INSTALL LOGAUTHERROR PLUGIN FOR FAIL2BAN -#================================================= -ynh_script_progression --message="Installing logautherror plugin for Fail2Ban..." --weight=2 - -ynh_setup_source --dest_dir="$final_path/lib/plugins/logautherror" --source_id=logautherror - # #================================================= # # GENERIC FINALIZATION # #================================================= @@ -234,6 +226,10 @@ then ynh_permission_update --permission="main" --add="visitors" fi +# Create the "admin" permission and add the "admin_user" to it +# More users can be added to the group from the YunoHost webadmin +ynh_permission_create --permission "admin" --allowed "$admin_user" + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/remove b/scripts/remove index b0d36b7..e2c981a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -45,6 +45,14 @@ ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2 # Remove the dedicated PHP-FPM config ynh_remove_fpm_config +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=1 + +# Remove metapackage and its dependencies if no other package need them +ynh_remove_app_dependencies + #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 7131e35..5f1e0f4 100755 --- a/scripts/restore +++ b/scripts/restore @@ -26,8 +26,8 @@ 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) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) @@ -41,12 +41,6 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -91,24 +85,6 @@ chown -R $app:www-data "$final_path" # # Allow to install templates # chown -R $app:root $final_path/lib/tpl -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=5 - -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - -# Recreate a dedicated php-fpm config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion - -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= @@ -118,6 +94,34 @@ 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 +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Reconfiguring PHP-FPM..." --weight=5 + +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +# Recreate a dedicated php-fpm config +# TODO: not in example_ynh, not needed? +#ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion + +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # GENERIC FINALIZATION #================================================= @@ -125,7 +129,7 @@ ynh_systemd_action --action=restart --service_name=fail2ban #================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-FPM.." --weight=2 -ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload +ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index a5ee7cf..790c8e0 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -143,22 +143,22 @@ if [ ! -f "$final_path/conf/local.php.bak" ]; then # if template exists if [ -f "$final_path/conf/local.php.dist" ]; then # Copy template to create default file - cp "$final_path/conf/local.php.dist" "$final_path/conf/local.php.bak" + cp --archive "$final_path/conf/local.php.dist" "$final_path/conf/local.php.bak" fi fi if [ ! -f "$final_path/conf/users.auth.php" ]; then if [ -f "$final_path/conf/users.auth.php.dist" ]; then - cp $final_path/conf/users.auth.php.dist $final_path/conf/users.auth.php + cp --archive $final_path/conf/users.auth.php.dist $final_path/conf/users.auth.php fi fi if [ ! -f "$final_path/conf/plugins.local.php" ]; then - cp ../conf/plugins.local.php $final_path/conf + cp --archive ../conf/plugins.local.php $final_path/conf fi if [ ! -f "$final_path/conf/plugins.local.php.bak" ]; then - cp ../conf/plugins.local.php $final_path/conf/plugins.local.php.bak + cp --archive ../conf/plugins.local.php $final_path/conf/plugins.local.php.bak fi @@ -166,10 +166,18 @@ if [ ! -f "$final_path/inc/preload.php" ]; then # if template exists if [ -f "$final_path/inc/preload.php.dist" ]; then # Copy template to create default file - cp "$final_path/inc/preload.php.dist" "$final_path/inc/preload.php" + cp --archive "$final_path/inc/preload.php.dist" "$final_path/inc/preload.php" fi fi +# purge "LOGAUTHERROR PLUGIN" as not compatible and not maintained anymore +# See https://www.dokuwiki.org/plugin:logautherror +if [ -d "$final_path/lib/plugins/logautherror" ]; then + ynh_script_progression --message="Purge "LOGAUTHERROR PLUGIN" as not maintained anymore" --weight=1 + ynh_secure_remove --file "$final_path/lib/plugins/logautherror" +fi + + #================================================= # CREATE DEDICATED USER #================================================= @@ -275,15 +283,27 @@ fi # TODO Taken from old "upgrade" script. Should check if it is needed and what it does # Update all plugins - for name_plugin in $(sudo -s cat $final_path/lib/plugins/*/plugin.info.txt | grep url | awk -F ':' '{print $3}'); - do - # Get a official plugin for dokuwiki, not update a no-official - wget -nv --quiet "https://github.com/splitbrain/dokuwiki-plugin-$name_plugin/zipball/master" -O "${name_plugin}.zip" -o /dev/null || true - if [ -s "${name_plugin}.zip" ]; then - unzip ${name_plugin}.zip - cp -a splitbrain-dokuwiki-plugin-${name_plugin}*/. "$final_path/lib/plugins/$name_plugin/" - fi - done + ###for name_plugin in $(sudo -s cat $final_path/lib/plugins/*/plugin.info.txt | grep url | awk -F ':' '{print $3}'); + ###do + ### # Get a official plugin for dokuwiki, not update a no-official + ### wget -nv --quiet "https://github.com/splitbrain/dokuwiki-plugin-$name_plugin/zipball/master" -O "${name_plugin}.zip" -o /dev/null || true + ### if [ -s "${name_plugin}.zip" ]; then + ### unzip ${name_plugin}.zip + ### cp -a splitbrain-dokuwiki-plugin-${name_plugin}*/. "$final_path/lib/plugins/$name_plugin/" + ### fi + ###done + + # if "file" exists and is executable + # Stolen from https://github.com/YunoHost-Apps/grav_ynh/blob/testing/scripts/upgrade#L189 + if [ -x "$final_path/bin/plugin.php" ]; then + pushd "$final_path" + ynh_exec_warn_less ynh_exec_as $app php${YNH_PHP_VERSION} bin/plugin.php --no-colors extension upgrade || ynh_print_warn --message="Automatic plugin upgrade has failed, you can upgrade them from your DokuWiki admin panel." + popd + else + ynh_print_warn --message="Automatic plugin cannot be done, you have to upgrade them from your DokuWiki admin panel." + fi + + fi #================================================= @@ -295,10 +315,7 @@ fi ynh_backup_if_checksum_is_different --file="$final_path/conf/local.protected.php" # Always overwrite local file with the one from package. -cp ../conf/local.protected.php $final_path/conf - -# Create the "admin" group and add the "admin" user -#ynh_permission_create --permission "admin" --allowed "$admin_user" +cp --archive ../conf/local.protected.php $final_path/conf # Customize admin group in case of multiple wiki install managed by different admins # dokuwiki.admin; dokuwiki__1.admin; etc @@ -307,13 +324,6 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$final_path/conf/local.protected.php" -#================================================= -# INSTALL LOGAUTHERROR PLUGIN FOR FAIL2BAN -#================================================= -ynh_script_progression --message="Upgrading logautherror plugin for Fail2Ban..." --weight=2 - -ynh_setup_source --dest_dir="$final_path/lib/plugins/logautherror" --source_id=logautherror - # #================================================= # # GENERIC FINALIZATION # #=================================================