From 854ba9417c073da4e179c82e63a09daa4add30d1 Mon Sep 17 00:00:00 2001 From: Gofannon Date: Fri, 28 Sep 2018 23:01:55 +0200 Subject: [PATCH] [enh] Add variable to handle authentication backend --- conf/local.protected.php | 4 ++-- scripts/install | 21 +++++++++++++++++---- scripts/upgrade | 12 +++++++++++- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/conf/local.protected.php b/conf/local.protected.php index f1b27c4..782e82d 100644 --- a/conf/local.protected.php +++ b/conf/local.protected.php @@ -2,7 +2,7 @@ /** * This file is used for configuration settings which cannot be modified by Dokuwiki admin panel * See here for explanations : https://www.dokuwiki.org/config - * + * * Yunohost dedicated settings are stored here in order to be able to upgrade the Yunohost package safely latter for Yunohost packager ( Yeah \o/ ) * * You should not modify this file direclty as it will be overwritten by Yunohost package @@ -12,7 +12,7 @@ /* Authentication Settings */ $conf['useacl'] = 1; //Use Access Control Lists to restrict access? -$conf['authtype'] = 'authldap'; //which authentication backend should be used +$conf['authtype'] = '__YNH_AUTH_BACKEND__'; //which authentication backend should be used $conf['passcrypt'] = 'sha1'; //Used crypt method (smd5,md5,sha1,ssha,crypt,mysql,my411) $conf['superuser'] = '__YNH_ADMIN_USER__'; //The admin can be user or @group or comma separated list user1,@group1,user2 $conf['manager'] = '__YNH_ADMIN_USER__'; //The manager can be user or @group or comma separated list user1,@group1,user2 diff --git a/scripts/install b/scripts/install index 6e509f6..787715f 100755 --- a/scripts/install +++ b/scripts/install @@ -53,6 +53,17 @@ ynh_app_setting_set $app admin $admin ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app language $language +#================================================= +# STORE DEFAULT VALUES FOR "ACTION SCRIPTS" +#================================================= + +# Needed for "upgrade" to know which backend to set back after overwriting "local.protected.php" +# Can be changed by action script "internal_users" +auth_backend='authldap' # Default backend is LDAP with Yunohost, 'authldap' for DokuWiki +ynh_app_setting_set $app auth_backend $auth_backend +# Disable the 'is_internal_users' feature +ynh_app_setting_set $app is_internal_users 0 + #================================================= # STANDARD MODIFICATIONS #================================================= @@ -111,22 +122,24 @@ ynh_print_info "Configuring dokuwiki..." # It will only be updated by Yunohost package or directly by adventurous users cp ../conf/local.protected.php $final_path/conf +# Set the authentification backend +ynh_replace_string "__YNH_AUTH_BACKEND__" "$auth_backend" "$final_path/conf/local.protected.php" # Set the "admin" user -ynh_replace_string "__YNH_ADMIN_USER__" "$admin" "$final_path/conf/local.protected.php" +ynh_replace_string "__YNH_ADMIN_USER__" "$admin" "$final_path/conf/local.protected.php" # This file might be modified by dokuwiki admin panel or by plugins # It will not be modified by Yunohost in order to keep user settings -cp ../conf/local.php $final_path/conf +cp ../conf/local.php $final_path/conf # Set the "language" -ynh_replace_string "__YNH_LANGUAGE__" "$language" "$final_path/conf/local.php" +ynh_replace_string "__YNH_LANGUAGE__" "$language" "$final_path/conf/local.php" # Restrict user rights by enforcing "read-only" mode for all users # See https://www.dokuwiki.org/acl#background_info # Default is "8" -cp ../conf/acl.auth.php $final_path/conf +cp ../conf/acl.auth.php $final_path/conf #================================================= # CREATE DEFAULT FILES diff --git a/scripts/upgrade b/scripts/upgrade index 7a0fb2a..e9f798f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,9 @@ admin=$(ynh_app_setting_get $app admin) is_public=$(ynh_app_setting_get $app is_public) final_path=$(ynh_app_setting_get $app final_path) +auth_backend=$(ynh_app_setting_get $app auth_backend) +#is_internal_users=$(ynh_app_setting_get $app is_internal_users) + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -55,6 +58,11 @@ if [ -z "$language" ]; then ynh_app_setting_set $app language $language fi +# 'is_internal_users' default value, if not set +if [ -z "$is_internal_users" ]; then + ynh_app_setting_set $app is_internal_users 0 +fi + # Yunohost specific configuration, if it isn't exist already @@ -233,8 +241,10 @@ ynh_backup_if_checksum_is_different "$final_path/conf/local.protected.php" # Always overwrite local file with the one from package. cp ../conf/local.protected.php $final_path/conf +# Set the authentification backend +ynh_replace_string "__YNH_AUTH_BACKEND__" "$auth_backend" "$final_path/conf/local.protected.php" # Set the "admin" user -ynh_replace_string "__YNH_ADMIN_USER__" "$admin" "$final_path/conf/local.protected.php" +ynh_replace_string "__YNH_ADMIN_USER__" "$admin" "$final_path/conf/local.protected.php" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum "$final_path/conf/local.protected.php"