1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/etherpad_mypads_ynh.git synced 2024-09-03 18:36:09 +02:00

Merge pull request #84 from YunoHost-Apps/automatic_logout

Allow to enable or disable automatic logout
This commit is contained in:
Maniack Crudelis 2020-03-18 11:57:29 +01:00 committed by GitHub
commit 8889b6aab5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 11 deletions

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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 "</div>" | cut -d '-' -f 1)