From 21a002970bf25e9bc5cb462eb294ff3762fd51cf Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 7 Aug 2018 13:13:25 +0200 Subject: [PATCH 01/42] Add actions and config-panel --- actions.json | 33 ++++ config_panel.json | 87 +++++++++ scripts/actions/add_remove_abiword | 94 +++++++++ scripts/actions/add_remove_libreoffice | 94 +++++++++ scripts/actions/list_all_pads | 35 ++++ scripts/config | 257 +++++++++++++++++++++++++ scripts/install | 2 +- scripts/upgrade | 2 +- 8 files changed, 602 insertions(+), 2 deletions(-) create mode 100644 actions.json create mode 100644 config_panel.json create mode 100755 scripts/actions/add_remove_abiword create mode 100755 scripts/actions/add_remove_libreoffice create mode 100755 scripts/actions/list_all_pads create mode 100644 scripts/config diff --git a/actions.json b/actions.json new file mode 100644 index 0000000..518828c --- /dev/null +++ b/actions.json @@ -0,0 +1,33 @@ +[{ + "id": "add_remove_abiword", + "name": "Install/remove abiword", + "command": "/bin/bash scripts/actions/add_remove_abiword", + "user": "root", + "accepted_return_codes": [0], + "description": { + "en": "Install or remove abiword.", + "fr": "Installe ou supprime abiword." + } +}, +{ + "id": "add_remove_libreoffice", + "name": "Install/remove libreoffice", + "command": "/bin/bash scripts/actions/add_remove_libreoffice", + "user": "root", + "accepted_return_codes": [0], + "description": { + "en": "Install or remove libreoffice.", + "fr": "Installe ou supprime libreoffice." + } +}, +{ + "id": "list_all_pads", + "name": "List all existing pads", + "command": "/bin/bash scripts/actions/list_all_pads", + "user": "root", + "accepted_return_codes": [0], + "description": { + "en": "List all existing pads.", + "fr": "Liste tout les pads existants." + } +}] diff --git a/config_panel.json b/config_panel.json new file mode 100644 index 0000000..1d34402 --- /dev/null +++ b/config_panel.json @@ -0,0 +1,87 @@ +{ + "name": "Etherpad configuration panel", + "version": "0.1", + "panel": [{ + "name": "Etherpad configuration", + "id": "main", + "sections": [{ + "name": "Export", + "id": "export", + "options": [{ + "name": "Use abiword (~260Mo) or libreoffice (~400Mo) (more stable) to expand export possibilities (pdf, doc) ?", + "help": "We can't use a choices field for now. In the meantime please choose between one of this values:
none, abiword, libreoffice.", + "id": "export", + "type": "text", + "//": "\"choices\" : [\"none\", \"abiword\", \"libreoffice\"]", + "default" : "none" + }] + }, + { + "name": "Default pad configuration", + "id": "pad_configuration", + "options": [{ + "name": "Hide authorship colors ?", + "id": "pad_config_nocolors", + "type": "bool", + "default": false + }, + { + "name": "Show line numbers ?", + "id": "pad_config_showlinenumbers", + "type": "bool", + "default": true + }, + { + "name": "Show chat and users ?", + "id": "pad_config_chatandusers", + "type": "bool", + "default": false + }, + { + "name": "Always show chat ?", + "id": "pad_config_alwaysshowchat", + "type": "bool", + "default": false + }, + { + "name": "Show markdown syntax ?", + "id": "pad_config_show_markdown", + "type": "bool", + "default": false + }, + { + "name": "Page view ?", + "id": "pad_config_pageview", + "type": "bool", + "default": false + }] + }, + { + "name": "Mypads configuration", + "id": "mypads_configuration", + "options": [{ + "name": "Enable Mypads plugin ?", + "id": "mypads", + "type": "bool", + "default": true + }, + { + "name": "Use ldap with Mypads ?", + "id": "useldap", + "type": "bool", + "default": true + }] + }, + { + "name": "Public access", + "id": "is_public", + "options": [{ + "name": "Is it a public website ?", + "id": "is_public", + "type": "bool", + "default": true + }] + }] + } +] +} diff --git a/scripts/actions/add_remove_abiword b/scripts/actions/add_remove_abiword new file mode 100755 index 0000000..1e4b3cf --- /dev/null +++ b/scripts/actions/add_remove_abiword @@ -0,0 +1,94 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +app=$YNH_APP_ID + +#================================================= +# CHECK IF ARGUMENTS ARE CORRECT +#================================================= + +#================================================= +# CHECK IF AN ACTION HAS TO BE DONE +#================================================= + +# Check the dependencies of the meta packages of etherpad_mypads with apt-cache +if apt-cache depends ${app//_/-}-ynh-deps | grep --quiet abiword +then + # abiword is already a dependence of etherpad_mypads. + # abiword should be removed. + abiword=0 + ynh_print_info "Abiword will be removed." >&2 +else + # abiword isn't a dependence of etherpad_mypads. + # abiword should be installed. + ynh_print_info "Abiword will be installed." >&2 + abiword=1 +fi + +if apt-cache depends ${app//_/-}-ynh-deps | grep --quiet libreoffice-writer +then + # libreoffice is already a dependence of etherpad_mypads. + # Keep it + libreoffice=1 +else + # libreoffice isn't a dependence of etherpad_mypads. + # Do not add it + libreoffice=0 +fi + +#================================================= +# SPECIFIC ACTION +#================================================= +# INSTALL OR REMOVE ABIWORD +#================================================= + +# Load common variables, and especially abiword dependencies. +source scripts/_variables + +dependencies="" +if [ $abiword -eq 1 ] +then + # Add abiword dependencies if abiword has to be installed + dependencies="$dependencies $abiword_app_depencencies" +fi +if [ $libreoffice -eq 1 ] +then + # Add libreoffice dependencies if libreoffice is already installed to keep it as a dependence. + dependencies="$dependencies $libreoffice_app_dependencies" +fi + +# Rebuild the meta package and install the new dependencies +( cd scripts # Move to scripts directory to allow the helper to find the manifest where it expects to find it. +ynh_install_app_dependencies $dependencies) + +# Remove all unused dependencies +ynh_package_autopurge + +#================================================= +# SET THE DEFAULT EXPORT APP +#================================================= + +if [ $abiword -eq 1 ] +then + # Set abiword as default export app + yunohost app config apply $app -a "YNH_CONFIG_MAIN_EXPORT_EXPORT=abiword" +elif [ $libreoffice -eq 1 ] +then + # Set libreoffice as default export app + yunohost app config apply $app -a "YNH_CONFIG_MAIN_EXPORT_EXPORT=libreoffice" +else + # Remove any export app + yunohost app config apply $app -a "YNH_CONFIG_MAIN_EXPORT_EXPORT=none" +fi diff --git a/scripts/actions/add_remove_libreoffice b/scripts/actions/add_remove_libreoffice new file mode 100755 index 0000000..6f32eb5 --- /dev/null +++ b/scripts/actions/add_remove_libreoffice @@ -0,0 +1,94 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +app=$YNH_APP_ID + +#================================================= +# CHECK IF ARGUMENTS ARE CORRECT +#================================================= + +#================================================= +# CHECK IF AN ACTION HAS TO BE DONE +#================================================= + +# Check the dependencies of the meta packages of etherpad_mypads with apt-cache +if apt-cache depends ${app//_/-}-ynh-deps | grep --quiet libreoffice-writer +then + # libreoffice is already a dependence of etherpad_mypads. + # libreoffice should be removed. + libreoffice=0 + ynh_print_info "Libreoffice writer will be removed." >&2 +else + # libreoffice isn't a dependence of etherpad_mypads. + # libreoffice should be installed. + ynh_print_info "Libreoffice writer will be installed." >&2 + libreoffice=1 +fi + +if apt-cache depends ${app//_/-}-ynh-deps | grep --quiet abiword +then + # abiword is already a dependence of etherpad_mypads. + # Keep it + abiword=1 +else + # abiword isn't a dependence of etherpad_mypads. + # Do not add it + abiword=0 +fi + +#================================================= +# SPECIFIC ACTION +#================================================= +# INSTALL OR REMOVE LIBREOFFICE +#================================================= + +# Load common variables, and especially libreoffice dependencies. +source scripts/_variables + +dependencies="" +if [ $libreoffice -eq 1 ] +then + # Add libreoffice dependencies if libreoffice has to be installed + dependencies="$dependencies $libreoffice_app_dependencies" +fi +if [ $abiword -eq 1 ] +then + # Add abiword dependencies if abiword is already installed to keep it as a dependence. + dependencies="$dependencies $abiword_app_depencencies" +fi + +# Rebuild the meta package and install the new dependencies +( cd scripts # Move to scripts directory to allow the helper to find the manifest where it expects to find it. +ynh_install_app_dependencies $dependencies) + +# Remove all unused dependencies +ynh_package_autopurge + +#================================================= +# SET THE DEFAULT EXPORT APP +#================================================= + +if [ $libreoffice -eq 1 ] +then + # Set libreoffice as default export app + yunohost app config apply $app -a "YNH_CONFIG_MAIN_EXPORT_EXPORT=libreoffice" +elif [ $abiword -eq 1 ] +then + # Set abiword as default export app + yunohost app config apply $app -a "YNH_CONFIG_MAIN_EXPORT_EXPORT=abiword" +else + # Remove any export app + yunohost app config apply $app -a "YNH_CONFIG_MAIN_EXPORT_EXPORT=none" +fi diff --git a/scripts/actions/list_all_pads b/scripts/actions/list_all_pads new file mode 100755 index 0000000..2d8160e --- /dev/null +++ b/scripts/actions/list_all_pads @@ -0,0 +1,35 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +app=$YNH_APP_ID + +db_name=$(ynh_app_setting_get $app db_name) +db_pwd=$(ynh_app_setting_get $app mysqlpwd) + +#================================================= +# CHECK IF ARGUMENTS ARE CORRECT +#================================================= + +#================================================= +# CHECK IF AN ACTION HAS TO BE DONE +#================================================= + +#================================================= +# SPECIFIC ACTION +#================================================= +# LIST ALL PADS FROM THE DATABASE +#================================================= + +mysql -u $db_name -p$db_pwd $db_name --silent -e 'select distinct substring(store.key,5,locate(":",store.key,5)-5) as "pads" from store where store.key like "pad:%"' | sed 's/^/>> /g' >&2 diff --git a/scripts/config b/scripts/config new file mode 100644 index 0000000..46d205a --- /dev/null +++ b/scripts/config @@ -0,0 +1,257 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers +# Load common variables for all scripts. +source _variables + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +app=$YNH_APP_ID + +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. + + # 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}" + + # 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}" + +#================================================= +# 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" + + 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" + + echo "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public" +} + +#================================================= +# MODIFY THE CONFIGURATION +#================================================= + +apply_config() { + 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 + + # 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 +} + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT +#================================================= + +case $1 in + show) show_config;; + apply) apply_config;; +esac diff --git a/scripts/install b/scripts/install index 929c3af..693dc65 100644 --- a/scripts/install +++ b/scripts/install @@ -186,7 +186,7 @@ ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json" # Use ldap for mypads if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] then - ynh_replace_string "//noldap" "" "$final_path/settings.json" + ynh_replace_string "//noldap\(.*\)" "\1 //useldap" "$final_path/settings.json" fi ynh_store_file_checksum "$final_path/settings.json" # Store config file checksum diff --git a/scripts/upgrade b/scripts/upgrade index 7941647..0df9520 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -201,7 +201,7 @@ ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json" # Use ldap for mypads if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] then - ynh_replace_string "//noldap" "" "$final_path/settings.json" + ynh_replace_string "//noldap\(.*\)" "\1 //useldap" "$final_path/settings.json" fi ynh_store_file_checksum "$final_path/settings.json" # Recalculate and store the config file checksum into the app settings From 37bb93d4cc7803663019c7be7631d3c1a56ef655 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 21 Aug 2018 19:57:15 +0200 Subject: [PATCH 02/42] Use YNH_APP_INSTANCE_NAME instead of YNH_APP_ID --- scripts/actions/add_remove_abiword | 2 +- scripts/actions/add_remove_libreoffice | 2 +- scripts/actions/list_all_pads | 2 +- scripts/config | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/actions/add_remove_abiword b/scripts/actions/add_remove_abiword index 1e4b3cf..8912185 100755 --- a/scripts/actions/add_remove_abiword +++ b/scripts/actions/add_remove_abiword @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -app=$YNH_APP_ID +app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF ARGUMENTS ARE CORRECT diff --git a/scripts/actions/add_remove_libreoffice b/scripts/actions/add_remove_libreoffice index 6f32eb5..86f493d 100755 --- a/scripts/actions/add_remove_libreoffice +++ b/scripts/actions/add_remove_libreoffice @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -app=$YNH_APP_ID +app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF ARGUMENTS ARE CORRECT diff --git a/scripts/actions/list_all_pads b/scripts/actions/list_all_pads index 2d8160e..ffdda94 100755 --- a/scripts/actions/list_all_pads +++ b/scripts/actions/list_all_pads @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -app=$YNH_APP_ID +app=$YNH_APP_INSTANCE_NAME db_name=$(ynh_app_setting_get $app db_name) db_pwd=$(ynh_app_setting_get $app mysqlpwd) diff --git a/scripts/config b/scripts/config index 46d205a..b20f344 100644 --- a/scripts/config +++ b/scripts/config @@ -15,7 +15,7 @@ source _variables # RETRIEVE ARGUMENTS #================================================= -app=$YNH_APP_ID +app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get $app final_path) From 452bae715460b68ca3ad36ef73e11e7dc0926cdb Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 29 Sep 2018 21:02:18 +0200 Subject: [PATCH 03/42] Panel-config + actions fully tested --- actions.json | 31 +++++ config_panel.json | 34 +++++- scripts/_common.sh | 18 +++ scripts/actions/add_remove_abiword | 2 +- scripts/actions/add_remove_libreoffice | 2 +- scripts/actions/list_all_pads | 2 +- scripts/actions/public_private | 58 +++++++++ scripts/actions/reset_default_config | 72 ++++++++++++ scripts/config | 152 ++++++++++++++---------- scripts/install | 4 + scripts/upgrade | 157 ++++++++++++++++++------- 11 files changed, 424 insertions(+), 108 deletions(-) create mode 100755 scripts/actions/public_private create mode 100755 scripts/actions/reset_default_config diff --git a/actions.json b/actions.json index 518828c..393a635 100644 --- a/actions.json +++ b/actions.json @@ -30,4 +30,35 @@ "en": "List all existing pads.", "fr": "Liste tout les pads existants." } +}, +{ + "id": "reset_default_config", + "name": "Reset the config file and restore a default one.", + "command": "/bin/bash scripts/actions/reset_default_config \"settings.json\"", + "user": "root", + "accepted_return_codes": [0], + "description": { + "en": "Reset the config file settings.json.", + "fr": "Réinitialise le fichier de configuration settings.json." + } +}, +{ + "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 ?" + }, + "default": true + } + ] }] diff --git a/config_panel.json b/config_panel.json index 1d34402..4beaf4f 100644 --- a/config_panel.json +++ b/config_panel.json @@ -76,11 +76,43 @@ "name": "Public access", "id": "is_public", "options": [{ - "name": "Is it a public website ?", + "name": "Is it a public app ?", "id": "is_public", "type": "bool", "default": true }] + }, + { + "name": "Overwriting config files", + "id": "overwrite_files", + "options": [{ + "name": "Overwrite the config file settings.json ?", + "help": "If the file is overwritten, a backup will be created.", + "id": "overwrite_settings", + "type": "bool", + "default": true + }, + { + "name": "Overwrite the config file credentials.json ?", + "help": "If the file is overwritten, a backup will be created.", + "id": "overwrite_credentials", + "type": "bool", + "default": true + }, + { + "name": "Overwrite the nginx config file ?", + "help": "If the file is overwritten, a backup will be created.", + "id": "overwrite_nginx", + "type": "bool", + "default": true + }, + { + "name": "Overwrite the systemd config file ?", + "help": "If the file is overwritten, a backup will be created.", + "id": "overwrite_systemd", + "type": "bool", + "default": true + }] }] } ] diff --git a/scripts/_common.sh b/scripts/_common.sh index 44a54cc..49ff2a2 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -22,6 +22,24 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant fi } +#================================================= +# BOOLEAN CONVERTER +#================================================= + +bool_to_01 () { + local var="$1" + [ "$var" = "true" ] && var=1 + [ "$var" = "false" ] && var=0 + echo "$var" +} + +bool_to_true_false () { + local var="$1" + [ "$var" = "1" ] && var=true + [ "$var" = "0" ] && var=false + echo "$var" +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/actions/add_remove_abiword b/scripts/actions/add_remove_abiword index 8912185..2224ee7 100755 --- a/scripts/actions/add_remove_abiword +++ b/scripts/actions/add_remove_abiword @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -app=$YNH_APP_INSTANCE_NAME +app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} #================================================= # CHECK IF ARGUMENTS ARE CORRECT diff --git a/scripts/actions/add_remove_libreoffice b/scripts/actions/add_remove_libreoffice index 86f493d..26677df 100755 --- a/scripts/actions/add_remove_libreoffice +++ b/scripts/actions/add_remove_libreoffice @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -app=$YNH_APP_INSTANCE_NAME +app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} #================================================= # CHECK IF ARGUMENTS ARE CORRECT diff --git a/scripts/actions/list_all_pads b/scripts/actions/list_all_pads index ffdda94..6bb8c21 100755 --- a/scripts/actions/list_all_pads +++ b/scripts/actions/list_all_pads @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -app=$YNH_APP_INSTANCE_NAME +app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} db_name=$(ynh_app_setting_get $app db_name) db_pwd=$(ynh_app_setting_get $app mysqlpwd) diff --git a/scripts/actions/public_private b/scripts/actions/public_private new file mode 100755 index 0000000..0b004cc --- /dev/null +++ b/scripts/actions/public_private @@ -0,0 +1,58 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +# Get is_public +is_public=${YNH_ACTION_IS_PUBLIC} + +app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} + +#================================================= +# 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_set $app skipped_uris "/admin" # etherpad admin page doesn't support SSO... +else + ynh_app_setting_set $app skipped_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/actions/reset_default_config b/scripts/actions/reset_default_config new file mode 100755 index 0000000..e0f76ef --- /dev/null +++ b/scripts/actions/reset_default_config @@ -0,0 +1,72 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +final_path=$(ynh_app_setting_get $app final_path) +port=$(ynh_app_setting_get $app port) +export=$(ynh_app_setting_get $app export) +language=$(ynh_app_setting_get $app language) +mypads=$(ynh_app_setting_get $app mypads) +useldap=$(ynh_app_setting_get $app useldap) + +#================================================= +# SORT OUT THE CONFIG FILE TO HANDLE +#================================================= + +file="$1" + +if [ "$file" = "settings.json" ]; then + config_file="$final_path/settings.json" +fi + +#================================================= +# SPECIFIC ACTION +#================================================= +# RESET THE CONFIG FILE +#================================================= + +# Verify the checksum and backup the file if it's different +ynh_backup_if_checksum_is_different "$config_file" + +if [ "$file" = "settings.json" ] +then + # Get the default file and overwrite the current config + cp /etc/yunohost/apps/$app/conf/settings.json "$config_file" + + # Recreate the default config + ynh_replace_string "__PORT__" "$port" "$final_path/settings.json" + if [ "$export" = "abiword" ] + then + abiword_path=`which abiword` # Get abiword binary path + ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + elif [ "$export" = "libreoffice" ] + then + soffice_path=`which soffice` # Get soffice binary path + ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + fi + ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json" + + # Use ldap for mypads + if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] + then + ynh_replace_string "//noldap\(.*\)" "\1 //useldap" "$final_path/settings.json" + fi +fi + +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum "$config_file" + +# Wait for etherpad to be fully started +ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120" diff --git a/scripts/config b/scripts/config index b20f344..709cb22 100644 --- a/scripts/config +++ b/scripts/config @@ -15,7 +15,7 @@ source _variables # RETRIEVE ARGUMENTS #================================================= -app=$YNH_APP_INSTANCE_NAME +app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} final_path=$(ynh_app_setting_get $app final_path) @@ -38,60 +38,75 @@ get_config_value() { # 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. +# 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. - # Export - old_export="$(ynh_app_setting_get $app export)" - export="${YNH_CONFIG_MAIN_EXPORT_EXPORT:-$old_export}" +# 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}" +# 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}" +# 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}" - # 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_public +old_is_public="$(ynh_app_setting_get $app is_public)" +old_is_public=$(bool_to_true_false $old_is_public) +is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}" + +# Overwrite settings.json file +old_overwrite_settings="$(ynh_app_setting_get $app overwrite_settings)" +old_overwrite_settings=$(bool_to_true_false $old_overwrite_settings) +overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}" + +# Overwrite credentials.json file +old_overwrite_credentials="$(ynh_app_setting_get $app overwrite_credentials)" +old_overwrite_credentials=$(bool_to_true_false $old_overwrite_credentials) +overwrite_credentials="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CREDENTIALS:-$old_overwrite_credentials}" + +# Overwrite nginx configuration +old_overwrite_nginx="$(ynh_app_setting_get $app overwrite_nginx)" +old_overwrite_nginx=$(bool_to_true_false $old_overwrite_nginx) +overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}" + +# Overwrite systemd configuration +old_overwrite_systemd="$(ynh_app_setting_get $app overwrite_systemd)" +old_overwrite_systemd=$(bool_to_true_false $old_overwrite_systemd) +overwrite_systemd="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD:-$old_overwrite_systemd}" #================================================= # SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND @@ -114,6 +129,11 @@ show_config() { echo "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP=$useldap" echo "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public" + + echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings" + echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CREDENTIALS=$overwrite_credentials" + echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx" + echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd" } #================================================= @@ -128,6 +148,7 @@ apply_config() { if [ "$pad_config_nocolors" != "$old_pad_config_nocolors" ] then ynh_replace_string "\(\"noColors\" *: \).*," "\1$pad_config_nocolors," "$config_file" + ynh_app_setting_set $app pad_config_nocolors "$pad_config_nocolors" restart_etherpad=1 fi @@ -135,6 +156,7 @@ apply_config() { if [ "$pad_config_showlinenumbers" != "$old_pad_config_showlinenumbers" ] then ynh_replace_string "\(\"showLineNumbers\" *: \).*," "\1$pad_config_showlinenumbers," "$config_file" + ynh_app_setting_set $app pad_config_showlinenumbers "$pad_config_showlinenumbers" restart_etherpad=1 fi @@ -142,6 +164,7 @@ apply_config() { if [ "$pad_config_chatandusers" != "$old_pad_config_chatandusers" ] then ynh_replace_string "\(\"chatAndUsers\" *: \).*," "\1$pad_config_chatandusers," "$config_file" + ynh_app_setting_set $app pad_config_chatandusers "$pad_config_chatandusers" restart_etherpad=1 fi @@ -149,6 +172,7 @@ apply_config() { if [ "$pad_config_alwaysshowchat" != "$old_pad_config_alwaysshowchat" ] then ynh_replace_string "\(\"alwaysShowChat\" *: \).*," "\1$pad_config_alwaysshowchat," "$config_file" + ynh_app_setting_set $app pad_config_alwaysshowchat "$pad_config_alwaysshowchat" restart_etherpad=1 fi @@ -156,6 +180,7 @@ apply_config() { if [ "$pad_config_show_markdown" != "$old_pad_config_show_markdown" ] then ynh_replace_string "\(\"ep_markdown_default\" *: \).*," "\1$pad_config_show_markdown," "$config_file" + ynh_app_setting_set $app pad_config_show_markdown "$pad_config_show_markdown" restart_etherpad=1 fi @@ -163,6 +188,7 @@ apply_config() { if [ "$pad_config_pageview" != "$old_pad_config_pageview" ] then ynh_replace_string "\(\"ep_page_view_default\" *: \).*," "\1$pad_config_pageview," "$config_file" + ynh_app_setting_set $app pad_config_pageview "$pad_config_pageview" restart_etherpad=1 fi @@ -232,17 +258,23 @@ apply_config() { # Change public accessibility if [ "$is_public" = "true" ] then - is_public=1 + yunohost app action run $app public_private --args is_public=1 else - is_public=0 + yunohost app action run $app public_private --args 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 + + # Set overwrite_settings + overwrite_settings=$(bool_to_01 $overwrite_settings) + ynh_app_setting_set $app overwrite_settings "$overwrite_settings" + # Set overwrite_credentials + overwrite_credentials=$(bool_to_01 $overwrite_credentials) + ynh_app_setting_set $app overwrite_credentials "$overwrite_credentials" + # Set overwrite_nginx + overwrite_nginx=$(bool_to_01 $overwrite_nginx) + ynh_app_setting_set $app overwrite_nginx "$overwrite_nginx" + # Set overwrite_systemd + overwrite_systemd=$(bool_to_01 $overwrite_systemd) + ynh_app_setting_set $app overwrite_systemd "$overwrite_systemd" } #================================================= diff --git a/scripts/install b/scripts/install index 693dc65..0c6e497 100644 --- a/scripts/install +++ b/scripts/install @@ -72,6 +72,10 @@ ynh_app_setting_set $app language $language ynh_app_setting_set $app export $export ynh_app_setting_set $app mypads $mypads ynh_app_setting_set $app useldap $useldap +ynh_app_setting_set $app overwrite_settings "1" +ynh_app_setting_set $app overwrite_credentials "1" +ynh_app_setting_set $app overwrite_nginx "1" +ynh_app_setting_set $app overwrite_systemd "1" #================================================= # ACTIVATE MAINTENANCE MODE diff --git a/scripts/upgrade b/scripts/upgrade index 0df9520..c4b8330 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,6 +28,17 @@ export=$(ynh_app_setting_get $app export) db_name=$(ynh_app_setting_get $app db_name) mypads=$(ynh_app_setting_get $app mypads) useldap=$(ynh_app_setting_get $app useldap) +overwrite_settings=$(ynh_app_setting_get $app overwrite_settings) +overwrite_credentials=$(ynh_app_setting_get $app overwrite_credentials) +overwrite_nginx=$(ynh_app_setting_get $app overwrite_nginx) +overwrite_systemd=$(ynh_app_setting_get $app overwrite_systemd) + +# Optional parameters from config-panel feature +pad_config_nocolors=$(ynh_app_setting_get $app pad_config_nocolors) +pad_config_showlinenumbers=$(ynh_app_setting_get $app pad_config_showlinenumbers) +pad_config_chatandusers=$(ynh_app_setting_get $app pad_config_chatandusers) +pad_config_alwaysshowchat=$(ynh_app_setting_get $app pad_config_alwaysshowchat) +pad_config_show_markdown=$(ynh_app_setting_get $app pad_config_show_markdown) #================================================= # CHECK VERSION @@ -39,7 +50,7 @@ ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/eth ynh_abort_if_up_to_date #================================================= -# FIX OLD THINGS +# ENSURE DOWNWARD COMPATIBILITY #================================================= if [ "$is_public" = "Yes" ]; then @@ -50,17 +61,17 @@ elif [ "$is_public" = "No" ]; then is_public=0 fi -if [ -z $db_name ]; then # If db_name setting doesn't exist +if [ -z "$db_name" ]; then # If db_name setting doesn't exist db_name=$(ynh_sanitize_dbid $app) ynh_app_setting_set $app db_name $db_name fi -if [ -z $abiword ]; then # If abiword setting doesn't exist +if [ -z "$abiword" ]; then # If abiword setting doesn't exist abiword=0 ynh_app_setting_set $app abiword $abiword fi -if [ -n $abiword ]; then # If abiword setting exists +if [ -n "$abiword" ]; then # If abiword setting exists if [ $abiword -eq 1 ]; then export=abiword fi @@ -68,26 +79,50 @@ if [ -n $abiword ]; then # If abiword setting exists ynh_app_setting_delete $app abiword fi -if [ -z $export ]; then # If export setting doesn't exist +if [ -z "$export" ]; then # If export setting doesn't exist export=none ynh_app_setting_set $app export $export fi -if [ -z $mypads ]; then # If mypads setting doesn't exist +if [ -z "$mypads" ]; then # If mypads setting doesn't exist mypads=1 ynh_app_setting_set $app mypads $mypads fi -if [ -z $useldap ]; then # If useldap setting doesn't exist +if [ -z "$useldap" ]; then # If useldap setting doesn't exist useldap=0 ynh_app_setting_set $app useldap $useldap fi -if [ -z $path_url ]; then # If path_url setting doesn't exist +if [ -z "$path_url" ]; then # If path_url setting doesn't exist path_url="/" ynh_app_setting_set $app path $path_url fi +# If overwrite_settings doesn't exist, create it +if [ -z "$overwrite_settings" ]; then + overwrite_settings=1 + ynh_app_setting_set $app overwrite_settings $overwrite_settings +fi + +# If overwrite_credentials doesn't exist, create it +if [ -z "$overwrite_credentials" ]; then + overwrite_credentials=1 + ynh_app_setting_set $app overwrite_credentials $overwrite_credentials +fi + +# If overwrite_nginx doesn't exist, create it +if [ -z "$overwrite_nginx" ]; then + overwrite_nginx=1 + ynh_app_setting_set $app overwrite_nginx $overwrite_nginx +fi + +# If overwrite_systemd doesn't exist, create it +if [ -z "$overwrite_systemd" ]; then + overwrite_systemd=1 + ynh_app_setting_set $app overwrite_systemd $overwrite_systemd +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -128,12 +163,16 @@ ynh_setup_source "$final_path" # Download, check integrity and uncompress the so # NGINX CONFIGURATION #================================================= -if [ "$path_url" != "/" ] +# Overwrite the nginx configuration only if it's allowed +if [ $overwrite_nginx -eq 1 ] then - ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf" + if [ "$path_url" != "/" ] + then + ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf" + fi + ynh_replace_string "__PATH__/" "${path_url%/}/" "../conf/nginx.conf" + ynh_add_nginx_config fi -ynh_replace_string "__PATH__/" "${path_url%/}/" "../conf/nginx.conf" -ynh_add_nginx_config #================================================= # UPGRADE NODEJS @@ -172,40 +211,66 @@ done <<< "$(ls -1 "$final_path/node_modules" | grep "^ep_")") # CONFIGURE ETHERPAD #================================================= -ynh_backup_if_checksum_is_different "$final_path/settings.json" # Verify the checksum and backup the file if it's different -ynh_backup_if_checksum_is_different "$final_path/credentials.json" # Verify the checksum and backup the file if it's different -cp ../conf/settings.json "$final_path/settings.json" -cp ../conf/credentials.json "$final_path/credentials.json" -ynh_replace_string "__PORT__" "$port" "$final_path/settings.json" -ynh_replace_string "__DB_USER__" "$app" "$final_path/credentials.json" -db_pwd=$(ynh_app_setting_get $app mysqlpwd) -ynh_print_OFF; password=$(ynh_app_setting_get $app password); ynh_print_ON -ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/credentials.json" -ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json" -ynh_print_OFF; ynh_replace_special_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON -if [ "$export" = "abiword" ] +# Overwrite the settings config file only if it's allowed +if [ $overwrite_settings -eq 1 ] then - abiword_path=`which abiword` # Get abiword binary path - ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad -elif [ "$export" = "libreoffice" ] -then - soffice_path=`which soffice` # Get soffice binary path - ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad -fi -if test -z $language; then - language=en # If upgrading from a version which doesn't support translations, set language to English by default - ynh_app_setting_set $app language $language -fi -ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json" + ynh_backup_if_checksum_is_different "$final_path/settings.json" # Verify the checksum and backup the file if it's different + cp ../conf/settings.json "$final_path/settings.json" + ynh_replace_string "__PORT__" "$port" "$final_path/settings.json" + if [ "$export" = "abiword" ] + then + abiword_path=`which abiword` # Get abiword binary path + ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + elif [ "$export" = "libreoffice" ] + then + soffice_path=`which soffice` # Get soffice binary path + ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + fi + if test -z $language; then + language=en # If upgrading from a version which doesn't support translations, set language to English by default + ynh_app_setting_set $app language $language + fi + ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json" + # Use ldap for mypads + if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] + then + ynh_replace_string "//noldap\(.*\)" "\1 //useldap" "$final_path/settings.json" + fi -# Use ldap for mypads -if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] -then - ynh_replace_string "//noldap\(.*\)" "\1 //useldap" "$final_path/settings.json" + # Optional parameters from config-panel feature + if [ -n "$pad_config_nocolors" ]; then + ynh_replace_string "\(\"noColors\" *: \).*," "\1$pad_config_nocolors," "$final_path/settings.json" + fi + if [ -n "$pad_config_showlinenumbers" ]; then + ynh_replace_string "\(\"showLineNumbers\" *: \).*," "\1$pad_config_showlinenumbers," "$final_path/settings.json" + fi + if [ -n "$pad_config_chatandusers" ]; then + ynh_replace_string "\(\"chatAndUsers\" *: \).*," "\1$pad_config_chatandusers," "$final_path/settings.json" + fi + if [ -n "$pad_config_alwaysshowchat" ]; then + ynh_replace_string "\(\"alwaysShowChat\" *: \).*," "\1$pad_config_alwaysshowchat," "$final_path/settings.json" + fi + if [ -n "$pad_config_show_markdown" ]; then + ynh_replace_string "\(\"ep_markdown_default\" *: \).*," "\1$pad_config_show_markdown," "$final_path/settings.json" + fi + + ynh_store_file_checksum "$final_path/settings.json" # Recalculate and store the config file checksum into the app settings fi -ynh_store_file_checksum "$final_path/settings.json" # Recalculate and store the config file checksum into the app settings -ynh_store_file_checksum "$final_path/credentials.json" # Recalculate and store the config file checksum into the app settings +# Overwrite the credentials config file only if it's allowed +if [ $overwrite_credentials -eq 1 ] +then + ynh_backup_if_checksum_is_different "$final_path/credentials.json" # Verify the checksum and backup the file if it's different + cp ../conf/credentials.json "$final_path/credentials.json" + ynh_replace_string "__DB_USER__" "$app" "$final_path/credentials.json" + db_pwd=$(ynh_app_setting_get $app mysqlpwd) + ynh_print_OFF; password=$(ynh_app_setting_get $app password); ynh_print_ON + ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/credentials.json" + ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json" + ynh_print_OFF; ynh_replace_special_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON + + ynh_store_file_checksum "$final_path/credentials.json" # Recalculate and store the config file checksum into the app settings +fi #================================================= # CREATE DEDICATED USER @@ -238,8 +303,12 @@ ynh_use_logrotate --non-append # SETUP SYSTEMD #================================================= -ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" -ynh_add_systemd_config +# Overwrite the systemd configuration only if it's allowed +if [ $overwrite_systemd -eq 1 ] +then + ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service" + ynh_add_systemd_config +fi #================================================= # SOME HACKS From 345b79afcd6938114cd81e396c451582c16942fe Mon Sep 17 00:00:00 2001 From: Kayou Date: Tue, 23 Jul 2019 11:02:57 +0200 Subject: [PATCH 04/42] time remaining --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index a7a3162..1bbf2e7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -137,7 +137,7 @@ ynh_systemd_action --action=stop if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --time --weight=1 + ynh_script_progression --message="Upgrading source files..." --weight=4 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" From cbab0a01114f5e0a96cf49ef378ef7322156c353 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Fri, 4 Oct 2019 18:09:41 +0200 Subject: [PATCH 05/42] Fix package check --- check_process | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index ab44e27..9255b18 100644 --- a/check_process +++ b/check_process @@ -41,7 +41,7 @@ ;; Test abiword ; Manifest domain="domain.tld" (DOMAIN) - path="/path" (PATH) + path="/" (PATH) admin="john" (USER) password="password" language="en" @@ -73,4 +73,4 @@ Notification=down ;;; Upgrade options ; commit=8bf300413ec3adcb416d168d2e9e98975dd9405b name= Fix nodejs & global update - manifest_arg=domain=DOMAIN&admin=USER&password=password&language=en&is_public=1&abiword=0& + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=password&language=en&is_public=1&abiword=0& From 09190a02390278f5376de1ec94e2fb306d25b61d Mon Sep 17 00:00:00 2001 From: maniack Date: Sat, 7 Dec 2019 23:27:46 +0100 Subject: [PATCH 06/42] Move to .toml --- actions.json | 64 ------------------------- actions.toml | 50 +++++++++++++++++++ config_panel.json | 119 ---------------------------------------------- config_panel.toml | 100 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 150 insertions(+), 183 deletions(-) delete mode 100644 actions.json create mode 100644 actions.toml delete mode 100644 config_panel.json create mode 100644 config_panel.toml diff --git a/actions.json b/actions.json deleted file mode 100644 index 393a635..0000000 --- a/actions.json +++ /dev/null @@ -1,64 +0,0 @@ -[{ - "id": "add_remove_abiword", - "name": "Install/remove abiword", - "command": "/bin/bash scripts/actions/add_remove_abiword", - "user": "root", - "accepted_return_codes": [0], - "description": { - "en": "Install or remove abiword.", - "fr": "Installe ou supprime abiword." - } -}, -{ - "id": "add_remove_libreoffice", - "name": "Install/remove libreoffice", - "command": "/bin/bash scripts/actions/add_remove_libreoffice", - "user": "root", - "accepted_return_codes": [0], - "description": { - "en": "Install or remove libreoffice.", - "fr": "Installe ou supprime libreoffice." - } -}, -{ - "id": "list_all_pads", - "name": "List all existing pads", - "command": "/bin/bash scripts/actions/list_all_pads", - "user": "root", - "accepted_return_codes": [0], - "description": { - "en": "List all existing pads.", - "fr": "Liste tout les pads existants." - } -}, -{ - "id": "reset_default_config", - "name": "Reset the config file and restore a default one.", - "command": "/bin/bash scripts/actions/reset_default_config \"settings.json\"", - "user": "root", - "accepted_return_codes": [0], - "description": { - "en": "Reset the config file settings.json.", - "fr": "Réinitialise le fichier de configuration settings.json." - } -}, -{ - "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 ?" - }, - "default": true - } - ] -}] diff --git a/actions.toml b/actions.toml new file mode 100644 index 0000000..9f32bf8 --- /dev/null +++ b/actions.toml @@ -0,0 +1,50 @@ +[add_remove_abiword] +name = "Install/remove abiword" +command = "/bin/bash scripts/actions/add_remove_abiword" +# user = "root" # optional +# cwd = "/" # optional +# accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "Install or remove abiword" + +[add_remove_libreoffice] +name = "Install/remove libreoffice" +command = "/bin/bash scripts/actions/add_remove_libreoffice" +# user = "root" # optional +# cwd = "/" # optional +# accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "Install or remove libreoffice" + +[list_all_pads] +name = "List all existing pads" +command = "/bin/bash scripts/actions/list_all_pads" +# user = "root" # optional +# cwd = "/" # optional +# accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "List all existing pads." + +[reset_default_config] +name = "Reset the config file and restore a default one." +command = "/bin/bash scripts/actions/reset_default_config \"settings.json\"" +# user = "root" # optional +# cwd = "/" # optional +# accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "Reset the config file settings.json." + +[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 ?" + default = true diff --git a/config_panel.json b/config_panel.json deleted file mode 100644 index 4beaf4f..0000000 --- a/config_panel.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "name": "Etherpad configuration panel", - "version": "0.1", - "panel": [{ - "name": "Etherpad configuration", - "id": "main", - "sections": [{ - "name": "Export", - "id": "export", - "options": [{ - "name": "Use abiword (~260Mo) or libreoffice (~400Mo) (more stable) to expand export possibilities (pdf, doc) ?", - "help": "We can't use a choices field for now. In the meantime please choose between one of this values:
none, abiword, libreoffice.", - "id": "export", - "type": "text", - "//": "\"choices\" : [\"none\", \"abiword\", \"libreoffice\"]", - "default" : "none" - }] - }, - { - "name": "Default pad configuration", - "id": "pad_configuration", - "options": [{ - "name": "Hide authorship colors ?", - "id": "pad_config_nocolors", - "type": "bool", - "default": false - }, - { - "name": "Show line numbers ?", - "id": "pad_config_showlinenumbers", - "type": "bool", - "default": true - }, - { - "name": "Show chat and users ?", - "id": "pad_config_chatandusers", - "type": "bool", - "default": false - }, - { - "name": "Always show chat ?", - "id": "pad_config_alwaysshowchat", - "type": "bool", - "default": false - }, - { - "name": "Show markdown syntax ?", - "id": "pad_config_show_markdown", - "type": "bool", - "default": false - }, - { - "name": "Page view ?", - "id": "pad_config_pageview", - "type": "bool", - "default": false - }] - }, - { - "name": "Mypads configuration", - "id": "mypads_configuration", - "options": [{ - "name": "Enable Mypads plugin ?", - "id": "mypads", - "type": "bool", - "default": true - }, - { - "name": "Use ldap with Mypads ?", - "id": "useldap", - "type": "bool", - "default": true - }] - }, - { - "name": "Public access", - "id": "is_public", - "options": [{ - "name": "Is it a public app ?", - "id": "is_public", - "type": "bool", - "default": true - }] - }, - { - "name": "Overwriting config files", - "id": "overwrite_files", - "options": [{ - "name": "Overwrite the config file settings.json ?", - "help": "If the file is overwritten, a backup will be created.", - "id": "overwrite_settings", - "type": "bool", - "default": true - }, - { - "name": "Overwrite the config file credentials.json ?", - "help": "If the file is overwritten, a backup will be created.", - "id": "overwrite_credentials", - "type": "bool", - "default": true - }, - { - "name": "Overwrite the nginx config file ?", - "help": "If the file is overwritten, a backup will be created.", - "id": "overwrite_nginx", - "type": "bool", - "default": true - }, - { - "name": "Overwrite the systemd config file ?", - "help": "If the file is overwritten, a backup will be created.", - "id": "overwrite_systemd", - "type": "bool", - "default": true - }] - }] - } -] -} diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..f79a5f0 --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,100 @@ +version = "0.1" +name = "Etherpad configuration panel" + +[main] +name = "Etherpad configuration" + + + [main.export] + name = "Export" + + [main.export.export] + ask = "Use abiword (~260Mo) or libreoffice (~400Mo) (more stable) to expand export possibilities (pdf, doc) ?" + choices = ["none", "abiword", "libreoffice"] + default = "none" + + + [main.pad_configuration] + name = "Default pad configuration" + + [main.pad_configuration.pad_config_nocolors] + ask = "Hide authorship colors ?" + type = "boolean" + default = false + + [main.pad_configuration.pad_config_showlinenumbers] + ask = "Show line numbers ?" + type = "boolean" + default = true + + [main.pad_configuration.pad_config_chatandusers] + ask = "Show chat and users ?" + type = "boolean" + default = false + + [main.pad_configuration.pad_config_alwaysshowchat] + ask = "Always show chat ?" + type = "boolean" + default = false + + [main.pad_configuration.pad_config_show_markdown] + ask = "Show markdown syntax ?" + type = "boolean" + default = false + + [main.pad_configuration.pad_config_pageview] + ask = "Page view ?" + type = "boolean" + default = false + + + [main.mypads_configuration] + name = "Mypads configuration" + + [main.mypads_configuration.mypads] + ask = "Enable Mypads plugin ?" + type = "boolean" + default = true + + [main.mypads_configuration.useldap] + ask = "Use ldap with Mypads ?" + type = "boolean" + default = true + + + [main.is_public] + name = "Public access" + + [main.is_public.is_public] + ask = "Is it a public website?" + type = "boolean" + default = true + help = "If your etherpad instance is public, everyone will be able to create a pad or see an existing one." + + + [main.overwrite_files] + name = "Overwriting config files" + + [main.overwrite_files.overwrite_settings] + ask = "Overwrite the config file settings.json ?" + type = "boolean" + default = true + help = "If the file is overwritten, a backup will be created." + + [main.overwrite_files.overwrite_credentials] + ask = "Overwrite the config file credentials.json ?" + type = "boolean" + default = true + help = "If the file is overwritten, a backup will be created." + + [main.overwrite_files.overwrite_nginx] + ask = "Overwrite the nginx config file ?" + type = "boolean" + default = true + help = "If the file is overwritten, a backup will be created." + + [main.overwrite_files.overwrite_systemd] + ask = "Overwrite the systemd config file ?" + type = "boolean" + default = true + help = "If the file is overwritten, a backup will be created." From 7b19a35da535a5bf24f08dbacb8944a44de124da Mon Sep 17 00:00:00 2001 From: maniack Date: Sat, 7 Dec 2019 23:28:28 +0100 Subject: [PATCH 07/42] Upgrade actions and config-panel scripts --- scripts/_common.sh | 18 ------- scripts/actions/add_remove_abiword | 16 +++++- scripts/actions/add_remove_libreoffice | 16 +++++- scripts/actions/list_all_pads | 12 ++++- scripts/actions/public_private | 27 +++++++--- scripts/actions/reset_default_config | 41 ++++++++++----- scripts/config | 73 ++++++++++++-------------- 7 files changed, 121 insertions(+), 82 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c2b4179..89c5a7b 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -22,24 +22,6 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant fi } -#================================================= -# BOOLEAN CONVERTER -#================================================= - -bool_to_01 () { - local var="$1" - [ "$var" = "true" ] && var=1 - [ "$var" = "false" ] && var=0 - echo "$var" -} - -bool_to_true_false () { - local var="$1" - [ "$var" = "1" ] && var=true - [ "$var" = "0" ] && var=false - echo "$var" -} - #================================================= # FUTUR OFFICIAL HELPERS #================================================= diff --git a/scripts/actions/add_remove_abiword b/scripts/actions/add_remove_abiword index 2224ee7..1ae79da 100755 --- a/scripts/actions/add_remove_abiword +++ b/scripts/actions/add_remove_abiword @@ -29,14 +29,18 @@ then # abiword is already a dependence of etherpad_mypads. # abiword should be removed. abiword=0 - ynh_print_info "Abiword will be removed." >&2 + action1=installed + action2=Installing else # abiword isn't a dependence of etherpad_mypads. # abiword should be installed. - ynh_print_info "Abiword will be installed." >&2 abiword=1 + action1=removed + action2=Removing fi +ynh_print_info --message="Abiword will be $action1." + if apt-cache depends ${app//_/-}-ynh-deps | grep --quiet libreoffice-writer then # libreoffice is already a dependence of etherpad_mypads. @@ -54,6 +58,8 @@ fi # INSTALL OR REMOVE ABIWORD #================================================= +ynh_script_progression --message="$action2 Abiword..." --weight=3 + # Load common variables, and especially abiword dependencies. source scripts/_variables @@ -92,3 +98,9 @@ else # Remove any export app yunohost app config apply $app -a "YNH_CONFIG_MAIN_EXPORT_EXPORT=none" fi + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last diff --git a/scripts/actions/add_remove_libreoffice b/scripts/actions/add_remove_libreoffice index 26677df..ec1dc59 100755 --- a/scripts/actions/add_remove_libreoffice +++ b/scripts/actions/add_remove_libreoffice @@ -29,14 +29,18 @@ then # libreoffice is already a dependence of etherpad_mypads. # libreoffice should be removed. libreoffice=0 - ynh_print_info "Libreoffice writer will be removed." >&2 + action1=installed + action2=Installing else # libreoffice isn't a dependence of etherpad_mypads. # libreoffice should be installed. - ynh_print_info "Libreoffice writer will be installed." >&2 libreoffice=1 + action1=removed + action2=Removing fi +ynh_print_info --message="Libreoffice will be $action1." + if apt-cache depends ${app//_/-}-ynh-deps | grep --quiet abiword then # abiword is already a dependence of etherpad_mypads. @@ -54,6 +58,8 @@ fi # INSTALL OR REMOVE LIBREOFFICE #================================================= +ynh_script_progression --message="$action2 Libreoffice..." --weight=3 + # Load common variables, and especially libreoffice dependencies. source scripts/_variables @@ -92,3 +98,9 @@ else # Remove any export app yunohost app config apply $app -a "YNH_CONFIG_MAIN_EXPORT_EXPORT=none" fi + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last diff --git a/scripts/actions/list_all_pads b/scripts/actions/list_all_pads index 6bb8c21..7142b64 100755 --- a/scripts/actions/list_all_pads +++ b/scripts/actions/list_all_pads @@ -15,8 +15,8 @@ source /usr/share/yunohost/helpers app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} -db_name=$(ynh_app_setting_get $app db_name) -db_pwd=$(ynh_app_setting_get $app mysqlpwd) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) #================================================= # CHECK IF ARGUMENTS ARE CORRECT @@ -32,4 +32,12 @@ db_pwd=$(ynh_app_setting_get $app mysqlpwd) # LIST ALL PADS FROM THE DATABASE #================================================= +ynh_script_progression --message="Listing all pads..." --weight=3 + mysql -u $db_name -p$db_pwd $db_name --silent -e 'select distinct substring(store.key,5,locate(":",store.key,5)-5) as "pads" from store where store.key like "pad:%"' | sed 's/^/>> /g' >&2 + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last diff --git a/scripts/actions/public_private b/scripts/actions/public_private index 0b004cc..f8ccebb 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -25,11 +25,11 @@ app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} # CHECK IF AN ACTION HAS TO BE DONE #================================================= -is_public_old=$(ynh_app_setting_get $app is_public) +is_public_old=$(ynh_app_setting_get --app=$app --key=is_public) if [ $is_public -eq $is_public_old ] then - ynh_die "is_public is already set as $is_public." 0 + ynh_die --message="is_public is already set as $is_public." --ret_code=0 fi #================================================= @@ -38,21 +38,36 @@ fi # MOVE TO PUBLIC OR PRIVATE #================================================= +if [ $is_public -eq 0 ]; then + public_private="private" +else + public_private="public" +fi +ynh_script_progression --message="Moving the application to $public_private..." --weight=3 + if [ $is_public -eq 0 ] then - ynh_app_setting_set $app skipped_uris "/admin" # etherpad admin page doesn't support SSO... + ynh_app_setting_set --app=$app --key=skipped_uris --value="/admin" # etherpad admin page doesn't support SSO... else - ynh_app_setting_set $app skipped_uris "/" + ynh_app_setting_set --app=$app --key=skipped_uris --value="/" fi +ynh_script_progression --message="Upgrading SSOwat configuration..." # Regen ssowat configuration yunohost app ssowatconf # Update the config of the app -ynh_app_setting_set $app is_public $is_public +ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Execution completed" --last diff --git a/scripts/actions/reset_default_config b/scripts/actions/reset_default_config index e0f76ef..a643228 100755 --- a/scripts/actions/reset_default_config +++ b/scripts/actions/reset_default_config @@ -14,12 +14,13 @@ source /usr/share/yunohost/helpers #================================================= app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} -final_path=$(ynh_app_setting_get $app final_path) -port=$(ynh_app_setting_get $app port) -export=$(ynh_app_setting_get $app export) -language=$(ynh_app_setting_get $app language) -mypads=$(ynh_app_setting_get $app mypads) -useldap=$(ynh_app_setting_get $app useldap) + +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +port=$(ynh_app_setting_get --app=$app --key=port) +export=$(ynh_app_setting_get --app=$app --key=export) +language=$(ynh_app_setting_get --app=$app --key=language) +mypads=$(ynh_app_setting_get --app=$app --key=mypads) +useldap=$(ynh_app_setting_get --app=$app --key=useldap) #================================================= # SORT OUT THE CONFIG FILE TO HANDLE @@ -36,9 +37,10 @@ fi #================================================= # RESET THE CONFIG FILE #================================================= +ynh_script_progression --message="Resetting the config file $config_file..." --weight=3 # Verify the checksum and backup the file if it's different -ynh_backup_if_checksum_is_different "$config_file" +ynh_backup_if_checksum_is_different --file="$config_file" if [ "$file" = "settings.json" ] then @@ -46,27 +48,38 @@ then cp /etc/yunohost/apps/$app/conf/settings.json "$config_file" # Recreate the default config - ynh_replace_string "__PORT__" "$port" "$final_path/settings.json" + ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/settings.json" if [ "$export" = "abiword" ] then abiword_path=`which abiword` # Get abiword binary path - ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + ynh_replace_string --match_string="\"abiword\" : null" --replace_string="\"abiword\" : \"$abiword_path\"" --target_file="$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad elif [ "$export" = "libreoffice" ] then soffice_path=`which soffice` # Get soffice binary path - ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + ynh_replace_string --match_string="\"soffice\" : null" --replace_string="\"soffice\" : \"$soffice_path\"" --target_file="$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad fi - ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json" + ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/settings.json" # Use ldap for mypads if [ $mypads -eq 1 ] && [ $useldap -eq 1 ] then - ynh_replace_string "//noldap\(.*\)" "\1 //useldap" "$final_path/settings.json" + ynh_replace_string --match_string="//noldap\(.*\)" --replace_string="\1 //useldap" --target_file="$final_path/settings.json" fi fi # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$config_file" +ynh_store_file_checksum --file="$config_file" + +#================================================= +# CHECK ETHERPAD STARTING +#================================================= +ynh_script_progression --message="Restarting Etherpad..." --weight=9 # Wait for etherpad to be fully started -ynh_check_starting "You can access your Etherpad instance at" "/var/log/$app/etherpad.log" "120" +ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --last diff --git a/scripts/config b/scripts/config index 709cb22..73ac7ab 100644 --- a/scripts/config +++ b/scripts/config @@ -50,18 +50,23 @@ 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}" @@ -74,6 +79,7 @@ else old_mypads=false fi mypads="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS:-$old_mypads}" + # Ldap for Mypads if grep -q "//noldap" $config_file then @@ -84,28 +90,23 @@ fi useldap="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP:-$old_useldap}" # is_public -old_is_public="$(ynh_app_setting_get $app is_public)" -old_is_public=$(bool_to_true_false $old_is_public) +old_is_public="$(ynh_app_setting_get --app=$app --key=is_public)" is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}" # Overwrite settings.json file -old_overwrite_settings="$(ynh_app_setting_get $app overwrite_settings)" -old_overwrite_settings=$(bool_to_true_false $old_overwrite_settings) +old_overwrite_settings="$(ynh_app_setting_get --app=$app --key=overwrite_settings)" overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}" # Overwrite credentials.json file -old_overwrite_credentials="$(ynh_app_setting_get $app overwrite_credentials)" -old_overwrite_credentials=$(bool_to_true_false $old_overwrite_credentials) +old_overwrite_credentials="$(ynh_app_setting_get --app=$app --key=overwrite_credentials)" overwrite_credentials="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CREDENTIALS:-$old_overwrite_credentials}" # Overwrite nginx configuration -old_overwrite_nginx="$(ynh_app_setting_get $app overwrite_nginx)" -old_overwrite_nginx=$(bool_to_true_false $old_overwrite_nginx) +old_overwrite_nginx="$(ynh_app_setting_get --app=$app --key=overwrite_nginx)" overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}" # Overwrite systemd configuration -old_overwrite_systemd="$(ynh_app_setting_get $app overwrite_systemd)" -old_overwrite_systemd=$(bool_to_true_false $old_overwrite_systemd) +old_overwrite_systemd="$(ynh_app_setting_get --app=$app --key=overwrite_systemd)" overwrite_systemd="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD:-$old_overwrite_systemd}" #================================================= @@ -147,48 +148,48 @@ apply_config() { # padOptions noColors if [ "$pad_config_nocolors" != "$old_pad_config_nocolors" ] then - ynh_replace_string "\(\"noColors\" *: \).*," "\1$pad_config_nocolors," "$config_file" - ynh_app_setting_set $app pad_config_nocolors "$pad_config_nocolors" + ynh_replace_string --match_string="\(\"noColors\" *: \).*," --replace_string="\1$pad_config_nocolors," --target_file="$config_file" + ynh_app_setting_set --app=$app --key=pad_config_nocolors --value="$pad_config_nocolors" 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" - ynh_app_setting_set $app pad_config_showlinenumbers "$pad_config_showlinenumbers" + ynh_replace_string --match_string="\(\"showLineNumbers\" *: \).*," --replace_string="\1$pad_config_showlinenumbers," --target_file="$config_file" + ynh_app_setting_set --app=$app --key=pad_config_showlinenumbers --value="$pad_config_showlinenumbers" 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" - ynh_app_setting_set $app pad_config_chatandusers "$pad_config_chatandusers" + ynh_replace_string --match_string="\(\"chatAndUsers\" *: \).*," --replace_string="\1$pad_config_chatandusers," --target_file="$config_file" + ynh_app_setting_set --app=$app --key=pad_config_chatandusers --value="$pad_config_chatandusers" 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" - ynh_app_setting_set $app pad_config_alwaysshowchat "$pad_config_alwaysshowchat" + ynh_replace_string --match_string="\(\"alwaysShowChat\" *: \).*," --replace_string="\1$pad_config_alwaysshowchat," --target_file="$config_file" + ynh_app_setting_set --app=$app --key=pad_config_alwaysshowchat --value="$pad_config_alwaysshowchat" 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" - ynh_app_setting_set $app pad_config_show_markdown "$pad_config_show_markdown" + ynh_replace_string --match_string="\(\"ep_markdown_default\" *: \).*," --replace_string="\1$pad_config_show_markdown," --target_file="$config_file" + ynh_app_setting_set --app=$app --key=pad_config_show_markdown --value="$pad_config_show_markdown" 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" - ynh_app_setting_set $app pad_config_pageview "$pad_config_pageview" + ynh_replace_string --match_string="\(\"ep_page_view_default\" *: \).*," --replace_string="\1$pad_config_pageview," "$config_file" + ynh_app_setting_set --app=$app --key=pad_config_pageview --value="$pad_config_pageview" restart_etherpad=1 fi @@ -202,8 +203,8 @@ apply_config() { 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" + ynh_replace_string --match_string="\(\"abiword\" *: \).*," --replace_string="\1\"$(which abiword)\"," --target_file="$config_file" + ynh_replace_string --match_string="\(\"soffice\" *: \).*," --replace_string="\1null," --target_file="$config_file" elif [ "$export" = "libreoffice" ] then # if libreoffice isn't installed, call the action add_remove_libreoffice. @@ -211,11 +212,11 @@ apply_config() { 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" + ynh_replace_string --match_string="\(\"abiword\" *: \).*," --replace_string="\1null," --target_file="$config_file" + ynh_replace_string --match_string="\(\"soffice\" *: \).*," --replace_string="\1\"$(which soffice)\"," --target_file="$config_file" else - ynh_replace_string "\(\"abiword\" *: \).*," "\1null," "$config_file" - ynh_replace_string "\(\"soffice\" *: \).*," "\1null," "$config_file" + ynh_replace_string --match_string="\(\"abiword\" *: \).*," --replace_string="\1null," --target_file="$config_file" + ynh_replace_string --match_string="\(\"soffice\" *: \).*," --replace_string="\1null," --target_file="$config_file" fi restart_etherpad=1 fi @@ -241,9 +242,9 @@ apply_config() { then if [ "$useldap" = "true" ] then - ynh_replace_string "//noldap\(.*\)" "\1 //useldap" "$final_path/settings.json" + ynh_replace_string --match_string="//noldap\(.*\)" --replace_string="\1 //useldap" --target_file="$final_path/settings.json" else - ynh_replace_string "\(.*\) //useldap" "//noldap\1" "$final_path/settings.json" + ynh_replace_string --match_string="\(.*\) //useldap" --replace_string="//noldap\1" --target_file="$final_path/settings.json" fi restart_etherpad=1 fi @@ -264,17 +265,13 @@ apply_config() { fi # Set overwrite_settings - overwrite_settings=$(bool_to_01 $overwrite_settings) - ynh_app_setting_set $app overwrite_settings "$overwrite_settings" + ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings" # Set overwrite_credentials - overwrite_credentials=$(bool_to_01 $overwrite_credentials) - ynh_app_setting_set $app overwrite_credentials "$overwrite_credentials" + ynh_app_setting_set --app=$app --key=overwrite_credentials --value="$overwrite_credentials" # Set overwrite_nginx - overwrite_nginx=$(bool_to_01 $overwrite_nginx) - ynh_app_setting_set $app overwrite_nginx "$overwrite_nginx" + ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx" # Set overwrite_systemd - overwrite_systemd=$(bool_to_01 $overwrite_systemd) - ynh_app_setting_set $app overwrite_systemd "$overwrite_systemd" + ynh_app_setting_set --app=$app --key=overwrite_systemd --value="$overwrite_systemd" } #================================================= From b5b229cd8650207de75c9a3a7325ab5af72660ac Mon Sep 17 00:00:00 2001 From: maniack Date: Sat, 7 Dec 2019 23:28:46 +0100 Subject: [PATCH 08/42] Fixes --- scripts/install | 12 ++++++------ scripts/upgrade | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 2d9e6ef..94e5cda 100644 --- a/scripts/install +++ b/scripts/install @@ -75,12 +75,6 @@ ynh_app_setting_set --app=$app --key=overwrite_credentials --value="1" ynh_app_setting_set --app=$app --key=overwrite_nginx --value="1" ynh_app_setting_set --app=$app --key=overwrite_systemd --value="1" -#================================================= -# ACTIVATE MAINTENANCE MODE -#================================================= - -ynh_maintenance_mode_ON - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -341,6 +335,9 @@ fi # SEND A README FOR THE ADMIN #================================================= +# Get main domain and buid the url of the admin panel of the app. +admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" + if [ $mypads -eq 1 ] then Informations="You can access 2 different admin panels, for etherpad by accessing https://$domain${path_url%/}/admin and for mypads by accessing https://$domain${path_url%/}/mypads/?/admin." @@ -356,6 +353,9 @@ Your credentials for the admin panel are: - login : $admin - password : $password +You can configure this app easily by using the experimental config-panel feature $admin_panel/config-panel. +You can also find some specific actions for this app by using the experimental action feature $admin_panel/actions. + If you are facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/etherpad_mypads_ynh" > mail_to_send ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type=install diff --git a/scripts/upgrade b/scripts/upgrade index 7944936..e15c693 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -411,6 +411,30 @@ ynh_script_progression --message="Disabling maintenance mode..." --weight=5 ynh_maintenance_mode_OFF +#================================================= +# SEND A README FOR THE ADMIN +#================================================= + +# Get main domain and buid the url of the admin panel of the app. +admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" + +if [ $mypads -eq 1 ] +then + Informations="You can access 2 different admin panels, for etherpad by accessing https://$domain${path_url%/}/admin and for mypads by accessing https://$domain${path_url%/}/mypads/?/admin." +else + Informations="You can access the admin panel by accessing https://$domain${path_url%/}/admin." +fi + +echo "$Informations +Or, you can find a config file for etherpad at this path /var/www/etherpad_mypads/settings.json. + +You can configure this app easily by using the experimental config-panel feature $admin_panel/config-panel. +You can also find some specific actions for this app by using the experimental action feature $admin_panel/actions. + +If you are facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/etherpad_mypads_ynh" > mail_to_send + +ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type=upgrade + #================================================= # END OF SCRIPT #================================================= From 3c2f9c4b57871663bf646036da6f02fbc63ee859 Mon Sep 17 00:00:00 2001 From: maniack Date: Mon, 9 Dec 2019 18:07:29 +0100 Subject: [PATCH 09/42] Update to last standard --- check_process | 1 - scripts/change_url | 17 +++++++++++++++++ scripts/remove | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index 9255b18..48636c3 100644 --- a/check_process +++ b/check_process @@ -19,7 +19,6 @@ upgrade=1 backup_restore=1 multi_instance=0 - incorrect_path=1 port_already_use=1 (9001) change_url=1 ;; Test sans mypads diff --git a/scripts/change_url b/scripts/change_url index 131102c..2b55063 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,6 +30,23 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) mypads=$(ynh_app_setting_get --app=$app --key=mypads) port=$(ynh_app_setting_get --app=$app --key=port) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=40 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # ACTIVATE MAINTENANCE MODE #================================================= diff --git a/scripts/remove b/scripts/remove index 1087332..1415a9b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -28,7 +28,7 @@ export=$(ynh_app_setting_get --app=$app --key=export) #================================================= # Remove a service from the admin panel, added by `yunohost service add` -if yunohost service status $app >/dev/null 2>&1 +if ynh_exec_fully_quiet yunohost service status $app then ynh_script_progression --message="Removing $app service..." yunohost service remove $app From feb52f60db43eb133674a286cd7093d0932bd829 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 12 Dec 2019 19:36:20 +0100 Subject: [PATCH 10/42] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 487ac1c..066b9e1 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Framapad clone, a online editor providing collaborative editing in real-time.", "fr": "Clone de Framapad, un éditeur en ligne fournissant l'édition collaborative en temps réel." }, - "version": "1.7.5~ynh2", + "version": "1.7.5~ynh3", "url": "https://framapad.org", "license": "Apache-2.0", "maintainer": { From 5fb8004f1981ecab03c96d0df0c30f7594e22f20 Mon Sep 17 00:00:00 2001 From: maniack Date: Thu, 12 Dec 2019 19:39:57 +0100 Subject: [PATCH 11/42] Add changelog --- CHANGELOG.md | 33 ++++++ scripts/_common.sh | 258 +++++++++++++++++++++++++-------------------- scripts/upgrade | 19 +++- 3 files changed, 195 insertions(+), 115 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..70d92a8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,33 @@ +Changelog +========= + +## Unreleased +#### Changed +* [Upgrade actions and config-panel scripts](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/commit/7b19a35da535a5bf24f08dbacb8944a44de124da) + +## [1.7.5~ynh2](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/69) - 2019-05-26 + +#### Changed +* [Upgrade to Etherpad 1.7.5](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/69/commits/d299b77dd865e9fff306c121235450e27ab9372a) + +## [1.7.0~ynh2](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63) - 2019-03-29 + +#### Fixed +- [Fix regression on ynh_system_user_create](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/c0de9b2ee3ebc5ecb11e02655984e1fe793dd9d5) + +#### Added +- [Progress bar](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/4489e07a059477802cfeb402e1980b79e1ddce97) + +#### Changed +- [Update to last standart](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/c663ec74c1d97cccbc1291a9d3e74cdf3b7586e9) +* [Update to mypads 1.7.6](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/c87caaad6507a52a71572ef21529cc4f1022b53b) +- [Update helpers](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/bab779a39f3f6f45c0fcc6bdf640baa47a5e6821) +- [Allow to include a pad in an other page](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/f27cca79957f88fd9972452db146fe6867ba3f79) + +## [1.7.0~ynh1](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/55) - 2018-12-08 + +#### Fixed +- [Set permissions during the restore script](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/55/commits/85be69b5ce15db0d9df0f0ca191be43c2ea6bc31) + +#### Changed +* [Update mypads to 1.6.8](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/55/commits/8c73fd242286029991b774d02ce9209c88793c21) diff --git a/scripts/_common.sh b/scripts/_common.sh index 89c5a7b..42f4916 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,9 @@ #!/bin/bash +#================================================= +# PERSONAL HELPERS +#================================================= + #================================================= # BACKUP #================================================= @@ -30,120 +34,6 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant # EXPERIMENTAL HELPERS #================================================= -# Start or restart a service and follow its booting -# -# usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name] -# -# | arg: Line to match - The line to find in the log to attest the service have finished to boot. -# | arg: Log file - The log file to watch; specify "systemd" to read systemd journal for specified service -# /var/log/$app/$app.log will be used if no other log is defined. -# | arg: Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds. -# | arg: Service name - -ynh_check_starting () { - local line_to_match="$1" - local app_log="${2:-/var/log/$service_name/$service_name.log}" - local timeout=${3:-300} - local service_name="${4:-$app}" - - echo "Starting of $service_name" >&2 - systemctl stop $service_name - local templog="$(mktemp)" - # Following the starting of the app in its log - if [ "$app_log" == "systemd" ] ; then - # Read the systemd journal - journalctl -u $service_name -f --since=-45 > "$templog" & - else - # Read the specified log file - tail -F -n0 "$app_log" > "$templog" & - fi - # Get the PID of the last command - local pid_tail=$! - systemctl start $service_name - - local i=0 - for i in `seq 1 $timeout` - do - # Read the log until the sentence is found, which means the app finished starting. Or run until the timeout. - if grep --quiet "$line_to_match" "$templog" - then - echo "The service $service_name has correctly started." >&2 - break - fi - echo -n "." >&2 - sleep 1 - done - if [ $i -eq $timeout ] - then - echo "The service $service_name didn't fully start before the timeout." >&2 - fi - - echo "" - ynh_clean_check_starting -} -# Clean temporary process and file used by ynh_check_starting -# (usually used in ynh_clean_setup scripts) -# -# usage: ynh_clean_check_starting - -ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 -} - -#================================================= - -ynh_print_log () { - echo "${1}" -} - -# Print an info on stdout -# -# usage: ynh_print_info "Text to print" -# | arg: text - The text to print -ynh_print_info () { - ynh_print_log "[INFO] ${1}" -} - -# Print a error on stderr -# -# usage: ynh_print_err "Text to print" -# | arg: text - The text to print -ynh_print_err () { - ynh_print_log "[ERR] ${1}" >&2 -} - -# Execute a command and force the result to be printed on stdout -# -# usage: ynh_exec_warn_less command to execute -# usage: ynh_exec_warn_less "command to execute | following command" -# In case of use of pipes, you have to use double quotes. Otherwise, this helper will be executed with the first command, then be send to the next pipe. -# -# | arg: command - command to execute -ynh_exec_warn_less () { - eval $@ 2>&1 -} - -# Remove any logs for all the following commands. -# -# usage: ynh_print_OFF -# WARNING: You should be careful with this helper, and never forgot to use ynh_print_ON as soon as possible to restore the logging. -ynh_print_OFF () { - set +x -} - -# Restore the logging after ynh_print_OFF -# -# usage: ynh_print_ON -ynh_print_ON () { - set -x - # Print an echo only for the log, to be able to know that ynh_print_ON has been called. - echo ynh_print_ON > /dev/null -} - -#================================================= - # Send an email to inform the administrator # # usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type] @@ -294,6 +184,8 @@ ynh_maintenance_mode_ON () { domain=$(ynh_app_setting_get $app domain) fi + mkdir -p /var/www/html/ + # Create an html to serve as maintenance notice echo " @@ -361,3 +253,141 @@ ynh_maintenance_mode_OFF () { systemctl reload nginx } + +#================================================= + +# Create a changelog for an app after an upgrade from the file CHANGELOG.md. +# +# usage: ynh_app_changelog [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source] +# | arg: -f --format= - Format in which the changelog will be printed +# markdown: Default format. +# html: Turn urls into html format. +# plain: Plain text changelog +# | arg: -o --output= - Output file for the changelog file (Default ./changelog) +# | arg: -c --changelog= - CHANGELOG.md source (Default ../CHANGELOG.md) +# +# The changelog is printed into the file ./changelog and ./changelog_lite +ynh_app_changelog () { + # Declare an array to define the options of this helper. + local legacy_args=foc + declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= ) + local format + local output + local changelog + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + format=${format:-markdown} + output=${output:-changelog} + changelog=${changelog:-../CHANGELOG.md} + + local original_changelog="$changelog" + local temp_changelog="changelog_temp" + local final_changelog="$output" + + if [ ! -n "$original_changelog" ] + then + echo "No changelog available..." > "$final_changelog" + echo "No changelog available..." > "${final_changelog}_lite" + return 0 + fi + + local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version") + local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version") + + # Get the line of the version to update to into the changelog + local update_version_line=$(grep --max-count=1 --line-number "^## \[$update_version" "$original_changelog" | cut -d':' -f1) + # If there's no entry for this version yet into the changelog + # Get the first available version + if [ -z "$update_version_line" ] + then + update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1) + fi + + # Get the length of the complete changelog. + local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}') + # Cut the file before the version to update to. + tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog" + + # Get the length of the troncated changelog. + changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}') + # Get the line of the current version into the changelog + # Keep only the last line found + local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1) + # If there's no entry for this version into the changelog + # Get the last available version + if [ -z "$current_version_line" ] + then + current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1) + fi + # Cut the file before the current version. + # Then grep the previous version into the changelog to get the line number of the previous version + local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \ + "$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1) + # If there's no previous version into the changelog + # Go until the end of the changelog + if [ -z "$previous_version_line" ] + then + previous_version_line=$changelog_length + fi + + # Cut the file after the previous version to keep only the changelog between the current version and the version to update to. + head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog" + + if [ "$format" = "html" ] + then + # Replace markdown links by html links + ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="\1)" --target_file="$final_changelog" + ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="\1" --target_file="$final_changelog" + elif [ "$format" = "plain" ] + then + # Change title format. + ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog" + # Change modifications lines format. + ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog" + fi + # else markdown. As the file is already in markdown, nothing to do. + + # Keep only important changes into the changelog + # Remove all minor changes + sed '/^-/d' "$final_changelog" > "${final_changelog}_lite" + # Remove all blank lines (to keep a clear workspace) + sed --in-place '/^$/d' "${final_changelog}_lite" + # Add a blank line at the end + echo "" >> "${final_changelog}_lite" + + # Clean titles if there's no significative changes + local line + local previous_line="" + while read line <&3 + do + if [ -n "$previous_line" ] + then + # Remove the line if it's a title or a blank line, and the previous one was a title as well. + if ( [ "${line:0:1}" = "#" ] || [ ${#line} -eq 0 ] ) && [ "${previous_line:0:1}" = "#" ] + then + ynh_replace_special_string --match_string="${previous_line//[/.}" --replace_string="" --target_file="${final_changelog}_lite" + fi + fi + previous_line="$line" + done 3< "${final_changelog}_lite" + + # Remove all blank lines again + sed --in-place '/^$/d' "${final_changelog}_lite" + + # Restore changelog format with blank lines + ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_file="${final_changelog}_lite" + # Remove the 2 first blank lines + sed --in-place '1,2d' "${final_changelog}_lite" + # Add a blank line at the end + echo "" >> "${final_changelog}_lite" + + # If changelog are empty, add an info + if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ] + then + echo "No changes from the changelog..." > "$final_changelog" + fi + if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ] + then + echo "No significative changes from the changelog..." > "${final_changelog}_lite" + fi +} diff --git a/scripts/upgrade b/scripts/upgrade index e15c693..0a83aca 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -418,6 +418,18 @@ ynh_maintenance_mode_OFF # Get main domain and buid the url of the admin panel of the app. admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" +# Build the changelog +# Get the value of admin_mail_html +admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) +admin_mail_html="${admin_mail_html:-0}" +# If a html email is required. Apply html to the changelog. +if [ "$admin_mail_html" -eq 1 ]; then + format=html +else + format=plain +fi +ynh_app_changelog --format=$format + if [ $mypads -eq 1 ] then Informations="You can access 2 different admin panels, for etherpad by accessing https://$domain${path_url%/}/admin and for mypads by accessing https://$domain${path_url%/}/mypads/?/admin." @@ -431,7 +443,12 @@ Or, you can find a config file for etherpad at this path /var/www/etherpad_mypad You can configure this app easily by using the experimental config-panel feature $admin_panel/config-panel. You can also find some specific actions for this app by using the experimental action feature $admin_panel/actions. -If you are facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/etherpad_mypads_ynh" > mail_to_send +If you are facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/etherpad_mypads_ynh + +--- + +Changelog since your last upgrade: +$(cat changelog)" > mail_to_send ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="$admin" --type=upgrade From 2bd8f440aeeba1134d3f0fc28c6b74d2886df869 Mon Sep 17 00:00:00 2001 From: maniack Date: Mon, 9 Dec 2019 18:07:29 +0100 Subject: [PATCH 12/42] Update to last standard --- check_process | 1 - scripts/change_url | 17 +++++++++++++++++ scripts/remove | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index 9255b18..48636c3 100644 --- a/check_process +++ b/check_process @@ -19,7 +19,6 @@ upgrade=1 backup_restore=1 multi_instance=0 - incorrect_path=1 port_already_use=1 (9001) change_url=1 ;; Test sans mypads diff --git a/scripts/change_url b/scripts/change_url index 131102c..2b55063 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,6 +30,23 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) mypads=$(ynh_app_setting_get --app=$app --key=mypads) port=$(ynh_app_setting_get --app=$app --key=port) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=40 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # ACTIVATE MAINTENANCE MODE #================================================= diff --git a/scripts/remove b/scripts/remove index 1087332..1415a9b 100755 --- a/scripts/remove +++ b/scripts/remove @@ -28,7 +28,7 @@ export=$(ynh_app_setting_get --app=$app --key=export) #================================================= # Remove a service from the admin panel, added by `yunohost service add` -if yunohost service status $app >/dev/null 2>&1 +if ynh_exec_fully_quiet yunohost service status $app then ynh_script_progression --message="Removing $app service..." yunohost service remove $app From c83b418957fb16924e9ef32df7a40be93697c4ff Mon Sep 17 00:00:00 2001 From: maniack Date: Mon, 30 Dec 2019 20:01:19 +0100 Subject: [PATCH 13/42] Update to v1.8.0 --- README.md | 2 +- README_fr.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- scripts/_common.sh | 15 +++++++++++++++ scripts/_variables | 2 +- scripts/install | 11 +++++++++-- scripts/restore | 3 +-- scripts/upgrade | 11 ++++++----- 9 files changed, 37 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index ad5d437..8ddf8cd 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to Etherpad is a highly customizable Open Source online editor providing collaborative editing in really real-time. This package will install the same plugins than [Framapad](https://framapad.org/). -**Shipped version:** 1.7.5 +**Shipped version:** 1.8.0 ## Screenshots diff --git a/README_fr.md b/README_fr.md index 303b6ef..b192165 100644 --- a/README_fr.md +++ b/README_fr.md @@ -12,7 +12,7 @@ Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/inst Etherpad est un éditeur en ligne Open Source hautement personnalisable qui permet l'édition collaborative en temps réel. Ce paquet installera les mêmes plugins que [Framapad](https://framapad.org/). -**Version embarquée:** 1.7.5 +**Version embarquée:** 1.8.0 ## Captures d'écran diff --git a/conf/app.src b/conf/app.src index 2ed7470..14d481e 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/ether/etherpad-lite/archive/1.7.5.tar.gz -SOURCE_SUM=01971447ff7b4d0d2af52faf02edb032 +SOURCE_URL=https://github.com/ether/etherpad-lite/archive/1.8.0.tar.gz +SOURCE_SUM=f5fc307e4206b1db13d12833024968bc SOURCE_SUM_PRG=md5sum ARCH_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 066b9e1..b0f63b9 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Framapad clone, a online editor providing collaborative editing in real-time.", "fr": "Clone de Framapad, un éditeur en ligne fournissant l'édition collaborative en temps réel." }, - "version": "1.7.5~ynh3", + "version": "1.8.0~ynh1", "url": "https://framapad.org", "license": "Apache-2.0", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 89c5a7b..89b259c 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -361,3 +361,18 @@ ynh_maintenance_mode_OFF () { systemctl reload nginx } + +#================================================= + +# Execute a command as another user +# usage: ynh_exec_as USER COMMAND [ARG ...] +ynh_exec_as() { + local USER=$1 + shift 1 + + if [[ $USER = $(whoami) ]]; then + eval "$@" + else + sudo -u "$USER" "$@" + fi +} diff --git a/scripts/_variables b/scripts/_variables index 9d86eaa..4336050 100644 --- a/scripts/_variables +++ b/scripts/_variables @@ -7,7 +7,7 @@ abiword_app_depencencies="abiword" libreoffice_app_dependencies="unoconv libreoffice-writer" # NodeJS version -nodejs_version=6 +nodejs_version=10 # Mypads version # This variable is mostly used to force an upgrade of the package in case of new versions of mypads. diff --git a/scripts/install b/scripts/install index 94e5cda..92fd0b1 100644 --- a/scripts/install +++ b/scripts/install @@ -162,8 +162,15 @@ ynh_script_progression --message="Installing Etherpad..." --weight=90 # Install dependencies and proceed to the installation ynh_use_nodejs -"$final_path/bin/installDeps.sh" > $install_log 2>&1 || ( ynh_exec_err cat "$install_log"; false ) -npm install forever -g >> $install_log 2>&1 || ( ynh_exec_err cat "$install_log"; false ) +( + cd "$final_path" + mkdir -p node_modules + cd node_modules + [ -e ep_etherpad-lite ] || ln -s ../src ep_etherpad-lite + cd ep_etherpad-lite + chown -R $app: $final_path + ynh_exec_as $app PATH="$nodejs_path:$PATH" "$nodejs_path/npm" install --save --loglevel warn +) #================================================= # CONFIGURE ETHERPAD diff --git a/scripts/restore b/scripts/restore index 1948604..24c6f93 100644 --- a/scripts/restore +++ b/scripts/restore @@ -127,8 +127,7 @@ ynh_install_nodejs --nodejs_version=$nodejs_version ynh_script_progression --message="Reinstalling Etherpad node dependencies..." --weight=17 ynh_use_nodejs -npm cache clean -npm install forever -g >> $install_log 2>&1 +ynh_exec_warn_less npm cache clean --force #================================================= # RESTORE USER RIGHTS diff --git a/scripts/upgrade b/scripts/upgrade index e15c693..fa8c481 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -220,17 +220,18 @@ ynh_install_nodejs --nodejs_version=$nodejs_version ynh_script_progression --message="Upgrading Etherpad npm modules..." --weight=60 # Update the main modules of etherpad +chown -R $app: $final_path (cd "$final_path/src" -npm cache clean -ynh_exec_warn_less npm update) +ynh_exec_warn_less npm cache clean --force +ynh_exec_warn_less ynh_exec_as $app PATH="$nodejs_path:$PATH" "$nodejs_path/npm" update) # Then update the additionnal modules (cd "$final_path" -npm cache clean +ynh_exec_warn_less npm cache clean --force while read node_module do - echo "Update $node_module" - ynh_exec_warn_less npm install --upgrade $node_module || true + echo "Update $node_module" + ynh_exec_warn_less ynh_exec_as $app PATH="$nodejs_path:$PATH" "$nodejs_path/npm" install --upgrade $node_module || true done <<< "$(ls -1 "$final_path/node_modules" | grep "^ep_")") #================================================= From d80d193ef96db49a5016bd642c43ec838d2f8f8f Mon Sep 17 00:00:00 2001 From: maniack Date: Sat, 4 Jan 2020 19:50:26 +0100 Subject: [PATCH 14/42] Fix config-panel --- scripts/config | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/config b/scripts/config index 73ac7ab..c90cea3 100644 --- a/scripts/config +++ b/scripts/config @@ -115,26 +115,26 @@ overwrite_systemd="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD:-$old_ove 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_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value" - echo "YNH_CONFIG_MAIN_EXPORT_EXPORT=$export" + ynh_return "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" + ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_NOCOLORS=$pad_config_nocolors" + ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOWLINENUMBERS=$pad_config_showlinenumbers" + ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_CHATANDUSERS=$pad_config_chatandusers" + ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_ALWAYSSHOWCHAT=$pad_config_alwaysshowchat" + ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOW_MARKDOWN=$pad_config_show_markdown" + ynh_return "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" + ynh_return "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS=$mypads" + ynh_return "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP=$useldap" - echo "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public" + ynh_return "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public" - echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings" - echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CREDENTIALS=$overwrite_credentials" - echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx" - echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd" + ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings" + ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_CREDENTIALS=$overwrite_credentials" + ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx" + ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd" } #================================================= From c1c5c06c8f5f22ae8c29cf5110817a0ec462bae2 Mon Sep 17 00:00:00 2001 From: Kayou Date: Thu, 16 Jan 2020 00:42:29 +0700 Subject: [PATCH 15/42] Update config --- scripts/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config b/scripts/config index c90cea3..abcd7ca 100644 --- a/scripts/config +++ b/scripts/config @@ -257,7 +257,7 @@ apply_config() { fi # Change public accessibility - if [ "$is_public" = "true" ] + if [ "$is_public" = "1" ] then yunohost app action run $app public_private --args is_public=1 else From f36f1c0f1393a8aa07bdf0d34c9a91d66a108101 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 31 Jan 2020 12:34:11 +0100 Subject: [PATCH 16/42] Update CHANGELOG.md --- CHANGELOG.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70d92a8..b32409a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,23 @@ Changelog ========= ## Unreleased + +## [1.8.0~ynh1](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/74) - 2019-10-08 + +#### Added +* [Add actions and config-panel](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/49) +* [Add changelog](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/76) + #### Changed -* [Upgrade actions and config-panel scripts](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/commit/7b19a35da535a5bf24f08dbacb8944a44de124da) +* [Upgrade to 1.8.0](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/78) + ## [1.7.5~ynh2](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/69) - 2019-05-26 #### Changed * [Upgrade to Etherpad 1.7.5](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/69/commits/d299b77dd865e9fff306c121235450e27ab9372a) + ## [1.7.0~ynh2](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63) - 2019-03-29 #### Fixed @@ -24,6 +33,7 @@ Changelog - [Update helpers](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/bab779a39f3f6f45c0fcc6bdf640baa47a5e6821) - [Allow to include a pad in an other page](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/f27cca79957f88fd9972452db146fe6867ba3f79) + ## [1.7.0~ynh1](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/55) - 2018-12-08 #### Fixed From db7732a8c39fd31c4443e0e8b627551a68184f05 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 31 Jan 2020 12:34:51 +0100 Subject: [PATCH 17/42] Update CHANGELOG.md --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b32409a..679bb42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,12 +21,12 @@ Changelog ## [1.7.0~ynh2](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63) - 2019-03-29 -#### Fixed -- [Fix regression on ynh_system_user_create](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/c0de9b2ee3ebc5ecb11e02655984e1fe793dd9d5) - #### Added - [Progress bar](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/4489e07a059477802cfeb402e1980b79e1ddce97) +#### Fixed +- [Fix regression on ynh_system_user_create](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/c0de9b2ee3ebc5ecb11e02655984e1fe793dd9d5) + #### Changed - [Update to last standart](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/c663ec74c1d97cccbc1291a9d3e74cdf3b7586e9) * [Update to mypads 1.7.6](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/63/commits/c87caaad6507a52a71572ef21529cc4f1022b53b) From 00060c99db7f0fcac57c910256a37b6deeb8c2fe Mon Sep 17 00:00:00 2001 From: maniack Date: Thu, 12 Mar 2020 18:59:06 +0100 Subject: [PATCH 18/42] Update to mypads 1.7.10 --- CHANGELOG.md | 3 +++ scripts/_variables | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 679bb42..281fba3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ Changelog ========= ## Unreleased +#### Changed +* [Update to mypads 1.7.10]() + ## [1.8.0~ynh1](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/74) - 2019-10-08 diff --git a/scripts/_variables b/scripts/_variables index 4336050..7c959bf 100644 --- a/scripts/_variables +++ b/scripts/_variables @@ -11,4 +11,4 @@ nodejs_version=10 # Mypads version # This variable is mostly used to force an upgrade of the package in case of new versions of mypads. -mypads_version=1.7.6 +mypads_version=1.7.10 From fdc8d6cbdd8eb0931336311d53857dad7f966d93 Mon Sep 17 00:00:00 2001 From: maniack Date: Sat, 14 Mar 2020 20:03:45 +0100 Subject: [PATCH 19/42] Allow to enable or disable automatic logout --- conf/settings.json | 1 - config_panel.toml | 5 +++++ scripts/config | 45 ++++++++++++++++++++++++++++++++++++--------- scripts/upgrade | 2 +- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/conf/settings.json b/conf/settings.json index c5ba108..20c2398 100644 --- a/conf/settings.json +++ b/conf/settings.json @@ -66,7 +66,6 @@ // Plugins config // ep_automatic_logut "automatic_logut_mins_show" : true, // Show logout time selector -// "automatic_logut_mins" : 30, // Set default time logout in minutes - Crash etherpad... "automatic_logut_url" : "../../", // Redirection URL address // ep_markdown diff --git a/config_panel.toml b/config_panel.toml index f79a5f0..21cb335 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -47,6 +47,11 @@ name = "Etherpad configuration" type = "boolean" default = false + [main.pad_configuration.pad_config_automatic_logout] + ask = "Automatic logout" + type = "boolean" + default = true + [main.mypads_configuration] name = "Mypads configuration" diff --git a/scripts/config b/scripts/config index abcd7ca..d8076de 100644 --- a/scripts/config +++ b/scripts/config @@ -31,7 +31,6 @@ 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 - } #================================================= @@ -71,21 +70,36 @@ pad_config_show_markdown="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOW_MA 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}" +# Enable/disable ep_automatic_logut +if grep -q "//.*\"automatic_logut_" $config_file +then + # Disable + old_pad_config_automatic_logout=0 +else + # Enable + old_pad_config_automatic_logout=1 +fi +pad_config_automatic_logout="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_AUTOMATIC_LOGOUT:-$old_pad_config_automatic_logout}" + # Mypads if [ -d $final_path/node_modules/ep_mypads ] then - old_mypads=true + # Enable + old_mypads=1 else - old_mypads=false + # Disable + old_mypads=0 fi mypads="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS:-$old_mypads}" # Ldap for Mypads if grep -q "//noldap" $config_file then - old_useldap=false + # Disable + old_useldap=0 else - old_useldap=true + # Enable + old_useldap=1 fi useldap="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP:-$old_useldap}" @@ -125,6 +139,7 @@ show_config() { ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_ALWAYSSHOWCHAT=$pad_config_alwaysshowchat" ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOW_MARKDOWN=$pad_config_show_markdown" ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_PAGEVIEW=$pad_config_pageview" + ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_AUTOMATIC_LOGOUT=$pad_config_automatic_logout" ynh_return "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS=$mypads" ynh_return "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP=$useldap" @@ -188,11 +203,23 @@ apply_config() { # Plugin option ep_page_view_default if [ "$pad_config_pageview" != "$old_pad_config_pageview" ] then - ynh_replace_string --match_string="\(\"ep_page_view_default\" *: \).*," --replace_string="\1$pad_config_pageview," "$config_file" + ynh_replace_string --match_string="\(\"ep_page_view_default\" *: \).*," --replace_string="\1$pad_config_pageview," --target_file="$config_file" ynh_app_setting_set --app=$app --key=pad_config_pageview --value="$pad_config_pageview" restart_etherpad=1 fi + # Plugin option ep_automatic_logut + if [ "$pad_config_automatic_logout" != "$old_pad_config_automatic_logout" ] + then + if [ "$pad_config_automatic_logout" = "0" ] + then + ynh_replace_string --match_string="^\(.*\"automatic_logut.*$\)" --replace_string="\/\/\1" --target_file="$config_file" + else + ynh_replace_string --match_string="^\/\/\(.*\"automatic_logut.*$\)" --replace_string="\1" --target_file="$config_file" + fi + restart_etherpad=1 + fi + # Export if [ "$export" != "$old_export" ] then @@ -226,7 +253,7 @@ apply_config() { then ynh_use_nodejs pushd "$final_path" - if [ "$mypads" = "true" ] + if [ "$mypads" = "1" ] then npm install ep_mypads@${mypads_version} else @@ -240,7 +267,7 @@ apply_config() { # Ldap for Mypads if [ "$useldap" != "$old_useldap" ] then - if [ "$useldap" = "true" ] + if [ "$useldap" = "1" ] then ynh_replace_string --match_string="//noldap\(.*\)" --replace_string="\1 //useldap" --target_file="$final_path/settings.json" else @@ -253,7 +280,7 @@ apply_config() { 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" + ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" fi # Change public accessibility diff --git a/scripts/upgrade b/scripts/upgrade index c794cb9..34c9859 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -369,7 +369,7 @@ fi # SOME HACKS #================================================= -if [ $mypads -eq 1 ] +if [ "$upgrade_type" == "UPGRADE_APP" ] then # Find the /div just after the field to open a pad mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "" | cut -d '-' -f 1) From f14e43de4ad105c5bf3fc8977fa93adf1524830a Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 19 Mar 2020 18:01:40 +0100 Subject: [PATCH 20/42] Update pull_request_template.md --- pull_request_template.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pull_request_template.md b/pull_request_template.md index 314c271..d7cd620 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -2,7 +2,7 @@ - *Description of why you made this PR* ## Solution -- *And how you fix that* +- *And how do you fix that problem* ## PR Status - [ ] Code finished. @@ -14,10 +14,9 @@ ## Validation --- *Minor decision* -- **Upgrade previous version** : - [ ] **Code review** : -- [ ] **Approval (LGTM)** : -- [ ] **Approval (LGTM)** : +- [ ] **Approval (LGTM)** : +*Code review and approval have to be from a member of @YunoHost-Apps/apps-group* - **CI succeeded** : [![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/etherpad_mypads_ynh%20PR-NUM-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/etherpad_mypads_ynh%20PR-NUM-/) *Please replace '-NUM-' in this link by the PR number.* From b76ebf922ad7debcd1d392504ce9ae6e36aa9d51 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Thu, 26 Mar 2020 15:22:42 +0100 Subject: [PATCH 21/42] Clarify the "Overwriting config" thing The actual description is unclear. --- config_panel.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_panel.toml b/config_panel.toml index 21cb335..ea7beec 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -78,7 +78,7 @@ name = "Etherpad configuration" [main.overwrite_files] - name = "Overwriting config files" + name = "Overwriting config files during an upgrade" [main.overwrite_files.overwrite_settings] ask = "Overwrite the config file settings.json ?" From 5ebdfa83af3b863ac76a952618bf2be9cb06289a Mon Sep 17 00:00:00 2001 From: Aeris One Date: Tue, 31 Mar 2020 23:14:12 +0200 Subject: [PATCH 22/42] Using new skin for Etherpad --- conf/settings.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/conf/settings.json b/conf/settings.json index 20c2398..00fcf9c 100644 --- a/conf/settings.json +++ b/conf/settings.json @@ -21,6 +21,18 @@ // Option to hide/show the settings.json in admin page, default option is set to true "showSettingsInAdminPage" : true, +/* + * Skin name. + * + * Its value has to be an existing directory under src/static/skins. + * You can write your own, or use one of the included ones: + * + * - "no-skin": an empty skin (default before 1.8). This yields the unmodified, + * traditional Etherpad theme. + * - "colibris": the new experimental skin which became the default one since Etherpad 1.8. + */ + "skinName": "colibris", + /* // Node native SSL support // this is disabled by default From 8127cb317a3f7f81c288648a80f2faffa8c9aa3d Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 31 Mar 2020 23:42:31 +0200 Subject: [PATCH 23/42] Update settings.json to version 1.8.0 --- conf/settings.json | 402 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 311 insertions(+), 91 deletions(-) diff --git a/conf/settings.json b/conf/settings.json index 00fcf9c..432a3b9 100644 --- a/conf/settings.json +++ b/conf/settings.json @@ -1,45 +1,109 @@ /* - This file must be valid JSON. But comments are allowed - - Please edit settings.json, not settings.json.template - - To still commit settings without credentials you can - store any credential settings in credentials.json -*/ + * This file must be valid JSON. But comments are allowed + * + * Please edit settings.json, not settings.json.template + * + * Please note that starting from Etherpad 1.6.0 you can store DB credentials in + * a separate file (credentials.json). + * + * + * ENVIRONMENT VARIABLE SUBSTITUTION + * ================================= + * + * All the configuration values can be read from environment variables using the + * syntax "${ENV_VAR}" or "${ENV_VAR:default_value}". + * + * This is useful, for example, when running in a Docker container. + * + * EXAMPLE: + * "port": "${PORT:9001}" + * "minify": "${MINIFY}" + * "skinName": "${SKIN_NAME:colibris}" + * + * Would read the configuration values for those items from the environment + * variables PORT, MINIFY and SKIN_NAME. + * + * If PORT and SKIN_NAME variables were not defined, the default values 9001 and + * "colibris" would be used. + * The configuration value "minify", on the other hand, does not have a + * designated default value. Thus, if the environment variable MINIFY were + * undefined, "minify" would be null. + * + * REMARKS: + * 1) please note that variable substitution always needs to be quoted. + * + * "port": 9001, <-- Literal values. When not using + * "minify": false substitution, only strings must be + * "skinName": "colibris" quoted. Booleans and numbers must not. + * + * "port": "${PORT:9001}" <-- CORRECT: if you want to use a variable + * "minify": "${MINIFY:true}" substitution, put quotes around its name, + * "skinName": "${SKIN_NAME}" even if the required value is a number or + * a boolean. + * Etherpad will take care of rewriting it + * to the proper type if necessary. + * + * "port": ${PORT:9001} <-- ERROR: this is not valid json. Quotes + * "minify": ${MINIFY} around variable names are missing. + * "skinName": ${SKIN_NAME} + * + * 2) Beware of undefined variables and default values: nulls and empty strings + * are different! + * + * This is particularly important for user's passwords (see the relevant + * section): + * + * "password": "${PASSW}" // if PASSW is not defined would result in password === null + * "password": "${PASSW:}" // if PASSW is not defined would result in password === '' + * + */ { - // Name your instance! + /* + * Name your instance! + */ "title": "Etherpad Mypads", - // favicon default name - // alternatively, set up a fully specified Url to your own favicon + /* + * favicon default name + * alternatively, set up a fully specified Url to your own favicon + */ "favicon": "favicon.ico", - //IP and port which etherpad should bind at - "ip": "127.0.0.1", - "port" : __PORT__, - - // Option to hide/show the settings.json in admin page, default option is set to true - "showSettingsInAdminPage" : true, - -/* + /* * Skin name. * * Its value has to be an existing directory under src/static/skins. * You can write your own, or use one of the included ones: * - * - "no-skin": an empty skin (default before 1.8). This yields the unmodified, + * - "no-skin": an empty skin (default). This yields the unmodified, * traditional Etherpad theme. - * - "colibris": the new experimental skin which became the default one since Etherpad 1.8. + * - "colibris": the new experimental skin (since Etherpad 1.8), candidate to + * become the default in Etherpad 2.0 */ "skinName": "colibris", /* - // Node native SSL support - // this is disabled by default - // - // make sure to have the minimum and correct file access permissions set - // so that the Etherpad server can access them + * IP and port which etherpad should bind at + */ + "ip": "127.0.0.1", + "port" : __PORT__, + /* + * Option to hide/show the settings.json in admin page. + * + * Default option is set to true + */ + "showSettingsInAdminPage": true, + + /* + * Node native SSL support + * + * This is disabled by default. + * Make sure to have the minimum and correct file access permissions set so + * that the Etherpad server can access them + */ + + /* "ssl" : { "key" : "/path-to-your/epl-server.key", "cert" : "/path-to-your/epl-server.crt", @@ -47,21 +111,16 @@ }, */ - //The Type of the database. You can choose between dirty, postgres, sqlite and mysql - //You shouldn't use "dirty" for for anything else than testing or development - //"dbType" : "dirty", - //the database specific settings - //"dbSettings" : { - // "filename" : "var/dirty.db" - // }, - - /* An Example of MySQL Configuration */ -// Withdrawn and moved... - - //the default text of a pad + /* + * The default text of a pad + */ "defaultPadText" : "Welcome to Etherpad!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nGet involved with Etherpad at http:\/\/etherpad.org\n", - /* Default Pad behavior, users can override by changing */ + /* + * Default Pad behavior. + * + * Change them if you want to override. + */ "padOptions": { "noColors": false, "showControls": true, @@ -73,7 +132,35 @@ "rtl": false, "alwaysShowChat": false, "chatAndUsers": false, - "lang": "__LANGUAGE__", + "lang": "__LANGUAGE__", + + /* + * Pad Shortcut Keys + */ + "padShortcutEnabled" : { + "altF9": true, /* focus on the File Menu and/or editbar */ + "altC": true, /* focus on the Chat window */ + "cmdShift2": true, /* shows a gritter popup showing a line author */ + "delete": true, + "return": true, + "esc": true, /* in mozilla versions 14-19 avoid reconnecting pad */ + "cmdS": true, /* save a revision */ + "tab": true, /* indent */ + "cmdZ": true, /* undo/redo */ + "cmdY": true, /* redo */ + "cmdI": true, /* italic */ + "cmdB": true, /* bold */ + "cmdU": true, /* underline */ + "cmd5": true, /* strike through */ + "cmdShiftL": true, /* unordered list */ + "cmdShiftN": true, /* ordered list */ + "cmdShift1": true, /* ordered list */ + "cmdShiftC": true, /* clear authorship */ + "cmdH": true, /* backspace */ + "ctrlHome": true, /* scroll to top of pad */ + "pageUp": true, + "pageDown": true + }, // Plugins config // ep_automatic_logut @@ -123,70 +210,182 @@ //noldap } //noldap }, - /* Should we suppress errors from being visible in the default Pad Text? */ - "suppressErrorsInPadText" : false, + /* + * Should we suppress errors from being visible in the default Pad Text? + */ + "suppressErrorsInPadText": false, - /* Users must have a session to access pads. This effectively allows only group pads to be accessed. */ - "requireSession" : false, + /* + * If this option is enabled, a user must have a session to access pads. + * This effectively allows only group pads to be accessed. + */ + "requireSession": false, - /* Users may edit pads but not create new ones. Pad creation is only via the API. This applies both to group pads and regular pads. */ - "editOnly" : false, + /* + * Users may edit pads but not create new ones. + * + * Pad creation is only via the API. + * This applies both to group pads and regular pads. + */ + "editOnly": false, - /* Users, who have a valid session, automatically get granted access to password protected pads */ - "sessionNoPassword" : false, + /* + * If set to true, those users who have a valid session will automatically be + * granted access to password protected pads. + */ + "sessionNoPassword": false, - /* if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly, - but makes it impossible to debug the javascript/css */ - "minify" : true, + /* + * If true, all css & js will be minified before sending to the client. + * + * This will improve the loading performance massively, but makes it difficult + * to debug the javascript/css + */ + "minify": true, - /* How long may clients use served javascript code (in seconds)? Without versioning this - may cause problems during deployment. Set to 0 to disable caching */ - "maxAge" : 21600, // 60 * 60 * 6 = 6 hours + /* + * How long may clients use served javascript code (in seconds)? + * + * Not setting this may cause problems during deployment. + * Set to 0 to disable caching. + */ + "maxAge": 21600, // 60 * 60 * 6 = 6 hours - /* This is the absolute path to the Abiword executable. Setting it to null, disables abiword. - Abiword is needed to advanced import/export features of pads*/ + /* + * Absolute path to the Abiword executable. + * + * Abiword is needed to get advanced import/export features of pads. Setting + * it to null disables Abiword and will only allow plain text and HTML + * import/exports. + */ "abiword" : null, - /* This is the absolute path to the soffice executable. Setting it to null, disables LibreOffice exporting. - LibreOffice can be used in lieu of Abiword to export pads */ + /* + * This is the absolute path to the soffice executable. + * + * LibreOffice can be used in lieu of Abiword to export pads. + * Setting it to null disables LibreOffice exporting. + */ "soffice" : null, - /* This is the path to the Tidy executable. Setting it to null, disables Tidy. - Tidy is used to improve the quality of exported pads*/ - "tidyHtml" : null, + /* + * Path to the Tidy executable. + * + * Tidy is used to improve the quality of exported pads. + * Setting it to null disables Tidy. + */ + "tidyHtml": null, - /* Allow import of file types other than the supported types: txt, doc, docx, rtf, odt, html & htm */ - "allowUnknownFileEnds" : true, + /* + * Allow import of file types other than the supported ones: + * txt, doc, docx, rtf, odt, html & htm + */ + "allowUnknownFileEnds": true, - /* This setting is used if you require authentication of all users. - Note: /admin always requires authentication. */ - "requireAuthentication" : false, + /* + * This setting is used if you require authentication of all users. + * + * Note: "/admin" always requires authentication. + */ + "requireAuthentication": false, - /* Require authorization by a module, or a user with is_admin set, see below. */ - "requireAuthorization" : false, + /* + * Require authorization by a module, or a user with is_admin set, see below. + */ + "requireAuthorization": false, - /*when you use NginX or another proxy/ load-balancer set this to true*/ - "trustProxy" : false, + /* + * When you use NGINX or another proxy/load-balancer set this to true. + * + * This is especially necessary when the reverse proxy performs SSL + * termination, otherwise the cookies will not have the "secure" flag. + * + * The other effect will be that the logs will contain the real client's IP, + * instead of the reverse proxy's IP. + */ + "trustProxy": false, - /* Privacy: disable IP logging */ - "disableIPlogging" : false, + /* + * Privacy: disable IP logging + */ + "disableIPlogging": false, - /* Users for basic authentication. is_admin = true gives access to /admin. - If you do not uncomment this, /admin will not be available! */ -// Withdrawn and moved... + /* + * Time (in seconds) to automatically reconnect pad when a "Force reconnect" + * message is shown to user. + * + * Set to 0 to disable automatic reconnection. + */ + "automaticReconnectionTimeout": 0, - // restrict socket.io transport methods + /* + * By default, when caret is moved out of viewport, it scrolls the minimum + * height needed to make this line visible. + */ + "scrollWhenFocusLineIsOutOfViewport": { + + /* + * Percentage of viewport height to be additionally scrolled. + * + * E.g.: use "percentage.editionAboveViewport": 0.5, to place caret line in + * the middle of viewport, when user edits a line above of the + * viewport + * + * Set to 0 to disable extra scrolling + */ + "percentage": { + "editionAboveViewport": 0, + "editionBelowViewport": 0 + }, + + /* + * Time (in milliseconds) used to animate the scroll transition. + * Set to 0 to disable animation + */ + "duration": 0, + + /* + * Flag to control if it should scroll when user places the caret in the + * last line of the viewport + */ + "scrollWhenCaretIsInTheLastLineOfViewport": false, + + /* + * Percentage of viewport height to be additionally scrolled when user + * presses arrow up in the line of the top of the viewport. + * + * Set to 0 to let the scroll to be handled as default by Etherpad + */ + "percentageToScrollWhenUserPressesArrowUp": 0 + + /* + * Restrict socket.io transport methods + */ "socketTransportProtocols" : ["xhr-polling", "jsonp-polling", "htmlfile"], - // Allow Load Testing tools to hit the Etherpad Instance. Warning this will disable security on the instance. + /* + * Allow Load Testing tools to hit the Etherpad Instance. + * + * WARNING: this will disable security on the instance. + */ "loadTest": false, - // Disable indentation on new line when previous line ends with some special chars (':', '[', '(', '{') + /* + * Disable indentation on new line when previous line ends with some special + * chars (':', '[', '(', '{') + */ + /* "indentationOnNewLine": false, */ - /* The toolbar buttons configuration. + /* + * Toolbar buttons configuration. + * + * Uncomment to customize. + */ + + /* "toolbar": { "left": [ ["bold", "italic", "underline", "strikethrough"], @@ -205,38 +404,57 @@ }, */ - /* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */ + /* + * Expose Etherpad version in the web interface and in the Server http header. + * + * Do not enable on production machines. + */ + "exposeVersion": false, + + /* + * The log level we are using. + * + * Valid values: DEBUG, INFO, WARN, ERROR + */ "loglevel": "INFO", - //Logging configuration. See log4js documentation for further information - // https://github.com/nomiddlename/log4js-node - // You can add as many appenders as you want here: + /* + * Logging configuration. See log4js documentation for further information: + * https://github.com/nomiddlename/log4js-node + * + * You can add as many appenders as you want here. + */ "logconfig" : { "appenders": [ { "type": "console" //, "category": "access"// only logs pad access } - /* + + /* , { "type": "file" , "filename": "your-log-file-here.log" , "maxLogSize": 1024 , "backups": 3 // how many log files there're gonna be at max //, "category": "test" // only log a specific category - }*/ - /* + } + */ + + /* , { "type": "logLevelFilter" , "level": "warn" // filters out all log messages that have a lower level than "error" , "appender": { Use whatever appender you want here } - }*/ - /* + } + */ + + /* , { "type": "logLevelFilter" , "level": "error" // filters out all log messages that have a lower level than "error" , "appender": { "type": "smtp" - , "subject": "An error occured in your EPL instance!" + , "subject": "An error occurred in your EPL instance!" , "recipients": "bar@blurdybloop.com, baz@blurdybloop.com" - , "sendInterval": 60*5 // in secs -- will buffer log messages; set to 0 to send a mail for every message + , "sendInterval": 300 // 60 * 5 = 5 minutes -- will buffer log messages; set to 0 to send a mail for every message , "transport": "SMTP", "SMTP": { // see https://github.com/andris9/Nodemailer#possible-transport-methods "host": "smtp.example.com", "port": 465, "secureConnection": true, @@ -246,7 +464,9 @@ } } } - }*/ + } + */ + ] - } + } // logconfig } From ce0759d0adf58df0beaea73c46839c486b26b9c6 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 31 Mar 2020 23:42:47 +0200 Subject: [PATCH 24/42] Update credential.json to version 1.8.0 --- conf/credentials.json | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/conf/credentials.json b/conf/credentials.json index 80c3c52..02cc320 100644 --- a/conf/credentials.json +++ b/conf/credentials.json @@ -2,8 +2,23 @@ This file must be valid JSON. But comments are allowed */ { - //The Type of the database. You can choose between dirty, postgres, sqlite and mysql - //You shouldn't use "dirty" for for anything else than testing or development }, + /* + * The type of the database. + * + * You can choose between many DB drivers, for example: dirty, postgres, + * sqlite, mysql. + * + * You shouldn't use "dirty" for for anything else than testing or + * development. + * + * + * Database specific settings are dependent on dbType, and go in dbSettings. + * Remember that since Etherpad 1.6.0 you can also store these informations in + * credentials.json. + * + * For a complete list of the supported drivers, please refer to: + * https://www.npmjs.com/package/ueberdb2 + */ /* An Example of MySQL Configuration */ "dbType" : "mysql", @@ -15,10 +30,20 @@ "charset" : "utf8mb4" }, - /* Users for basic authentication. is_admin = true gives access to /admin. - If you do not uncomment this, /admin will not be available! */ + /* + * Users for basic authentication. + * + * is_admin = true gives access to /admin. + * If you do not uncomment this, /admin will not be available! + * + * WARNING: passwords should not be stored in plaintext in this file. + * If you want to mitigate this, please install ep_hash_auth and + * follow the section "secure your installation" in README.md + */ "users": { "__ADMIN__": { + // 1) "password" can be replaced with "hash" if you install ep_hash_auth + // 2) please note that if password is null, the user will not be created "password": "__PASSWD__", "is_admin": true } From 43416d728230788aecbf2eaa1c5f23380123daef Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 1 Apr 2020 00:27:36 +0200 Subject: [PATCH 25/42] Fix settings.json syntax That little nasty one was fucking tricky ! --- conf/settings.json | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/settings.json b/conf/settings.json index 432a3b9..1acac24 100644 --- a/conf/settings.json +++ b/conf/settings.json @@ -357,6 +357,7 @@ * Set to 0 to let the scroll to be handled as default by Etherpad */ "percentageToScrollWhenUserPressesArrowUp": 0 +}, /* * Restrict socket.io transport methods From 46b50b32e58edfb74c143fe5a50362629294f50b Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 1 Apr 2020 13:02:30 +0200 Subject: [PATCH 26/42] Show a link to mypads only if installed --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 34c9859..b582c60 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -369,7 +369,7 @@ fi # SOME HACKS #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] +if [ "$upgrade_type" == "UPGRADE_APP" ] && [ $mypads -eq 1 ] then # Find the /div just after the field to open a pad mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "" | cut -d '-' -f 1) From 383b45fb963568bd3caf76df26053d96555d4c0a Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 2 Apr 2020 00:46:19 +0200 Subject: [PATCH 27/42] Fix plugin issue --- scripts/upgrade | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 34c9859..6260296 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -223,6 +223,8 @@ ynh_script_progression --message="Upgrading Etherpad npm modules..." --weight=60 chown -R $app: $final_path (cd "$final_path/src" ynh_exec_warn_less npm cache clean --force +# Remove package-lock.json to prevent any shit during npm update... +ynh_secure_remove --file="$final_path/src/package-lock.json" ynh_exec_warn_less ynh_exec_as $app PATH="$nodejs_path:$PATH" "$nodejs_path/npm" update) # Then update the additionnal modules From fb6b94bbddea6fba9757a79f25538a4b0fc7a318 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 9 Apr 2020 18:34:33 +0200 Subject: [PATCH 28/42] Add new badges --- README.md | 4 ++-- README_fr.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8ddf8cd..0869d59 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Etherpad with mypads plugin for YunoHost -[![Integration level](https://dash.yunohost.org/integration/etherpad_mypads.svg)](https://dash.yunohost.org/appci/app/etherpad_mypads) +[![Integration level](https://dash.yunohost.org/integration/etherpad_mypads.svg)](https://dash.yunohost.org/appci/app/etherpad_mypads) ![](https://ci-apps.yunohost.org/ci/badges/etherpad_mypads.status.svg) [![](https://ci-apps.yunohost.org/ci/badges/etherpad_mypads.maintain.svg)](https://github.com/YunoHost/Apps/#what-to-do-if-i-cant-maintain-my-app-anymore-) [![Install Etherpad with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=etherpad_mypads) *[Lire ce readme en français.](./README_fr.md)* @@ -42,7 +42,7 @@ Supported, with LDAP. * x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/etherpad_mypads%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/etherpad_mypads/) * ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/etherpad_mypads%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/etherpad_mypads/) -* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/etherpad_mypads%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/etherpad_mypads/) +* Buster x86-64b - [![](https://ci-buster.nohost.me/ci/logs/etherpad_mypads%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/etherpad_mypads/) ## Limitations diff --git a/README_fr.md b/README_fr.md index b192165..b19547f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,6 +1,6 @@ # Etherpad avec plugin mypads pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/etherpad_mypads.svg)](https://dash.yunohost.org/appci/app/etherpad_mypads) +[![Niveau d'intégration](https://dash.yunohost.org/integration/etherpad_mypads.svg)](https://dash.yunohost.org/appci/app/etherpad_mypads) ![](https://ci-apps.yunohost.org/ci/badges/etherpad_mypads.status.svg) [![](https://ci-apps.yunohost.org/ci/badges/etherpad_mypads.maintain.svg)](https://github.com/YunoHost/Apps/#what-to-do-if-i-cant-maintain-my-app-anymore-) [![Installer Etherpad avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=etherpad_mypads) *[Read this readme in english.](./README.md)* @@ -42,7 +42,7 @@ Supportée, avec LDAP. * x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/etherpad_mypads%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/etherpad_mypads/) * ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/etherpad_mypads%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/etherpad_mypads/) -* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/etherpad_mypads%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/etherpad_mypads/) +* Buster x86-64b - [![](https://ci-buster.nohost.me/ci/logs/etherpad_mypads%20%28Apps%29.svg)](https://ci-buster.nohost.me/ci/apps/etherpad_mypads/) ## Limitations From 28adea148e840f4d703fdd64a3e69861a569a03e Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 9 Apr 2020 18:37:53 +0200 Subject: [PATCH 29/42] Actions and config_panel tests --- check_process | 22 ++++++++++++++- scripts/actions/add_remove_abiword | 15 +++++++--- scripts/actions/add_remove_libreoffice | 15 +++++++--- scripts/actions/list_all_pads | 7 +++++ scripts/actions/public_private | 7 +++++ scripts/actions/reset_default_config | 7 +++++ scripts/config | 38 ++++++++++++++++++++++---- 7 files changed, 96 insertions(+), 15 deletions(-) diff --git a/check_process b/check_process index 48636c3..e0162f6 100644 --- a/check_process +++ b/check_process @@ -9,6 +9,24 @@ export="libreoffice" mypads=1 useldap=1 + ; Actions + is_public=0|1 + ; Config_panel + main.export.export=none|abiword|libreoffice + main.pad_configuration.pad_config_nocolors=1|0 + main.pad_configuration.pad_config_showlinenumbers=0|1 + main.pad_configuration.pad_config_chatandusers=1|0 + main.pad_configuration.pad_config_alwaysshowchat=1|0 + main.pad_configuration.pad_config_show_markdown=1|0 + main.pad_configuration.pad_config_pageview=1|0 + main.pad_configuration.pad_config_automatic_logout=0|1 + main.mypads_configuration.mypads=0|1 + main.mypads_configuration.useldap=0|1 + main.is_public.is_public=1|0 + main.overwrite_files.overwrite_settings=0|1 + main.overwrite_files.overwrite_credentials=0|1 + main.overwrite_files.overwrite_nginx=0|1 + main.overwrite_files.overwrite_systemd=0|1 ; Checks pkg_linter=1 setup_sub_dir=1 @@ -21,6 +39,8 @@ multi_instance=0 port_already_use=1 (9001) change_url=1 + actions=1 + config_panel=1 ;; Test sans mypads ; Manifest domain="domain.tld" (DOMAIN) @@ -68,7 +88,7 @@ Level 5=auto ;;; Options Email= -Notification=down +Notification=change ;;; Upgrade options ; commit=8bf300413ec3adcb416d168d2e9e98975dd9405b name= Fix nodejs & global update diff --git a/scripts/actions/add_remove_abiword b/scripts/actions/add_remove_abiword index 1ae79da..a3b388d 100755 --- a/scripts/actions/add_remove_abiword +++ b/scripts/actions/add_remove_abiword @@ -9,6 +9,13 @@ source scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # RETRIEVE ARGUMENTS #================================================= @@ -29,14 +36,14 @@ then # abiword is already a dependence of etherpad_mypads. # abiword should be removed. abiword=0 - action1=installed - action2=Installing + action1=removed + action2=Removing else # abiword isn't a dependence of etherpad_mypads. # abiword should be installed. abiword=1 - action1=removed - action2=Removing + action1=installed + action2=Installing fi ynh_print_info --message="Abiword will be $action1." diff --git a/scripts/actions/add_remove_libreoffice b/scripts/actions/add_remove_libreoffice index ec1dc59..13c4091 100755 --- a/scripts/actions/add_remove_libreoffice +++ b/scripts/actions/add_remove_libreoffice @@ -9,6 +9,13 @@ source scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # RETRIEVE ARGUMENTS #================================================= @@ -29,14 +36,14 @@ then # libreoffice is already a dependence of etherpad_mypads. # libreoffice should be removed. libreoffice=0 - action1=installed - action2=Installing + action1=removed + action2=Removing else # libreoffice isn't a dependence of etherpad_mypads. # libreoffice should be installed. libreoffice=1 - action1=removed - action2=Removing + action1=installed + action2=Installing fi ynh_print_info --message="Libreoffice will be $action1." diff --git a/scripts/actions/list_all_pads b/scripts/actions/list_all_pads index 7142b64..c2029e1 100755 --- a/scripts/actions/list_all_pads +++ b/scripts/actions/list_all_pads @@ -9,6 +9,13 @@ source scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # RETRIEVE ARGUMENTS #================================================= diff --git a/scripts/actions/public_private b/scripts/actions/public_private index f8ccebb..3622632 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -8,6 +8,13 @@ source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # RETRIEVE ARGUMENTS #================================================= diff --git a/scripts/actions/reset_default_config b/scripts/actions/reset_default_config index a643228..c4e280e 100755 --- a/scripts/actions/reset_default_config +++ b/scripts/actions/reset_default_config @@ -9,6 +9,13 @@ source scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # RETRIEVE ARGUMENTS #================================================= diff --git a/scripts/config b/scripts/config index d8076de..05893e3 100644 --- a/scripts/config +++ b/scripts/config @@ -6,11 +6,12 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh -source /usr/share/yunohost/helpers # Load common variables for all scripts. source _variables +source _common.sh +source /usr/share/yunohost/helpers + #================================================= # RETRIEVE ARGUMENTS #================================================= @@ -157,6 +158,11 @@ show_config() { #================================================= apply_config() { + + #================================================= + # MODIFY ETHERPAD CONFIG + #================================================= + restart_etherpad=0 # Change configuration if needed @@ -245,6 +251,9 @@ apply_config() { ynh_replace_string --match_string="\(\"abiword\" *: \).*," --replace_string="\1null," --target_file="$config_file" ynh_replace_string --match_string="\(\"soffice\" *: \).*," --replace_string="\1null," --target_file="$config_file" fi + + ynh_app_setting_set --app=$app --key=export --value="$export" + restart_etherpad=1 fi @@ -261,6 +270,9 @@ apply_config() { fi popd chown -R $app: $final_path/node_modules + + ynh_app_setting_set --app=$app --key=mypads --value="$mypads" + restart_etherpad=1 fi @@ -273,6 +285,9 @@ apply_config() { else ynh_replace_string --match_string="\(.*\) //useldap" --replace_string="//noldap\1" --target_file="$final_path/settings.json" fi + + ynh_app_setting_set --app=$app --key=useldap --value="$useldap" + restart_etherpad=1 fi @@ -283,14 +298,25 @@ apply_config() { ynh_systemd_action --action=restart --line_match="You can access your Etherpad instance at" --log_path="/var/log/$app/etherpad.log" --timeout="120" fi + #================================================= + # MODIFY PUBLIC ACCESSIBILITY + #================================================= + # Change public accessibility - if [ "$is_public" = "1" ] + if [ "$is_public" != "$old_is_public" ] then - yunohost app action run $app public_private --args is_public=1 - else - yunohost app action run $app public_private --args is_public=0 + if [ "$is_public" = "1" ] + then + yunohost app action run $app public_private --args is_public=1 + else + yunohost app action run $app public_private --args is_public=0 + fi fi + #================================================= + # MODIFY OVERWRITTING SETTINGS + #================================================= + # Set overwrite_settings ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings" # Set overwrite_credentials From 3d67b528aa403fa1dbd9b5b505d853fd73054078 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 9 Apr 2020 18:38:07 +0200 Subject: [PATCH 30/42] Linter fix --- manifest.json | 2 +- scripts/install | 5 +++-- scripts/restore | 5 +++-- scripts/upgrade | 5 +++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/manifest.json b/manifest.json index b0f63b9..139ef45 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "maniackc_dev@crudelis.fr" }, "requirements": { - "yunohost": ">= 3.5" + "yunohost": ">= 3.6" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 92fd0b1..898911d 100644 --- a/scripts/install +++ b/scripts/install @@ -6,11 +6,12 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh -source /usr/share/yunohost/helpers # Load common variables for all scripts. source _variables +source _common.sh +source /usr/share/yunohost/helpers + #================================================= # MANAGE FAILURE OF THE SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 24c6f93..619f0e4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,11 +6,12 @@ # IMPORT GENERIC HELPERS #================================================= -source ../settings/scripts/_common.sh -source /usr/share/yunohost/helpers # Load common variables for all scripts. source ../settings/scripts/_variables +source ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + #================================================= # MANAGE SCRIPT FAILURE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b582c60..1cf16af 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,11 +6,12 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh -source /usr/share/yunohost/helpers # Load common variables for all scripts. source _variables +source _common.sh +source /usr/share/yunohost/helpers + #================================================= # LOAD SETTINGS #================================================= From a0689eb7adde93f8adaeae386129a63a190543a2 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 29 Apr 2020 17:08:02 +0200 Subject: [PATCH 31/42] Update scripts/actions/add_remove_abiword Co-Authored-By: Kayou --- scripts/actions/add_remove_abiword | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/actions/add_remove_abiword b/scripts/actions/add_remove_abiword index a3b388d..52d8325 100755 --- a/scripts/actions/add_remove_abiword +++ b/scripts/actions/add_remove_abiword @@ -20,7 +20,7 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS #================================================= -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF ARGUMENTS ARE CORRECT From 6fb0ac9730492a8908cd9954133cf952175f81a3 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 29 Apr 2020 17:08:20 +0200 Subject: [PATCH 32/42] Update scripts/actions/add_remove_libreoffice Co-Authored-By: Kayou --- scripts/actions/add_remove_libreoffice | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/actions/add_remove_libreoffice b/scripts/actions/add_remove_libreoffice index 13c4091..55e158d 100755 --- a/scripts/actions/add_remove_libreoffice +++ b/scripts/actions/add_remove_libreoffice @@ -20,7 +20,7 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS #================================================= -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF ARGUMENTS ARE CORRECT From ec7aafcd9c266a43aa0127a981599181277bb464 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 29 Apr 2020 17:08:34 +0200 Subject: [PATCH 33/42] Update scripts/actions/list_all_pads Co-Authored-By: Kayou --- scripts/actions/list_all_pads | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/actions/list_all_pads b/scripts/actions/list_all_pads index c2029e1..9c10137 100755 --- a/scripts/actions/list_all_pads +++ b/scripts/actions/list_all_pads @@ -20,7 +20,7 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS #================================================= -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +app=$YNH_APP_INSTANCE_NAME db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) From 04e8a4b5de2461775d9b14a788f49d8f18fd5515 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 29 Apr 2020 17:09:43 +0200 Subject: [PATCH 34/42] Update scripts/actions/public_private Co-Authored-By: Kayou --- scripts/actions/public_private | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/actions/public_private b/scripts/actions/public_private index 3622632..2c33aed 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -22,7 +22,7 @@ ynh_abort_if_errors # Get is_public is_public=${YNH_ACTION_IS_PUBLIC} -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF ARGUMENTS ARE CORRECT From f7cb019e99b02186134c93de996e6f5a03dabcf3 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 29 Apr 2020 17:09:57 +0200 Subject: [PATCH 35/42] Update scripts/config Co-Authored-By: Kayou --- scripts/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config b/scripts/config index 05893e3..009ce75 100644 --- a/scripts/config +++ b/scripts/config @@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get $app final_path) From 4a55c83af7ce49d0271d9ceff7b5bb2dc187fe94 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 29 Apr 2020 17:10:30 +0200 Subject: [PATCH 36/42] Update scripts/actions/reset_default_config Co-Authored-By: Kayou --- scripts/actions/reset_default_config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/actions/reset_default_config b/scripts/actions/reset_default_config index c4e280e..d6b9782 100755 --- a/scripts/actions/reset_default_config +++ b/scripts/actions/reset_default_config @@ -20,7 +20,7 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS #================================================= -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} +app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) From 43d0f4f66bcab63d399a32a2bc155bdce9548d84 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 29 Apr 2020 17:12:04 +0200 Subject: [PATCH 37/42] Update scripts/config Co-Authored-By: Kayou --- scripts/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config b/scripts/config index 009ce75..c8f3934 100644 --- a/scripts/config +++ b/scripts/config @@ -252,7 +252,7 @@ apply_config() { ynh_replace_string --match_string="\(\"soffice\" *: \).*," --replace_string="\1null," --target_file="$config_file" fi - ynh_app_setting_set --app=$app --key=export --value="$export" + ynh_app_setting_set --app=$app --key=export --value="$export" restart_etherpad=1 fi From daa1ba1975b9e615edf7a6df374aa5a00b4dfc8a Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 29 Apr 2020 17:13:58 +0200 Subject: [PATCH 38/42] Apply suggestions from code review Co-Authored-By: Kayou --- scripts/config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/config b/scripts/config index c8f3934..7b8fc00 100644 --- a/scripts/config +++ b/scripts/config @@ -271,7 +271,7 @@ apply_config() { popd chown -R $app: $final_path/node_modules - ynh_app_setting_set --app=$app --key=mypads --value="$mypads" + ynh_app_setting_set --app=$app --key=mypads --value="$mypads" restart_etherpad=1 fi @@ -286,7 +286,7 @@ apply_config() { ynh_replace_string --match_string="\(.*\) //useldap" --replace_string="//noldap\1" --target_file="$final_path/settings.json" fi - ynh_app_setting_set --app=$app --key=useldap --value="$useldap" + ynh_app_setting_set --app=$app --key=useldap --value="$useldap" restart_etherpad=1 fi From d94a1d36783b2723b77ee104b327c6997c942d5e Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 29 Apr 2020 20:38:08 +0200 Subject: [PATCH 39/42] Fix comments and helper usage --- scripts/actions/list_all_pads | 9 ++++++++- scripts/actions/reset_default_config | 12 ++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/actions/list_all_pads b/scripts/actions/list_all_pads index 9c10137..782a93c 100755 --- a/scripts/actions/list_all_pads +++ b/scripts/actions/list_all_pads @@ -41,7 +41,14 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_script_progression --message="Listing all pads..." --weight=3 -mysql -u $db_name -p$db_pwd $db_name --silent -e 'select distinct substring(store.key,5,locate(":",store.key,5)-5) as "pads" from store where store.key like "pad:%"' | sed 's/^/>> /g' >&2 +# Get the list of pads from the database +pad_list="$(ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name <<< \ + "select distinct substring(store.key,5,locate(\":\",store.key,5)-5) as \"pads\" from store where store.key like \"pad:%\"")" + +# Remove empty lines +# Name the first line "> List of pads" +# Then for the second lines and following, add >> before the name of the pad. +ynh_print_info --message="$(echo "$pad_list" | sed '/^$/d' | sed '1 s/^/> List of /' | sed '2,$s/^/>> /g')" #================================================= # END OF SCRIPT diff --git a/scripts/actions/reset_default_config b/scripts/actions/reset_default_config index d6b9782..19936da 100755 --- a/scripts/actions/reset_default_config +++ b/scripts/actions/reset_default_config @@ -58,12 +58,16 @@ then ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/settings.json" if [ "$export" = "abiword" ] then - abiword_path=`which abiword` # Get abiword binary path - ynh_replace_string --match_string="\"abiword\" : null" --replace_string="\"abiword\" : \"$abiword_path\"" --target_file="$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + # Get abiword binary path + abiword_path=`which abiword` + # Set the path of abiword into etherpad config + ynh_replace_string --match_string="\"abiword\" : null" --replace_string="\"abiword\" : \"$abiword_path\"" --target_file="$final_path/settings.json" elif [ "$export" = "libreoffice" ] then - soffice_path=`which soffice` # Get soffice binary path - ynh_replace_string --match_string="\"soffice\" : null" --replace_string="\"soffice\" : \"$soffice_path\"" --target_file="$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad + # Get soffice binary path + soffice_path=`which soffice` + # Set the path of soffice into etherpad config + ynh_replace_string --match_string="\"soffice\" : null" --replace_string="\"soffice\" : \"$soffice_path\"" --target_file="$final_path/settings.json" fi ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/settings.json" From 242cddbc23c0f3dd7c24a452b9eb6776a2e12470 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 29 Apr 2020 23:13:58 +0200 Subject: [PATCH 40/42] Do not use the new kikoolol theme... --- check_process | 1 + conf/settings.json | 2 +- config_panel.toml | 6 ++++++ scripts/config | 24 +++++++++++++++++++++++- scripts/upgrade | 4 ++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index e0162f6..f159030 100644 --- a/check_process +++ b/check_process @@ -20,6 +20,7 @@ main.pad_configuration.pad_config_show_markdown=1|0 main.pad_configuration.pad_config_pageview=1|0 main.pad_configuration.pad_config_automatic_logout=0|1 + main.pad_configuration.pad_config_skinname=noskin|colibris|noskin main.mypads_configuration.mypads=0|1 main.mypads_configuration.useldap=0|1 main.is_public.is_public=1|0 diff --git a/conf/settings.json b/conf/settings.json index 1acac24..ffadc04 100644 --- a/conf/settings.json +++ b/conf/settings.json @@ -80,7 +80,7 @@ * - "colibris": the new experimental skin (since Etherpad 1.8), candidate to * become the default in Etherpad 2.0 */ - "skinName": "colibris", + "skinName": "no-skin", /* * IP and port which etherpad should bind at diff --git a/config_panel.toml b/config_panel.toml index ea7beec..3581e21 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -52,6 +52,12 @@ name = "Etherpad configuration" type = "boolean" default = true + [main.pad_configuration.pad_config_skinname] + ask = "Theme Name" + choices = ["noskin", "colibris"] + default = "noskin" + help = "noskin is the traditional Etherpad theme. colibris is the new theme." + [main.mypads_configuration] name = "Mypads configuration" diff --git a/scripts/config b/scripts/config index 7b8fc00..44a4878 100644 --- a/scripts/config +++ b/scripts/config @@ -31,7 +31,7 @@ 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 + grep "^ *\"$option_name\" *:" "$config_file" | cut -d':' -f2 | sed s'/[ \"]//g' | cut -d',' -f1 } #================================================= @@ -82,6 +82,16 @@ else fi pad_config_automatic_logout="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_AUTOMATIC_LOGOUT:-$old_pad_config_automatic_logout}" +# Etherpad skin +old_pad_config_skinname="$(get_config_value skinName)" +if [ "$old_pad_config_skinname" = "no-skin" ]; then + old_pad_config_skinname=noskin +fi +pad_config_skinname="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SKINNAME:-$old_pad_config_skinname}" +if [ "$pad_config_skinname" = "no-skin" ]; then + pad_config_skinname=noskin +fi + # Mypads if [ -d $final_path/node_modules/ep_mypads ] then @@ -141,6 +151,7 @@ show_config() { ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SHOW_MARKDOWN=$pad_config_show_markdown" ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_PAGEVIEW=$pad_config_pageview" ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_AUTOMATIC_LOGOUT=$pad_config_automatic_logout" + ynh_return "YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SKINNAME=$pad_config_skinname" ynh_return "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS=$mypads" ynh_return "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP=$useldap" @@ -226,6 +237,17 @@ apply_config() { restart_etherpad=1 fi + # Plugin option ep_page_view_default + if [ "$pad_config_skinname" != "$old_pad_config_skinname" ] + then + if [ "$pad_config_skinname" = "noskin" ]; then + pad_config_skinname="no-skin" + fi + ynh_replace_string --match_string="\( *\"skinName\" *: \).*," --replace_string="\1\"$pad_config_skinname\"," --target_file="$config_file" + ynh_app_setting_set --app=$app --key=pad_config_skinname --value="$pad_config_skinname" + restart_etherpad=1 + fi + # Export if [ "$export" != "$old_export" ] then diff --git a/scripts/upgrade b/scripts/upgrade index 30ee27f..dfb880d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -41,6 +41,7 @@ pad_config_showlinenumbers=$(ynh_app_setting_get --app=$app --key=pad_config_sho pad_config_chatandusers=$(ynh_app_setting_get --app=$app --key=pad_config_chatandusers) pad_config_alwaysshowchat=$(ynh_app_setting_get --app=$app --key=pad_config_alwaysshowchat) pad_config_show_markdown=$(ynh_app_setting_get --app=$app --key=pad_config_show_markdown) +pad_config_skinname=$(ynh_app_setting_get --app=$app --key=pad_config_skinname) #================================================= # CHECK VERSION @@ -298,6 +299,9 @@ then if [ -n "$pad_config_show_markdown" ]; then ynh_replace_string --match_string="\(\"ep_markdown_default\" *: \).*," --replace_string="\1$pad_config_show_markdown," --target_file="$final_path/settings.json" fi + if [ -n "$pad_config_skinname" ]; then + ynh_replace_string --match_string="\(\"skinName\" *: \).*," --replace_string="\1\"$pad_config_skinname\"," --target_file="$final_path/settings.json" + fi # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$final_path/settings.json" From 934c2f4a5d5781afb1851cd41915c7113a891e19 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 29 Apr 2020 23:21:25 +0200 Subject: [PATCH 41/42] Update CHANGELOG.md --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 281fba3..77e41fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,13 @@ Changelog * [Add actions and config-panel](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/49) * [Add changelog](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/76) +#### Fixed +- [Show a link to mypads only if installed](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/74/commits/46b50b32e58edfb74c143fe5a50362629294f50b) + #### Changed * [Upgrade to 1.8.0](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/78) - +* [Update to mypads 1.7.10](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/74/commits/00060c99db7f0fcac57c910256a37b6deeb8c2fe) +* [Allow to enable or disable automatic logout](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/74/commits/fdc8d6cbdd8eb0931336311d53857dad7f966d93) ## [1.7.5~ynh2](https://github.com/YunoHost-Apps/etherpad_mypads_ynh/pull/69) - 2019-05-26 From f6a4fd1a947cef2100f22634e72babdb45028953 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 30 Apr 2020 20:22:21 +0200 Subject: [PATCH 42/42] Disable ep_automatic_logut in config --- scripts/config | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/config b/scripts/config index 44a4878..7604af9 100644 --- a/scripts/config +++ b/scripts/config @@ -228,12 +228,18 @@ apply_config() { # Plugin option ep_automatic_logut if [ "$pad_config_automatic_logout" != "$old_pad_config_automatic_logout" ] then + ynh_use_nodejs + pushd "$final_path" if [ "$pad_config_automatic_logout" = "0" ] then ynh_replace_string --match_string="^\(.*\"automatic_logut.*$\)" --replace_string="\/\/\1" --target_file="$config_file" + npm uninstall ep_automatic_logut else ynh_replace_string --match_string="^\/\/\(.*\"automatic_logut.*$\)" --replace_string="\1" --target_file="$config_file" + npm install ep_automatic_logut fi + popd + chown -R $app: $final_path/node_modules restart_etherpad=1 fi