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