mirror of
https://github.com/YunoHost-Apps/dokuwiki_ynh.git
synced 2024-09-03 18:26:20 +02:00
Cleaning
This commit is contained in:
parent
07a018ba5e
commit
1eaf2dff7c
2 changed files with 72 additions and 17 deletions
|
@ -92,28 +92,82 @@ ynh_backup_if_checksum_is_different "$final_path/conf/local.protected.php"
|
||||||
# Always overwrite local file with the one from package.
|
# Always overwrite local file with the one from package.
|
||||||
cp conf/local.protected.php $final_path/conf
|
cp conf/local.protected.php $final_path/conf
|
||||||
|
|
||||||
if [ $is_internal_users -eq 1 ];
|
|
||||||
then
|
|
||||||
auth_backend="authchained"
|
|
||||||
|
|
||||||
#authchained_configuration='$conf['p lugin']['authchained']['authtypes'] = 'authldap:authplain';'
|
if [ $is_internal_users -eq 1 ]; then
|
||||||
#grep -q -F '$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain';' "$final_path/conf/local.protected.php" || echo 'include "/configs/projectname.conf"' >> foo.bar
|
auth_backend="authchained"
|
||||||
|
|
||||||
# Search if configuration in "config file" is present for plugin to work
|
# Automatically install "authchained" plugin
|
||||||
#TODO could be added straight to 'local.protected.php' file ?
|
# Allows to use multiple users backend storage : LDAP + internal DokuWiki users
|
||||||
grep -q -F '$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain';' "$final_path/conf/local.protected.php"
|
# See https://www.dokuwiki.org/plugin:authchained?s[]=chained
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
# If not found, add the setting to "local.protected.php" which can only be edited by Yunohost
|
plugin_archive=dokuwiki-plugin-authchained.tar.gz
|
||||||
# \$conf needs the "\" to espace the dollar and avoid echo to interprate it as a (void) variable
|
wget -nv --quiet 'https://github.com/rztuc/dokuwiki-plugin-authchained/archive/master.tar.gz' -O "$plugin_archive" -o /dev/null || true
|
||||||
echo "\$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain';" >> "$final_path/conf/local.protected.php"
|
|
||||||
fi
|
# if "file is not zero size"
|
||||||
# source: https://stackoverflow.com/questions/3557037/appending-a-line-to-a-file-only-if-it-does-not-already-exist
|
if [ -s "$plugin_archive" ]; then
|
||||||
|
|
||||||
|
tmpdir="$(ynh_smart_mktemp --min_size=1)" # Create a 1mb temporary folder
|
||||||
|
tar xzf "$plugin_archive" -C "$tmpdir" # Extract plugin to the temp folder
|
||||||
|
|
||||||
|
# Extract the "base" field from the plugin archive to create plugin folder name
|
||||||
|
# See https://www.dokuwiki.org/devel:plugin_info
|
||||||
|
#
|
||||||
|
# 'wildcard' is used to avoid having to find the name of the subfolder
|
||||||
|
# It should not change later but who knows...
|
||||||
|
plugin_folder_name=$(cat $tmpdir/*/plugin.info.txt | grep url | awk -F ':' '{print $3}')
|
||||||
|
|
||||||
|
# Define the path where plugin has to be installed
|
||||||
|
plugin_finalpath="$final_path/lib/plugins/$plugin_folder_name"
|
||||||
|
mkdir -p $plugin_finalpath
|
||||||
|
|
||||||
|
# Copy plugin files to DokuWiki plugin directory
|
||||||
|
# Doesn't work with "mv" so "cp" instead (taken from "upgrade" script)
|
||||||
|
cp -a $tmpdir/*/. "$plugin_finalpath/"
|
||||||
|
|
||||||
|
# Cleaning
|
||||||
|
ynh_secure_remove --file="$tmpdir"
|
||||||
|
|
||||||
|
# Set filesystem rights for new plugin
|
||||||
|
chown -R $app:root $plugin_finalpath
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
auth_backend="authldap"
|
auth_backend="authldap"
|
||||||
|
# TODO: Disable/remove "authchained"
|
||||||
|
|
||||||
|
|
||||||
|
##$plugins['authchained'] = 0; in plugins.local.php
|
||||||
|
#
|
||||||
|
#
|
||||||
|
## Use a "sub process" to start a new shell to run these commands
|
||||||
|
## Allow to use only one "cd" and to be more efficent
|
||||||
|
#(
|
||||||
|
# cd $final_path/conf
|
||||||
|
#
|
||||||
|
# cp plugins.local.php plugins.local.php.bak
|
||||||
|
#
|
||||||
|
# # Search if configuration in "config file" is present for plugin to work
|
||||||
|
# ## -F, --fixed-strings
|
||||||
|
# ## Interpret PATTERN as a list of fixed strings (instead of regular expressions), separated by newlines, any of which is to
|
||||||
|
# ## be matched.
|
||||||
|
# ## -q, --quiet, --silent
|
||||||
|
# ## Quiet; do not write anything to standard output. Exit immediately with zero status if any match is found, even if an
|
||||||
|
# ## error was detected. Also see the -s or --no-messages option.
|
||||||
|
# grep --quiet --fixed-strings '$plugins['authchained'] = 0;' "plugins.local.php"
|
||||||
|
# if [ $? -ne 0 ]; then
|
||||||
|
# echo "not found in file"
|
||||||
|
# # If not found, add the setting to "local.protected.php" which can only be edited by Yunohost
|
||||||
|
# # "\$conf" needs the "\" to espace the dollar and avoid echo to interprate it as a (void) variable
|
||||||
|
# #echo "\$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain';" >> "$final_path/conf/local.protected.php"
|
||||||
|
# else
|
||||||
|
# echo "not found in file"
|
||||||
|
# fi
|
||||||
|
# # source: https://stackoverflow.com/questions/3557037/appending-a-line-to-a-file-only-if-it-does-not-already-exist
|
||||||
|
#
|
||||||
|
#)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Set the authentification backend
|
# Set the authentification backend
|
||||||
#ynh_replace_string "^$conf['authtype'].*" "$conf['authtype'] = '$auth_backend';" "$final_path/conf/local.protected.php"
|
|
||||||
ynh_replace_string "__YNH_AUTH_BACKEND__" "$auth_backend" "$final_path/conf/local.protected.php"
|
ynh_replace_string "__YNH_AUTH_BACKEND__" "$auth_backend" "$final_path/conf/local.protected.php"
|
||||||
# Set the "admin" user
|
# 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"
|
||||||
|
|
|
@ -71,7 +71,8 @@ ynh_app_setting_set $app language $language
|
||||||
# Can be changed by action script "internal_users"
|
# Can be changed by action script "internal_users"
|
||||||
auth_backend='authldap' # Default backend is LDAP with Yunohost, 'authldap' for DokuWiki
|
auth_backend='authldap' # Default backend is LDAP with Yunohost, 'authldap' for DokuWiki
|
||||||
ynh_app_setting_set $app auth_backend $auth_backend
|
ynh_app_setting_set $app auth_backend $auth_backend
|
||||||
# Disable the 'is_internal_users' feature
|
|
||||||
|
# Force disable the 'is_internal_users' feature
|
||||||
ynh_app_setting_set $app is_internal_users 0
|
ynh_app_setting_set $app is_internal_users 0
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Add table
Reference in a new issue