From bd578c05c33f5e9758089e93786373ed0dfb5672 Mon Sep 17 00:00:00 2001 From: Gofannon Date: Fri, 28 Sep 2018 23:01:55 +0200 Subject: [PATCH 01/17] [enh] Add variable to handle authentication backend --- conf/local.protected.php | 4 ++-- scripts/install | 21 +++++++++++++++++---- scripts/upgrade | 18 +++++++++++++++--- 3 files changed, 34 insertions(+), 9 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 046c816..8297dcb 100755 --- a/scripts/install +++ b/scripts/install @@ -63,6 +63,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 #================================================= @@ -116,22 +127,24 @@ ynh_add_fpm_config # 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 75be9a7..f641101 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,6 +23,9 @@ is_public=$(ynh_app_setting_get $app is_public) #language=$(ynh_app_setting_get $app language) 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 not exists @@ -78,8 +86,10 @@ fi if [ ! -f "$final_path/conf/local.protected.php" ]; then cp ../conf/local.protected.php $final_path/conf - # Set the default "admin" - ynh_replace_string "__YNH_ADMIN_USER__" "$admin" "$final_path/conf/local.protected.php" + # 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" fi # Do not overwrite existing dokuwiki configuration as it could have user customization's and settings. @@ -238,8 +248,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" From fb981af6d5a6222e0ae7b72921154e3e9642e7d3 Mon Sep 17 00:00:00 2001 From: Gofannon Date: Fri, 28 Sep 2018 23:04:24 +0200 Subject: [PATCH 02/17] [enh] initial version of "actions scripts" --- actions.json | 40 ++++++++++ scripts/actions/internal_users | 133 +++++++++++++++++++++++++++++++++ scripts/actions/public_private | 59 +++++++++++++++ 3 files changed, 232 insertions(+) create mode 100644 actions.json create mode 100644 scripts/actions/internal_users create mode 100644 scripts/actions/public_private diff --git a/actions.json b/actions.json new file mode 100644 index 0000000..58afc94 --- /dev/null +++ b/actions.json @@ -0,0 +1,40 @@ +[{ + "id": "public_private", + "name": "Move to public or private", + "command": "/bin/bash scripts/actions/public_private", + "user": "root", + "accepted_return_codes": [0], + "description": { + "en": "Change the public access of the app." + }, + "arguments": [ + { + "name": "is_public", + "type": "boolean", + "ask": { + "en": "Is it a public app ? (1/0) (1=yes; 0=no)" + }, + "default": false + } + ] +}, +{ + "id": "internal_users", + "name": "Allow DokuWiki internal users storage in addition to Yunohost", + "command": "/bin/bash scripts/actions/internal_users", + "user": "root", + "accepted_return_codes": [0], + "description": { + "en": "Enable DokuWiki internal users." + }, + "arguments": [ + { + "name": "is_internal_users", + "type": "boolean", + "ask": { + "en": "Want to enable DokuWiki users too ? (1/0) (1=yes; 0=no)" + }, + "default": false + } + ] +}] diff --git a/scripts/actions/internal_users b/scripts/actions/internal_users new file mode 100644 index 0000000..743c86b --- /dev/null +++ b/scripts/actions/internal_users @@ -0,0 +1,133 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +# Get authentication backend and set as lowercase +#auth_backend=${YNH_ACTION_IS_INTERNAL_USERS,,} +# Get "is_internal_users" and set as lowercase +is_internal_users=${YNH_ACTION_IS_INTERNAL_USERS,,} + +# Get the full name of the app, Example: strut__3 +app=$YNH_APP_INSTANCE_NAME + +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_old=$(ynh_app_setting_get $app auth_backend) +is_internal_users_old=$(ynh_app_setting_get $app is_internal_users) + +#================================================= +# CHECK IF ARGUMENTS AND REQUIREMENTS ARE CORRECT +#================================================= + +#================================================= +# CHECK IF AN ACTION HAS TO BE DONE +#================================================= + +if [ $is_internal_users -eq $is_internal_users_old ] +then + ynh_die "is_internal_users is already set as $is_internal_users." 0 +fi + +# Ensure that app is public +if [ $is_public -eq 0 ]; then + ynh_die "Wiki must be public if you want your people to be able to reach it. Run 'public_private' and come back here" 1 +fi + +# Plugin "authchained" needs to be installed for this script to run +if [ ! -d $final_path/lib/plugins/authchained ]; then + ynh_die "Plugin 'authchained' is not installed and must be installed beforehand." 1 +fi + +### automatic installation of "authchained" plugin +### FIXME plugin installed this way does not work. Had to reinstall from "admin panel" +# Install "authchained" plugin. Allows to use multiple users backend storage : LDAP + internal DokuWiki users +# See https://www.dokuwiki.org/plugin:authchained?s[]=chained + +#sudo wget -nv --quiet "https://github.com/splitbrain/dokuwiki-plugin-${name_plugin}/zipball/master" -O "${name_plugin}.zip" -o /dev/null || true +#plugin_archive=dokuwiki-plugin-authchained.zip +#wget -nv --quiet 'https://github.com/rztuc/dokuwiki-plugin-authchained/archive/master.zip' -O "$plugin_archive" -o /dev/null || true +# +## if "file is not zero size" +#if [ -s "$plugin_archive" ]; then +# # path "authchained" is hardcoded and a better way should be to use the "base" field from the plugin archive +# # See https://www.dokuwiki.org/devel:plugin_info +# mkdir $final_path/lib/plugins/authchained +# +# # Extract plugin files strayed to the local plugin directory +# # Assume that the plugin name will not change in the futur +# # +# # unzip options +# # -j junk paths (do not make directories) +# # -d extract files into exdir +# unzip -j -d $final_path/lib/plugins/authchained "$plugin_archive" +# +# # Set filesystem rights for new plugin +# chown -R $app:root $final_path/lib/plugins/authchained +#fi + +#================================================= +# SPECIFIC ACTION +#================================================= + +### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. +### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. +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 + +if [ $is_internal_users -eq 1 ]; +then + auth_backend="authchained" + + #authchained_configuration='$conf['p lugin']['authchained']['authtypes'] = 'authldap:authplain';' + #grep -q -F '$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain';' "$final_path/conf/local.protected.php" || echo 'include "/configs/projectname.conf"' >> foo.bar + + # Search if configuration in "config file" is present for plugin to work + #TODO could be added straight to 'local.protected.php' file ? + grep -q -F '$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain';' "$final_path/conf/local.protected.php" + if [ $? -ne 0 ]; then + # 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" + fi + # source: https://stackoverflow.com/questions/3557037/appending-a-line-to-a-file-only-if-it-does-not-already-exist +else + auth_backend="authldap" +fi + +# 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" +# Set the "admin" user +ynh_replace_string "__YNH_ADMIN_USER__" "$admin" "$final_path/conf/local.protected.php" + +# Recalculate and store the config file checksum into the app settings +ynh_store_file_checksum "$final_path/conf/local.protected.php" + + +# Regen ssowat configuration +yunohost app ssowatconf + +# Update the config of the app +ynh_app_setting_set $app auth_backend $auth_backend +ynh_app_setting_set $app is_internal_users $is_internal_users + +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx diff --git a/scripts/actions/public_private b/scripts/actions/public_private new file mode 100644 index 0000000..0ce8a51 --- /dev/null +++ b/scripts/actions/public_private @@ -0,0 +1,59 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +# Get is_public and set as lowercase +is_public=${YNH_ACTION_IS_PUBLIC,,} + +# Get the full name of the app, Example: strut__3 +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# CHECK IF ARGUMENTS ARE CORRECT +#================================================= + +#================================================= +# CHECK IF AN ACTION HAS TO BE DONE +#================================================= + +is_public_old=$(ynh_app_setting_get $app is_public) + +if [ $is_public -eq $is_public_old ] +then + ynh_die "is_public is already set as $is_public." 0 +fi + +#================================================= +# SPECIFIC ACTION +#================================================= +# MOVE TO PUBLIC OR PRIVATE +#================================================= + +if [ $is_public -eq 0 ]; +then + ynh_app_setting_delete $app unprotected_uris +else + ynh_app_setting_set $app unprotected_uris "/" +fi + +# Regen ssowat configuration +yunohost app ssowatconf + +# Update the config of the app +ynh_app_setting_set $app is_public $is_public + +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx From 1f8f5455df25be1067da79df4e5d4885968552d5 Mon Sep 17 00:00:00 2001 From: Gofannon Date: Sun, 25 Nov 2018 13:12:22 +0100 Subject: [PATCH 03/17] Preload authchained config --- conf/local.protected.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/conf/local.protected.php b/conf/local.protected.php index 782e82d..04044c8 100644 --- a/conf/local.protected.php +++ b/conf/local.protected.php @@ -25,7 +25,11 @@ $conf['plugin']['authldap']['usertree'] = 'ou=users,dc=yunohost,dc=org'; $conf['plugin']['authldap']['userfilter'] = '(&(uid=%{user})(objectClass=posixAccount))'; # no groups #$conf['plugin']['authldap']['grouptree'] = 'ou=Group, dc=server, dc=tld'; -#$conf['plugin']['authldap']['groupfilter'] = '(&(objectClass=posixGroup)(|(gidNumber=%{gid})(memberUID=%{user})))'; +#$conf['plugin']['authldap']['groupfilter'] = '(&(objectClass=posixGroup)(|(gidNumber=%{gid})(memberUID=%{user})))'; + +// Authchained plugin preload configuration. Can be used by 'internal_users' action script +//$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain'; +// /* Advanced Settings */ $conf['updatecheck'] = 0; //automatically check for new releases? From a6c4196c35f3cd36b2e087fe9ff989f62470f4bd Mon Sep 17 00:00:00 2001 From: Gofannon Date: Sun, 12 May 2019 15:55:38 +0200 Subject: [PATCH 04/17] [fix] issues spotted durring review --- scripts/actions/internal_users | 18 +++++++----------- scripts/upgrade | 8 +++++++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/actions/internal_users b/scripts/actions/internal_users index 743c86b..271987b 100644 --- a/scripts/actions/internal_users +++ b/scripts/actions/internal_users @@ -13,8 +13,6 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -# Get authentication backend and set as lowercase -#auth_backend=${YNH_ACTION_IS_INTERNAL_USERS,,} # Get "is_internal_users" and set as lowercase is_internal_users=${YNH_ACTION_IS_INTERNAL_USERS,,} @@ -32,6 +30,11 @@ is_internal_users_old=$(ynh_app_setting_get $app is_internal_users) # CHECK IF ARGUMENTS AND REQUIREMENTS ARE CORRECT #================================================= +# Ensure that app is public +if [ $is_public -eq 0 ]; then + ynh_die "Wiki must be public if you want your people to be able to reach it. Run 'public_private' and come back here" 1 +fi + #================================================= # CHECK IF AN ACTION HAS TO BE DONE #================================================= @@ -118,16 +121,9 @@ ynh_replace_string "__YNH_ADMIN_USER__" "$admin" "$final_path/conf/loca # Recalculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/conf/local.protected.php" - -# Regen ssowat configuration -yunohost app ssowatconf +# Purge cache; see https://www.dokuwiki.org/faq:pluginproblems#cache +touch $final_path/conf/local.php # Update the config of the app ynh_app_setting_set $app auth_backend $auth_backend ynh_app_setting_set $app is_internal_users $is_internal_users - -#================================================= -# RELOAD NGINX -#================================================= - -systemctl reload nginx diff --git a/scripts/upgrade b/scripts/upgrade index f641101..121df1d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,7 +24,7 @@ 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) +is_internal_users=$(ynh_app_setting_get $app is_internal_users) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -58,6 +58,12 @@ if [ -z "$language" ]; then ynh_app_setting_set $app language $language fi +# 'auth_backend' default value, if not set +if [ -z "$auth_backend" ]; then + auth_backend='authldap' + ynh_app_setting_set $app auth_backend $authldap +fi + # 'is_internal_users' default value, if not set if [ -z "$is_internal_users" ]; then ynh_app_setting_set $app is_internal_users 0 From 37b76987d607407893bf2e69231e6f6bf259efad Mon Sep 17 00:00:00 2001 From: Gofannon Date: Sun, 12 May 2019 15:56:34 +0200 Subject: [PATCH 05/17] Overload default config for peace of mind Add this setting even if not use by default. Only usefull with "internal_users" script. Harmless and makes the maintenance easier --- conf/local.protected.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/local.protected.php b/conf/local.protected.php index 04044c8..3f5176c 100644 --- a/conf/local.protected.php +++ b/conf/local.protected.php @@ -28,8 +28,7 @@ $conf['plugin']['authldap']['userfilter'] = '(&(uid=%{user})(objectClass=posixA #$conf['plugin']['authldap']['groupfilter'] = '(&(objectClass=posixGroup)(|(gidNumber=%{gid})(memberUID=%{user})))'; // Authchained plugin preload configuration. Can be used by 'internal_users' action script -//$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain'; -// +$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain'; /* Advanced Settings */ $conf['updatecheck'] = 0; //automatically check for new releases? From 07a018ba5ecdef5319097834141d1f0e98d7f32a Mon Sep 17 00:00:00 2001 From: Gofannon Date: Sun, 12 May 2019 15:59:22 +0200 Subject: [PATCH 06/17] Add helper "ynh_smart_mktemp" --- scripts/_common.sh | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index bb04a03..d98beaf 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -10,4 +10,48 @@ ynh_delete_file_checksum () { local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' ynh_app_setting_delete $app $checksum_setting_name -} \ No newline at end of file +} + + + + + + + + +# Check available space before creating a temp directory. +# +# usage: ynh_smart_mktemp --min_size="Min size" +# +# | arg: -s, --min_size= - Minimal size needed for the temporary directory, in Mb +ynh_smart_mktemp () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [s]=min_size= ) + local min_size + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + min_size="${min_size:-300}" + # Transform the minimum size from megabytes to kilobytes + min_size=$(( $min_size * 1024 )) + + # Check if there's enough free space in a directory + is_there_enough_space () { + local free_space=$(df --output=avail "$1" | sed 1d) + test $free_space -ge $min_size + } + + if is_there_enough_space /tmp; then + local tmpdir=/tmp + elif is_there_enough_space /var; then + local tmpdir=/var + elif is_there_enough_space /; then + local tmpdir=/ + elif is_there_enough_space /home; then + local tmpdir=/home + else + ynh_die "Insufficient free space to continue..." + fi + + echo "$(sudo mktemp --directory --tmpdir="$tmpdir")" +} From 1eaf2dff7c61ecf061db2187e6cfe8f143bf3d70 Mon Sep 17 00:00:00 2001 From: Gofannon Date: Sun, 12 May 2019 15:59:55 +0200 Subject: [PATCH 07/17] Cleaning --- scripts/actions/internal_users | 86 +++++++++++++++++++++++++++------- scripts/install | 3 +- 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/scripts/actions/internal_users b/scripts/actions/internal_users index 271987b..9e24ab7 100644 --- a/scripts/actions/internal_users +++ b/scripts/actions/internal_users @@ -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. 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';' - #grep -q -F '$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain';' "$final_path/conf/local.protected.php" || echo 'include "/configs/projectname.conf"' >> foo.bar +if [ $is_internal_users -eq 1 ]; then + auth_backend="authchained" - # Search if configuration in "config file" is present for plugin to work - #TODO could be added straight to 'local.protected.php' file ? - grep -q -F '$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain';' "$final_path/conf/local.protected.php" - if [ $? -ne 0 ]; then - # 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" - fi - # source: https://stackoverflow.com/questions/3557037/appending-a-line-to-a-file-only-if-it-does-not-already-exist + # Automatically install "authchained" plugin + # Allows to use multiple users backend storage : LDAP + internal DokuWiki users + # See https://www.dokuwiki.org/plugin:authchained?s[]=chained + + plugin_archive=dokuwiki-plugin-authchained.tar.gz + wget -nv --quiet 'https://github.com/rztuc/dokuwiki-plugin-authchained/archive/master.tar.gz' -O "$plugin_archive" -o /dev/null || true + + # if "file is not zero size" + 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 - 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 + # 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" # Set the "admin" user ynh_replace_string "__YNH_ADMIN_USER__" "$admin" "$final_path/conf/local.protected.php" diff --git a/scripts/install b/scripts/install index 8297dcb..855a041 100755 --- a/scripts/install +++ b/scripts/install @@ -71,7 +71,8 @@ ynh_app_setting_set $app language $language # 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 + +# Force disable the 'is_internal_users' feature ynh_app_setting_set $app is_internal_users 0 #================================================= From c825710306eea5fa5f5fc6e6a74402159ed56baa Mon Sep 17 00:00:00 2001 From: Gofannon Date: Sun, 12 May 2019 16:51:10 +0200 Subject: [PATCH 08/17] cleaning 2 --- scripts/actions/internal_users | 37 ---------------------------------- 1 file changed, 37 deletions(-) diff --git a/scripts/actions/internal_users b/scripts/actions/internal_users index 9e24ab7..c69c626 100644 --- a/scripts/actions/internal_users +++ b/scripts/actions/internal_users @@ -44,43 +44,6 @@ then ynh_die "is_internal_users is already set as $is_internal_users." 0 fi -# Ensure that app is public -if [ $is_public -eq 0 ]; then - ynh_die "Wiki must be public if you want your people to be able to reach it. Run 'public_private' and come back here" 1 -fi - -# Plugin "authchained" needs to be installed for this script to run -if [ ! -d $final_path/lib/plugins/authchained ]; then - ynh_die "Plugin 'authchained' is not installed and must be installed beforehand." 1 -fi - -### automatic installation of "authchained" plugin -### FIXME plugin installed this way does not work. Had to reinstall from "admin panel" -# Install "authchained" plugin. Allows to use multiple users backend storage : LDAP + internal DokuWiki users -# See https://www.dokuwiki.org/plugin:authchained?s[]=chained - -#sudo wget -nv --quiet "https://github.com/splitbrain/dokuwiki-plugin-${name_plugin}/zipball/master" -O "${name_plugin}.zip" -o /dev/null || true -#plugin_archive=dokuwiki-plugin-authchained.zip -#wget -nv --quiet 'https://github.com/rztuc/dokuwiki-plugin-authchained/archive/master.zip' -O "$plugin_archive" -o /dev/null || true -# -## if "file is not zero size" -#if [ -s "$plugin_archive" ]; then -# # path "authchained" is hardcoded and a better way should be to use the "base" field from the plugin archive -# # See https://www.dokuwiki.org/devel:plugin_info -# mkdir $final_path/lib/plugins/authchained -# -# # Extract plugin files strayed to the local plugin directory -# # Assume that the plugin name will not change in the futur -# # -# # unzip options -# # -j junk paths (do not make directories) -# # -d extract files into exdir -# unzip -j -d $final_path/lib/plugins/authchained "$plugin_archive" -# -# # Set filesystem rights for new plugin -# chown -R $app:root $final_path/lib/plugins/authchained -#fi - #================================================= # SPECIFIC ACTION #================================================= From 854ba9417c073da4e179c82e63a09daa4add30d1 Mon Sep 17 00:00:00 2001 From: Gofannon Date: Fri, 28 Sep 2018 23:01:55 +0200 Subject: [PATCH 09/17] [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" From a40ae18d86fc498613f0c4116cb0958323ec9036 Mon Sep 17 00:00:00 2001 From: Gofannon Date: Fri, 28 Sep 2018 23:04:24 +0200 Subject: [PATCH 10/17] [enh] initial version of "actions scripts" --- actions.json | 40 ++++++++++ scripts/actions/internal_users | 133 +++++++++++++++++++++++++++++++++ scripts/actions/public_private | 59 +++++++++++++++ 3 files changed, 232 insertions(+) create mode 100644 actions.json create mode 100644 scripts/actions/internal_users create mode 100644 scripts/actions/public_private diff --git a/actions.json b/actions.json new file mode 100644 index 0000000..58afc94 --- /dev/null +++ b/actions.json @@ -0,0 +1,40 @@ +[{ + "id": "public_private", + "name": "Move to public or private", + "command": "/bin/bash scripts/actions/public_private", + "user": "root", + "accepted_return_codes": [0], + "description": { + "en": "Change the public access of the app." + }, + "arguments": [ + { + "name": "is_public", + "type": "boolean", + "ask": { + "en": "Is it a public app ? (1/0) (1=yes; 0=no)" + }, + "default": false + } + ] +}, +{ + "id": "internal_users", + "name": "Allow DokuWiki internal users storage in addition to Yunohost", + "command": "/bin/bash scripts/actions/internal_users", + "user": "root", + "accepted_return_codes": [0], + "description": { + "en": "Enable DokuWiki internal users." + }, + "arguments": [ + { + "name": "is_internal_users", + "type": "boolean", + "ask": { + "en": "Want to enable DokuWiki users too ? (1/0) (1=yes; 0=no)" + }, + "default": false + } + ] +}] diff --git a/scripts/actions/internal_users b/scripts/actions/internal_users new file mode 100644 index 0000000..743c86b --- /dev/null +++ b/scripts/actions/internal_users @@ -0,0 +1,133 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +# Get authentication backend and set as lowercase +#auth_backend=${YNH_ACTION_IS_INTERNAL_USERS,,} +# Get "is_internal_users" and set as lowercase +is_internal_users=${YNH_ACTION_IS_INTERNAL_USERS,,} + +# Get the full name of the app, Example: strut__3 +app=$YNH_APP_INSTANCE_NAME + +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_old=$(ynh_app_setting_get $app auth_backend) +is_internal_users_old=$(ynh_app_setting_get $app is_internal_users) + +#================================================= +# CHECK IF ARGUMENTS AND REQUIREMENTS ARE CORRECT +#================================================= + +#================================================= +# CHECK IF AN ACTION HAS TO BE DONE +#================================================= + +if [ $is_internal_users -eq $is_internal_users_old ] +then + ynh_die "is_internal_users is already set as $is_internal_users." 0 +fi + +# Ensure that app is public +if [ $is_public -eq 0 ]; then + ynh_die "Wiki must be public if you want your people to be able to reach it. Run 'public_private' and come back here" 1 +fi + +# Plugin "authchained" needs to be installed for this script to run +if [ ! -d $final_path/lib/plugins/authchained ]; then + ynh_die "Plugin 'authchained' is not installed and must be installed beforehand." 1 +fi + +### automatic installation of "authchained" plugin +### FIXME plugin installed this way does not work. Had to reinstall from "admin panel" +# Install "authchained" plugin. Allows to use multiple users backend storage : LDAP + internal DokuWiki users +# See https://www.dokuwiki.org/plugin:authchained?s[]=chained + +#sudo wget -nv --quiet "https://github.com/splitbrain/dokuwiki-plugin-${name_plugin}/zipball/master" -O "${name_plugin}.zip" -o /dev/null || true +#plugin_archive=dokuwiki-plugin-authchained.zip +#wget -nv --quiet 'https://github.com/rztuc/dokuwiki-plugin-authchained/archive/master.zip' -O "$plugin_archive" -o /dev/null || true +# +## if "file is not zero size" +#if [ -s "$plugin_archive" ]; then +# # path "authchained" is hardcoded and a better way should be to use the "base" field from the plugin archive +# # See https://www.dokuwiki.org/devel:plugin_info +# mkdir $final_path/lib/plugins/authchained +# +# # Extract plugin files strayed to the local plugin directory +# # Assume that the plugin name will not change in the futur +# # +# # unzip options +# # -j junk paths (do not make directories) +# # -d extract files into exdir +# unzip -j -d $final_path/lib/plugins/authchained "$plugin_archive" +# +# # Set filesystem rights for new plugin +# chown -R $app:root $final_path/lib/plugins/authchained +#fi + +#================================================= +# SPECIFIC ACTION +#================================================= + +### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. +### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. +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 + +if [ $is_internal_users -eq 1 ]; +then + auth_backend="authchained" + + #authchained_configuration='$conf['p lugin']['authchained']['authtypes'] = 'authldap:authplain';' + #grep -q -F '$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain';' "$final_path/conf/local.protected.php" || echo 'include "/configs/projectname.conf"' >> foo.bar + + # Search if configuration in "config file" is present for plugin to work + #TODO could be added straight to 'local.protected.php' file ? + grep -q -F '$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain';' "$final_path/conf/local.protected.php" + if [ $? -ne 0 ]; then + # 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" + fi + # source: https://stackoverflow.com/questions/3557037/appending-a-line-to-a-file-only-if-it-does-not-already-exist +else + auth_backend="authldap" +fi + +# 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" +# Set the "admin" user +ynh_replace_string "__YNH_ADMIN_USER__" "$admin" "$final_path/conf/local.protected.php" + +# Recalculate and store the config file checksum into the app settings +ynh_store_file_checksum "$final_path/conf/local.protected.php" + + +# Regen ssowat configuration +yunohost app ssowatconf + +# Update the config of the app +ynh_app_setting_set $app auth_backend $auth_backend +ynh_app_setting_set $app is_internal_users $is_internal_users + +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx diff --git a/scripts/actions/public_private b/scripts/actions/public_private new file mode 100644 index 0000000..0ce8a51 --- /dev/null +++ b/scripts/actions/public_private @@ -0,0 +1,59 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +# Get is_public and set as lowercase +is_public=${YNH_ACTION_IS_PUBLIC,,} + +# Get the full name of the app, Example: strut__3 +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# CHECK IF ARGUMENTS ARE CORRECT +#================================================= + +#================================================= +# CHECK IF AN ACTION HAS TO BE DONE +#================================================= + +is_public_old=$(ynh_app_setting_get $app is_public) + +if [ $is_public -eq $is_public_old ] +then + ynh_die "is_public is already set as $is_public." 0 +fi + +#================================================= +# SPECIFIC ACTION +#================================================= +# MOVE TO PUBLIC OR PRIVATE +#================================================= + +if [ $is_public -eq 0 ]; +then + ynh_app_setting_delete $app unprotected_uris +else + ynh_app_setting_set $app unprotected_uris "/" +fi + +# Regen ssowat configuration +yunohost app ssowatconf + +# Update the config of the app +ynh_app_setting_set $app is_public $is_public + +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx From 3a8b257c4073659c84c9c0ae13167811089051b6 Mon Sep 17 00:00:00 2001 From: Gofannon Date: Sun, 25 Nov 2018 13:12:22 +0100 Subject: [PATCH 11/17] Preload authchained config --- conf/local.protected.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/conf/local.protected.php b/conf/local.protected.php index 782e82d..04044c8 100644 --- a/conf/local.protected.php +++ b/conf/local.protected.php @@ -25,7 +25,11 @@ $conf['plugin']['authldap']['usertree'] = 'ou=users,dc=yunohost,dc=org'; $conf['plugin']['authldap']['userfilter'] = '(&(uid=%{user})(objectClass=posixAccount))'; # no groups #$conf['plugin']['authldap']['grouptree'] = 'ou=Group, dc=server, dc=tld'; -#$conf['plugin']['authldap']['groupfilter'] = '(&(objectClass=posixGroup)(|(gidNumber=%{gid})(memberUID=%{user})))'; +#$conf['plugin']['authldap']['groupfilter'] = '(&(objectClass=posixGroup)(|(gidNumber=%{gid})(memberUID=%{user})))'; + +// Authchained plugin preload configuration. Can be used by 'internal_users' action script +//$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain'; +// /* Advanced Settings */ $conf['updatecheck'] = 0; //automatically check for new releases? From cc963615b4017fcb39829900d52d4943de0fc652 Mon Sep 17 00:00:00 2001 From: Gofannon Date: Sun, 12 May 2019 15:55:38 +0200 Subject: [PATCH 12/17] [fix] issues spotted durring review --- scripts/actions/internal_users | 18 +++++++----------- scripts/upgrade | 8 +++++++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/actions/internal_users b/scripts/actions/internal_users index 743c86b..271987b 100644 --- a/scripts/actions/internal_users +++ b/scripts/actions/internal_users @@ -13,8 +13,6 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -# Get authentication backend and set as lowercase -#auth_backend=${YNH_ACTION_IS_INTERNAL_USERS,,} # Get "is_internal_users" and set as lowercase is_internal_users=${YNH_ACTION_IS_INTERNAL_USERS,,} @@ -32,6 +30,11 @@ is_internal_users_old=$(ynh_app_setting_get $app is_internal_users) # CHECK IF ARGUMENTS AND REQUIREMENTS ARE CORRECT #================================================= +# Ensure that app is public +if [ $is_public -eq 0 ]; then + ynh_die "Wiki must be public if you want your people to be able to reach it. Run 'public_private' and come back here" 1 +fi + #================================================= # CHECK IF AN ACTION HAS TO BE DONE #================================================= @@ -118,16 +121,9 @@ ynh_replace_string "__YNH_ADMIN_USER__" "$admin" "$final_path/conf/loca # Recalculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/conf/local.protected.php" - -# Regen ssowat configuration -yunohost app ssowatconf +# Purge cache; see https://www.dokuwiki.org/faq:pluginproblems#cache +touch $final_path/conf/local.php # Update the config of the app ynh_app_setting_set $app auth_backend $auth_backend ynh_app_setting_set $app is_internal_users $is_internal_users - -#================================================= -# RELOAD NGINX -#================================================= - -systemctl reload nginx diff --git a/scripts/upgrade b/scripts/upgrade index e9f798f..7b70b82 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,7 +23,7 @@ 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) +is_internal_users=$(ynh_app_setting_get $app is_internal_users) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -58,6 +58,12 @@ if [ -z "$language" ]; then ynh_app_setting_set $app language $language fi +# 'auth_backend' default value, if not set +if [ -z "$auth_backend" ]; then + auth_backend='authldap' + ynh_app_setting_set $app auth_backend $authldap +fi + # 'is_internal_users' default value, if not set if [ -z "$is_internal_users" ]; then ynh_app_setting_set $app is_internal_users 0 From f927f2ab9f29bd43078e2f299df8259aae477726 Mon Sep 17 00:00:00 2001 From: Gofannon Date: Sun, 12 May 2019 15:56:34 +0200 Subject: [PATCH 13/17] Overload default config for peace of mind Add this setting even if not use by default. Only usefull with "internal_users" script. Harmless and makes the maintenance easier --- conf/local.protected.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/local.protected.php b/conf/local.protected.php index 04044c8..3f5176c 100644 --- a/conf/local.protected.php +++ b/conf/local.protected.php @@ -28,8 +28,7 @@ $conf['plugin']['authldap']['userfilter'] = '(&(uid=%{user})(objectClass=posixA #$conf['plugin']['authldap']['groupfilter'] = '(&(objectClass=posixGroup)(|(gidNumber=%{gid})(memberUID=%{user})))'; // Authchained plugin preload configuration. Can be used by 'internal_users' action script -//$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain'; -// +$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain'; /* Advanced Settings */ $conf['updatecheck'] = 0; //automatically check for new releases? From 8a460dcc1432a023bb9375a1fcc4e797fab40763 Mon Sep 17 00:00:00 2001 From: Gofannon Date: Sun, 12 May 2019 15:59:22 +0200 Subject: [PATCH 14/17] Add helper "ynh_smart_mktemp" --- scripts/_common.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/scripts/_common.sh b/scripts/_common.sh index a9bf588..e9a1f09 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1 +1,38 @@ #!/bin/bash + +# Check available space before creating a temp directory. +# +# usage: ynh_smart_mktemp --min_size="Min size" +# +# | arg: -s, --min_size= - Minimal size needed for the temporary directory, in Mb +ynh_smart_mktemp () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [s]=min_size= ) + local min_size + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + min_size="${min_size:-300}" + # Transform the minimum size from megabytes to kilobytes + min_size=$(( $min_size * 1024 )) + + # Check if there's enough free space in a directory + is_there_enough_space () { + local free_space=$(df --output=avail "$1" | sed 1d) + test $free_space -ge $min_size + } + + if is_there_enough_space /tmp; then + local tmpdir=/tmp + elif is_there_enough_space /var; then + local tmpdir=/var + elif is_there_enough_space /; then + local tmpdir=/ + elif is_there_enough_space /home; then + local tmpdir=/home + else + ynh_die "Insufficient free space to continue..." + fi + + echo "$(sudo mktemp --directory --tmpdir="$tmpdir")" +} From 49b5bf85205b9d84cf93c0f863dc3d54e5696eae Mon Sep 17 00:00:00 2001 From: Gofannon Date: Sun, 12 May 2019 15:59:55 +0200 Subject: [PATCH 15/17] Cleaning --- scripts/actions/internal_users | 86 +++++++++++++++++++++++++++------- scripts/install | 3 +- 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/scripts/actions/internal_users b/scripts/actions/internal_users index 271987b..9e24ab7 100644 --- a/scripts/actions/internal_users +++ b/scripts/actions/internal_users @@ -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. 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';' - #grep -q -F '$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain';' "$final_path/conf/local.protected.php" || echo 'include "/configs/projectname.conf"' >> foo.bar +if [ $is_internal_users -eq 1 ]; then + auth_backend="authchained" - # Search if configuration in "config file" is present for plugin to work - #TODO could be added straight to 'local.protected.php' file ? - grep -q -F '$conf['plugin']['authchained']['authtypes'] = 'authldap:authplain';' "$final_path/conf/local.protected.php" - if [ $? -ne 0 ]; then - # 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" - fi - # source: https://stackoverflow.com/questions/3557037/appending-a-line-to-a-file-only-if-it-does-not-already-exist + # Automatically install "authchained" plugin + # Allows to use multiple users backend storage : LDAP + internal DokuWiki users + # See https://www.dokuwiki.org/plugin:authchained?s[]=chained + + plugin_archive=dokuwiki-plugin-authchained.tar.gz + wget -nv --quiet 'https://github.com/rztuc/dokuwiki-plugin-authchained/archive/master.tar.gz' -O "$plugin_archive" -o /dev/null || true + + # if "file is not zero size" + 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 - 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 + # 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" # Set the "admin" user ynh_replace_string "__YNH_ADMIN_USER__" "$admin" "$final_path/conf/local.protected.php" diff --git a/scripts/install b/scripts/install index 787715f..bfd7638 100755 --- a/scripts/install +++ b/scripts/install @@ -61,7 +61,8 @@ ynh_app_setting_set $app language $language # 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 + +# Force disable the 'is_internal_users' feature ynh_app_setting_set $app is_internal_users 0 #================================================= From 6bd544f2d12de14c11cf98240e9d1da35da528df Mon Sep 17 00:00:00 2001 From: Gofannon Date: Sun, 12 May 2019 16:51:10 +0200 Subject: [PATCH 16/17] cleaning 2 --- scripts/actions/internal_users | 37 ---------------------------------- 1 file changed, 37 deletions(-) diff --git a/scripts/actions/internal_users b/scripts/actions/internal_users index 9e24ab7..c69c626 100644 --- a/scripts/actions/internal_users +++ b/scripts/actions/internal_users @@ -44,43 +44,6 @@ then ynh_die "is_internal_users is already set as $is_internal_users." 0 fi -# Ensure that app is public -if [ $is_public -eq 0 ]; then - ynh_die "Wiki must be public if you want your people to be able to reach it. Run 'public_private' and come back here" 1 -fi - -# Plugin "authchained" needs to be installed for this script to run -if [ ! -d $final_path/lib/plugins/authchained ]; then - ynh_die "Plugin 'authchained' is not installed and must be installed beforehand." 1 -fi - -### automatic installation of "authchained" plugin -### FIXME plugin installed this way does not work. Had to reinstall from "admin panel" -# Install "authchained" plugin. Allows to use multiple users backend storage : LDAP + internal DokuWiki users -# See https://www.dokuwiki.org/plugin:authchained?s[]=chained - -#sudo wget -nv --quiet "https://github.com/splitbrain/dokuwiki-plugin-${name_plugin}/zipball/master" -O "${name_plugin}.zip" -o /dev/null || true -#plugin_archive=dokuwiki-plugin-authchained.zip -#wget -nv --quiet 'https://github.com/rztuc/dokuwiki-plugin-authchained/archive/master.zip' -O "$plugin_archive" -o /dev/null || true -# -## if "file is not zero size" -#if [ -s "$plugin_archive" ]; then -# # path "authchained" is hardcoded and a better way should be to use the "base" field from the plugin archive -# # See https://www.dokuwiki.org/devel:plugin_info -# mkdir $final_path/lib/plugins/authchained -# -# # Extract plugin files strayed to the local plugin directory -# # Assume that the plugin name will not change in the futur -# # -# # unzip options -# # -j junk paths (do not make directories) -# # -d extract files into exdir -# unzip -j -d $final_path/lib/plugins/authchained "$plugin_archive" -# -# # Set filesystem rights for new plugin -# chown -R $app:root $final_path/lib/plugins/authchained -#fi - #================================================= # SPECIFIC ACTION #================================================= From f9443712d8e24b8cd0b90ac9934b3b62b7970629 Mon Sep 17 00:00:00 2001 From: Gofannon Date: Fri, 10 Jan 2020 17:58:25 +0100 Subject: [PATCH 17/17] Switch to toml and fix scripts --- actions.json | 40 ------- actions.toml | 52 ++++++++ config_panel.toml | 30 +++++ scripts/config | 294 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 376 insertions(+), 40 deletions(-) delete mode 100644 actions.json create mode 100644 actions.toml create mode 100644 config_panel.toml create mode 100644 scripts/config diff --git a/actions.json b/actions.json deleted file mode 100644 index 58afc94..0000000 --- a/actions.json +++ /dev/null @@ -1,40 +0,0 @@ -[{ - "id": "public_private", - "name": "Move to public or private", - "command": "/bin/bash scripts/actions/public_private", - "user": "root", - "accepted_return_codes": [0], - "description": { - "en": "Change the public access of the app." - }, - "arguments": [ - { - "name": "is_public", - "type": "boolean", - "ask": { - "en": "Is it a public app ? (1/0) (1=yes; 0=no)" - }, - "default": false - } - ] -}, -{ - "id": "internal_users", - "name": "Allow DokuWiki internal users storage in addition to Yunohost", - "command": "/bin/bash scripts/actions/internal_users", - "user": "root", - "accepted_return_codes": [0], - "description": { - "en": "Enable DokuWiki internal users." - }, - "arguments": [ - { - "name": "is_internal_users", - "type": "boolean", - "ask": { - "en": "Want to enable DokuWiki users too ? (1/0) (1=yes; 0=no)" - }, - "default": false - } - ] -}] diff --git a/actions.toml b/actions.toml new file mode 100644 index 0000000..a5346d9 --- /dev/null +++ b/actions.toml @@ -0,0 +1,52 @@ +[public_private] +name = "Move to public or private" +command = "/bin/bash scripts/actions/public_private" +user = "root" # optional +#cwd = "/" # optional +#accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "Change the public access of the app." + + [public_private.arguments] + [public_private.arguments.is_public] + type = "boolean" + ask = "Is it a public app ? (1/0) (1=yes; 0=no)" + example = "0" + default = false + +[internal_users] +name = "Allow DokuWiki internal users storage in addition to Yunohost" +command = "/bin/bash scripts/actions/internal_users" +user = "root" # optional +#cwd = "/" # optional +#accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "Enable DokuWiki internal users." + + [internal_users.arguments] + [internal_users.arguments.is_internal_users] + type = "boolean" + ask = "Want to enable DokuWiki users too ? (1/0) (1=yes; 0=no)" + example = "0" + default = false + +#[echo_plop] +#name = "echo plop" +#command = "echo plop" +# +# [echo_plop.arguments] +# [echo_plop.arguments.argument_one] +# type = "string" +# ask = "some stuff" +# example = "stuff" +# +# [echo_plop.arguments.argument_two] +# type = "string" +# ask = "some stuff" +# example = "stuff" +# +# [echo_plop.arguments.argument_three] +# type = "string" +# ask = "some stuff" +# example = "stuff" +# \ No newline at end of file diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..61c2c39 --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,30 @@ +version = "0.1" +name = "DokuWiki configuration panel" + +[main] +name = "DokuWiki configuration" + + [main.public_access] + name = "Public access" + + [main.public_access.is_public] + ask = "Is it a public website ?" + type = "boolean" + default = false + help = "By activating this, people who does not have a YunoHost account will be able to reach your Wiki." + + [main.internal_users] + name = "Internal users" + + [main.internal_users.is_internal_users] + ask = "Allow local users from DokuWiki in addition to Yunohost users ?" + type = "boolean" + default = false + help = "By activating this, people will be able to create account and loggin on the wiki" + + # WIP + #[main.internal_users.self_register] + #name = "Allow guest users to create an account ?" + #help = "By activating this, people will be able to self register and then logging" + #type = "bool" + #default = false diff --git a/scripts/config b/scripts/config new file mode 100644 index 0000000..1d7cdf9 --- /dev/null +++ b/scripts/config @@ -0,0 +1,294 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers +# Load common variables for all scripts. +#source _variables TODO: remove ? + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +app=$YNH_APP_INSTANCE_NAME + +final_path=$(ynh_app_setting_get $app final_path) + +#================================================= +# SPECIFIC CODE +#================================================= +# DECLARE GENERIC FUNCTION +#================================================= + +#config_file="$final_path/settings.json" + +#get_config_value() { +# option_name="$1" +# # Get the value of this option in the config file +# grep "\"$option_name\" *:" "$config_file" | cut -d':' -f2 | sed s'/ //g' | cut -d',' -f1 +# +#} + +#================================================= +# LOAD VALUES +#================================================= + + # Load the real value from the app config or elsewhere. + # Then get the value from the form. + # If the form has a value for a variable, take the value from the form, + # Otherwise, keep the value from the app config. + + # Some bash magic explained before diving into the code + # ${VAR:-WORD} + # If VAR is not defined or null, the expansion of WORD is substituted; otherwise the value of VAR is substituted: + # See http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_10_03.html#sect_10_03_03 + + # is_public + old_is_public="$(ynh_app_setting_get $app is_public)" + if [ $old_is_public -eq 1 ] + then + old_is_public=true + else + old_is_public=false + fi + is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}" + + # is_internal_users + old_is_internal_users="$(ynh_app_setting_get $app is_internal_users)" + if [ $old_is_internal_users -eq 1 ] + then + old_is_internal_users=true + else + old_is_internal_users=false + fi + is_internal_users="${YNH_CONFIG_MAIN_IS_INTERNAL_USERS_IS_INTERNAL_USERS:-$old_is_internal_users}" + + +# # Export +# old_export="$(ynh_app_setting_get $app export)" +# export="${YNH_CONFIG_MAIN_EXPORT_EXPORT:-$old_export}" +# +# # padOptions noColors +# old_pad_config_nocolors="$(get_config_value noColors)" +# pad_config_nocolors="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_NOCOLORS:-$old_pad_config_nocolors}" +# # padOptions showLineNumbers +# old_pad_config_showlinenumbers="$(get_config_value showLineNumbers)" +# pad_config_showlinenumbers="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOWLINENUMBERS:-$old_pad_config_showlinenumbers}" +# # padOptions chatAndUsers +# old_pad_config_chatandusers="$(get_config_value chatAndUsers)" +# pad_config_chatandusers="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_CHATANDUSERS:-$old_pad_config_chatandusers}" +# # padOptions alwaysShowChat +# old_pad_config_alwaysshowchat="$(get_config_value alwaysShowChat)" +# pad_config_alwaysshowchat="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_ALWAYSSHOWCHAT:-$old_pad_config_alwaysshowchat}" +# # Plugin option ep_markdown_default +# old_pad_config_show_markdown="$(get_config_value ep_markdown_default)" +# pad_config_show_markdown="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOW_MARKDOWN:-$old_pad_config_show_markdown}" +# # Plugin option ep_page_view_default +# old_pad_config_pageview="$(get_config_value ep_page_view_default)" +# pad_config_pageview="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_PAGEVIEW:-$old_pad_config_pageview}" +# +# # Mypads +# if [ -d $final_path/node_modules/ep_mypads ] +# then +# old_mypads=true +# else +# old_mypads=false +# fi +# mypads="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS:-$old_mypads}" +# # Ldap for Mypads +# if grep -q "//noldap" $config_file +# then +# old_useldap=false +# else +# old_useldap=true +# fi +# useldap="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP:-$old_useldap}" + +#================================================= +# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND +#================================================= + +show_config() { + # here you are supposed to read some config file/database/other then print the values + # echo "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value" + + ynh_return "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public" + ynh_return "YNH_CONFIG_MAIN_IS_INTERNAL_USERS_IS_INTERNAL_USERS=$is_internal_users" + + +# echo "YNH_CONFIG_MAIN_EXPORT_EXPORT=$export" +# +# echo "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_NOCOLORS=$pad_config_nocolors" +# echo "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOWLINENUMBERS=$pad_config_showlinenumbers" +# echo "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_CHATANDUSERS=$pad_config_chatandusers" +# echo "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_ALWAYSSHOWCHAT=$pad_config_alwaysshowchat" +# echo "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOW_MARKDOWN=$pad_config_show_markdown" +# echo "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_PAGEVIEW=$pad_config_pageview" +# +# echo "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS=$mypads" +# echo "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP=$useldap" +} + +#================================================= +# MODIFY THE CONFIGURATION +#================================================= + +apply_config() { + + # Change public accessibility + if [ "$is_public" = "true" ]; then + is_public=1 + else + is_public=0 + fi + + if [ $is_public -eq 1 ]; then + ynh_app_setting_set $app skipped_uris "/" + else + ynh_app_setting_set $app skipped_uris "/admin" # etherpad admin page doesn't support SSO... + fi + ynh_app_setting_set $app is_public $is_public + yunohost app ssowatconf + + + + # Change internal users functionnality + if [ "$is_internal_users" = "true" ]; then + is_internal_users=1 + else + is_internal_users=0 + fi + + if [ $is_internal_users -eq 1 ]; then + ynh_app_setting_set $app skipped_uris "/" + else + ynh_app_setting_set $app skipped_uris "/admin" # etherpad admin page doesn't support SSO... + fi + ynh_app_setting_set $app is_internal_users $is_internal_users + yunohost app ssowatconf + + +# restart_etherpad=0 +# +# # Change configuration if needed +# # padOptions noColors +# if [ "$pad_config_nocolors" != "$old_pad_config_nocolors" ] +# then +# ynh_replace_string "\(\"noColors\" *: \).*," "\1$pad_config_nocolors," "$config_file" +# restart_etherpad=1 +# fi +# +# # padOptions showLineNumbers +# if [ "$pad_config_showlinenumbers" != "$old_pad_config_showlinenumbers" ] +# then +# ynh_replace_string "\(\"showLineNumbers\" *: \).*," "\1$pad_config_showlinenumbers," "$config_file" +# restart_etherpad=1 +# fi +# +# # padOptions chatAndUsers +# if [ "$pad_config_chatandusers" != "$old_pad_config_chatandusers" ] +# then +# ynh_replace_string "\(\"chatAndUsers\" *: \).*," "\1$pad_config_chatandusers," "$config_file" +# restart_etherpad=1 +# fi +# +# # padOptions alwaysShowChat +# if [ "$pad_config_alwaysshowchat" != "$old_pad_config_alwaysshowchat" ] +# then +# ynh_replace_string "\(\"alwaysShowChat\" *: \).*," "\1$pad_config_alwaysshowchat," "$config_file" +# restart_etherpad=1 +# fi +# +# # Plugin option ep_markdown_default +# if [ "$pad_config_show_markdown" != "$old_pad_config_show_markdown" ] +# then +# ynh_replace_string "\(\"ep_markdown_default\" *: \).*," "\1$pad_config_show_markdown," "$config_file" +# restart_etherpad=1 +# fi +# +# # Plugin option ep_page_view_default +# if [ "$pad_config_pageview" != "$old_pad_config_pageview" ] +# then +# ynh_replace_string "\(\"ep_page_view_default\" *: \).*," "\1$pad_config_pageview," "$config_file" +# restart_etherpad=1 +# fi +# +# # Export +# if [ "$export" != "$old_export" ] +# then +# if [ "$export" = "abiword" ] +# then +# # if abiword isn't installed, call the action add_remove_abiword. +# if ! which abiword > /dev/null +# then +# yunohost app action run $app add_remove_abiword +# fi +# ynh_replace_string "\(\"abiword\" *: \).*," "\1\"$(which abiword)\"," "$config_file" +# ynh_replace_string "\(\"soffice\" *: \).*," "\1null," "$config_file" +# elif [ "$export" = "libreoffice" ] +# then +# # if libreoffice isn't installed, call the action add_remove_libreoffice. +# if ! which soffice > /dev/null +# then +# yunohost app action run $app add_remove_libreoffice +# fi +# ynh_replace_string "\(\"abiword\" *: \).*," "\1null," "$config_file" +# ynh_replace_string "\(\"soffice\" *: \).*," "\1\"$(which soffice)\"," "$config_file" +# else +# ynh_replace_string "\(\"abiword\" *: \).*," "\1null," "$config_file" +# ynh_replace_string "\(\"soffice\" *: \).*," "\1null," "$config_file" +# fi +# restart_etherpad=1 +# fi +# +# # Mypads +# if [ "$mypads" != "$old_mypads" ] +# then +# ynh_use_nodejs +# pushd "$final_path" +# if [ "$mypads" = "true" ] +# then +# npm install ep_mypads@${mypads_version} +# else +# npm uninstall ep_mypads +# fi +# popd +# chown -R $app: $final_path/node_modules +# restart_etherpad=1 +# fi +# +# # Ldap for Mypads +# if [ "$useldap" != "$old_useldap" ] +# then +# if [ "$useldap" = "true" ] +# then +# ynh_replace_string "//noldap\(.*\)" "\1 //useldap" "$final_path/settings.json" +# else +# ynh_replace_string "\(.*\) //useldap" "//noldap\1" "$final_path/settings.json" +# fi +# restart_etherpad=1 +# fi +# +# +# if [ $restart_etherpad -eq 1 ] +# then +# # Wait for etherpad to be fully started +# ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120" +# fi +} + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT +#================================================= + +case $1 in + show) show_config;; + apply) apply_config;; +esac