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/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/conf/local.protected.php b/conf/local.protected.php
index f6945dd..2ac890d 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'] = '@__APP__.admin'; //The admin can be user or @group or comma separated list user1,@group1,user2
$conf['manager'] = '@__APP__.admin'; //The manager can be user or @group or comma separated list user1,@group1,user2
@@ -22,11 +22,13 @@ $conf['plugin']['authldap']['server'] = 'localhost';
$conf['plugin']['authldap']['port'] = 389;
$conf['plugin']['authldap']['version'] = 3;
$conf['plugin']['authldap']['usertree'] = 'ou=users,dc=yunohost,dc=org';
-$conf['plugin']['authldap']['grouptree'] = 'ou=permission,dc=yunohost,dc=org';
-$conf['plugin']['authldap']['userfilter'] = '(&(objectClass=posixAccount)(uid=%{user})(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org))';
-$conf['plugin']['authldap']['groupfilter'] = '(&(objectClass=posixGroup)(memberUid=%{user}))';
-#$conf['plugin']['authldap']['debug'] = 1;
+$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})))';
+// 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?
diff --git a/config_panel.toml b/config_panel.toml
index 3abba52..47a9aab 100644
--- a/config_panel.toml
+++ b/config_panel.toml
@@ -1,25 +1,31 @@
-version = "1.0"
+
+version = "0.1"
+name = "DokuWiki configuration panel"
[main]
-name = "Dokuwiki configuration"
+name = "DokuWiki configuration"
- [main.php_fpm_config]
- name = "PHP-FPM configuration"
+ [main.public_access]
+ name = "Public access"
- [main.php_fpm_config.fpm_footprint]
- ask = "Memory footprint of the service?"
- choices = ["low", "medium", "high", "specific"]
- default = "low"
- help = "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool.
Use specific to set a value with the following option."
+ [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.php_fpm_config.free_footprint]
- ask = "Memory footprint of the service?"
- type = "number"
- default = "0"
- help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values."
+ [main.internal_users]
+ name = "Internal users"
- [main.php_fpm_config.fpm_usage]
- ask = "Expected usage of the service?"
- choices = ["low", "medium", "high"]
- default = "low"
- help = "low: Personal usage, behind the SSO. No RAM footprint when not used, but the impact on the processor can be high if many users are using the service.
medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.
high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding."
+ [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/_common.sh b/scripts/_common.sh
index 1e47ce7..e9a1f09 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -1,19 +1,38 @@
#!/bin/bash
-#=================================================
-# COMMON VARIABLES
-#=================================================
-# PHP APP SPECIFIC
-#=================================================
+# 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 "$@"
-#=================================================
-# PERSONAL HELPERS
-#=================================================
+ min_size="${min_size:-300}"
+ # Transform the minimum size from megabytes to kilobytes
+ min_size=$(( $min_size * 1024 ))
-#=================================================
-# EXPERIMENTAL HELPERS
-#=================================================
+ # 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
+ }
-#=================================================
-# FUTURE OFFICIAL HELPERS
-#=================================================
+ 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")"
+}
diff --git a/scripts/actions/internal_users b/scripts/actions/internal_users
new file mode 100644
index 0000000..c69c626
--- /dev/null
+++ b/scripts/actions/internal_users
@@ -0,0 +1,146 @@
+#!/bin/bash
+
+#=================================================
+# GENERIC STARTING
+#=================================================
+# IMPORT GENERIC HELPERS
+#=================================================
+
+source scripts/_common.sh
+source /usr/share/yunohost/helpers
+
+#=================================================
+# RETRIEVE ARGUMENTS
+#=================================================
+
+# 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
+#=================================================
+
+# 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
+#=================================================
+
+if [ $is_internal_users -eq $is_internal_users_old ]
+then
+ ynh_die "is_internal_users is already set as $is_internal_users." 0
+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"
+
+ # 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"
+ # 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 "__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"
+
+# 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
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
diff --git a/scripts/config b/scripts/config
index 8a9110c..8e6078b 100644
--- a/scripts/config
+++ b/scripts/config
@@ -9,87 +9,287 @@
source _common.sh
source /usr/share/yunohost/helpers
-ynh_abort_if_errors
+# Load common variables for all scripts.
+#source _variables TODO: remove ?
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
-phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
-current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
+app=$YNH_APP_INSTANCE_NAME
+
+final_path=$(ynh_app_setting_get $app final_path)
#=================================================
-# SPECIFIC GETTERS FOR TOML SHORT KEY
+# SPECIFIC CODE
+#=================================================
+# DECLARE GENERIC FUNCTION
#=================================================
-get__fpm_footprint() {
- # Free footprint value for php-fpm
- # Check if current_fpm_footprint is an integer
- if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null
- then
- echo "specific"
- else
- echo "$current_fpm_footprint"
- fi
-}
+#config_file="$final_path/settings.json"
-get__free_footprint() {
- # Free footprint value for php-fpm
- # Check if current_fpm_footprint is an integer
- if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null
- then
- # If current_fpm_footprint is an integer, that's a numeric value for the footprint
- echo "$current_fpm_footprint"
- else
- echo "0"
- fi
+#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"
}
#=================================================
-# SPECIFIC SETTERS FOR TOML SHORT KEYS
+# MODIFY THE CONFIGURATION
#=================================================
-set__fpm_footprint() {
- if [ "$fpm_footprint" != "specific" ]
- then
- ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_footprint"
- fi
-}
+apply_config() {
-set__free_footprint() {
- if [ "$fpm_footprint" == "specific" ]
- then
- ynh_app_setting_set --app=$app --key=fpm_footprint --value="$free_footprint"
- fi
+ # 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
+#=================================================
-ynh_app_config_validate() {
- _ynh_app_config_validate
-
- if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[free_footprint]}" == "true" ]; then
- # If fpm_footprint is set to 'specific', use $free_footprint value.
- if [ "$fpm_footprint" == "specific" ]
- then
- fpm_footprint=$free_footprint
- fi
-
- if [ "$fpm_footprint" == "0" ]
- then
- ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below."
-
- exit 0
- fi
- fi
-}
-
-ynh_app_config_apply() {
- _ynh_app_config_apply
-
- ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
-}
-
-ynh_app_config_run $1
+case $1 in
+ show) show_config;;
+ apply) apply_config;;
+esac
diff --git a/scripts/install b/scripts/install
index 5440773..c01ea7d 100755
--- a/scripts/install
+++ b/scripts/install
@@ -25,6 +25,32 @@ ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
+#=================================================
+# 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
+
+# Force disable the 'is_internal_users' feature
+ynh_app_setting_set $app is_internal_users 0
+
+#=================================================
+# 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
+
+# Force disable the 'is_internal_users' feature
+ynh_app_setting_set $app is_internal_users 0
+
+#=================================================
+# STANDARD MODIFICATIONS
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
@@ -69,6 +95,10 @@ ynh_script_progression --message="Adding a configuration file..." --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
+# 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 --match_string="__YNH_ADMIN_USER__" --replace_string="$admin" --target_file="$final_path/conf/local.protected.php"
# Customize admin group in case of multiple wiki install managed by different admins
# dokuwiki.admin; dokuwiki__1.admin; etc
@@ -76,6 +106,7 @@ ynh_add_config --template="../conf/local.protected.php" --destination="$install_
# 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
# Set the "language"
ynh_add_config --template="../conf/local.php" --destination="$install_dir/conf/local.php"
@@ -83,7 +114,7 @@ ynh_add_config --template="../conf/local.php" --destination="$install_dir/conf/l
# Restrict user rights by enforcing "read-only" mode for all users
# See https://www.dokuwiki.org/acl#background_info
# Default is "8"
-ynh_add_config --template="../conf/acl.auth.php" --destination="$install_dir/conf/acl.auth.php"
+cp ../conf/acl.auth.php $final_path/conf
#=================================================
# CREATE DEFAULT FILES
diff --git a/scripts/upgrade b/scripts/upgrade
index ca22984..ebae8fa 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -15,6 +15,12 @@ source /usr/share/yunohost/helpers
upgrade_type=$(ynh_check_app_version_changed)
+auth_backend=$(ynh_app_setting_get $app auth_backend)
+is_internal_users=$(ynh_app_setting_get $app is_internal_users)
+
+auth_backend=$(ynh_app_setting_get $app auth_backend)
+is_internal_users=$(ynh_app_setting_get $app is_internal_users)
+
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
@@ -40,6 +46,28 @@ if [ -z "${fpm_usage:-}" ]; then
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
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
+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
+fi
+
# Yunohost specific configuration, if it isn't exist already
# Previously, these settings were store in an unique "dokuwiki.php"
@@ -230,9 +258,20 @@ fi
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=2
-# Customize admin group in case of multiple wiki install managed by different admins
-# dokuwiki.admin; dokuwiki__1.admin; etc
-ynh_add_config --template="../conf/local.protected.php" --destination="$install_dir/conf/local.protected.php"
+### 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 --file="$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 --match_string="__YNH_ADMIN_USER__" --replace_string="$admin" --target_file="$final_path/conf/local.protected.php"
+
+# Recalculate and store the checksum of the file for the next upgrade.
+ynh_store_file_checksum --file="$final_path/conf/local.protected.php"
#=================================================
# GENERIC FINALIZATION