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:
commit
8889b6aab5
4 changed files with 42 additions and 11 deletions
|
@ -66,7 +66,6 @@
|
||||||
// Plugins config
|
// Plugins config
|
||||||
// ep_automatic_logut
|
// ep_automatic_logut
|
||||||
"automatic_logut_mins_show" : true, // Show logout time selector
|
"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
|
"automatic_logut_url" : "../../", // Redirection URL address
|
||||||
|
|
||||||
// ep_markdown
|
// ep_markdown
|
||||||
|
|
|
@ -47,6 +47,11 @@ name = "Etherpad configuration"
|
||||||
type = "boolean"
|
type = "boolean"
|
||||||
default = false
|
default = false
|
||||||
|
|
||||||
|
[main.pad_configuration.pad_config_automatic_logout]
|
||||||
|
ask = "Automatic logout"
|
||||||
|
type = "boolean"
|
||||||
|
default = true
|
||||||
|
|
||||||
|
|
||||||
[main.mypads_configuration]
|
[main.mypads_configuration]
|
||||||
name = "Mypads configuration"
|
name = "Mypads configuration"
|
||||||
|
|
|
@ -31,7 +31,6 @@ get_config_value() {
|
||||||
option_name="$1"
|
option_name="$1"
|
||||||
# Get the value of this option in the config file
|
# 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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -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)"
|
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}"
|
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
|
# Mypads
|
||||||
if [ -d $final_path/node_modules/ep_mypads ]
|
if [ -d $final_path/node_modules/ep_mypads ]
|
||||||
then
|
then
|
||||||
old_mypads=true
|
# Enable
|
||||||
|
old_mypads=1
|
||||||
else
|
else
|
||||||
old_mypads=false
|
# Disable
|
||||||
|
old_mypads=0
|
||||||
fi
|
fi
|
||||||
mypads="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS:-$old_mypads}"
|
mypads="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_MYPADS:-$old_mypads}"
|
||||||
|
|
||||||
# Ldap for Mypads
|
# Ldap for Mypads
|
||||||
if grep -q "//noldap" $config_file
|
if grep -q "//noldap" $config_file
|
||||||
then
|
then
|
||||||
old_useldap=false
|
# Disable
|
||||||
|
old_useldap=0
|
||||||
else
|
else
|
||||||
old_useldap=true
|
# Enable
|
||||||
|
old_useldap=1
|
||||||
fi
|
fi
|
||||||
useldap="${YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP:-$old_useldap}"
|
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_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_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_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_MYPADS=$mypads"
|
||||||
ynh_return "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP=$useldap"
|
ynh_return "YNH_CONFIG_MAIN_MYPADS_CONFIGURATION_USELDAP=$useldap"
|
||||||
|
@ -188,11 +203,23 @@ apply_config() {
|
||||||
# Plugin option ep_page_view_default
|
# Plugin option ep_page_view_default
|
||||||
if [ "$pad_config_pageview" != "$old_pad_config_pageview" ]
|
if [ "$pad_config_pageview" != "$old_pad_config_pageview" ]
|
||||||
then
|
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"
|
ynh_app_setting_set --app=$app --key=pad_config_pageview --value="$pad_config_pageview"
|
||||||
restart_etherpad=1
|
restart_etherpad=1
|
||||||
fi
|
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
|
# Export
|
||||||
if [ "$export" != "$old_export" ]
|
if [ "$export" != "$old_export" ]
|
||||||
then
|
then
|
||||||
|
@ -226,7 +253,7 @@ apply_config() {
|
||||||
then
|
then
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
pushd "$final_path"
|
pushd "$final_path"
|
||||||
if [ "$mypads" = "true" ]
|
if [ "$mypads" = "1" ]
|
||||||
then
|
then
|
||||||
npm install ep_mypads@${mypads_version}
|
npm install ep_mypads@${mypads_version}
|
||||||
else
|
else
|
||||||
|
@ -240,7 +267,7 @@ apply_config() {
|
||||||
# Ldap for Mypads
|
# Ldap for Mypads
|
||||||
if [ "$useldap" != "$old_useldap" ]
|
if [ "$useldap" != "$old_useldap" ]
|
||||||
then
|
then
|
||||||
if [ "$useldap" = "true" ]
|
if [ "$useldap" = "1" ]
|
||||||
then
|
then
|
||||||
ynh_replace_string --match_string="//noldap\(.*\)" --replace_string="\1 //useldap" --target_file="$final_path/settings.json"
|
ynh_replace_string --match_string="//noldap\(.*\)" --replace_string="\1 //useldap" --target_file="$final_path/settings.json"
|
||||||
else
|
else
|
||||||
|
@ -253,7 +280,7 @@ apply_config() {
|
||||||
if [ $restart_etherpad -eq 1 ]
|
if [ $restart_etherpad -eq 1 ]
|
||||||
then
|
then
|
||||||
# Wait for etherpad to be fully started
|
# 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
|
fi
|
||||||
|
|
||||||
# Change public accessibility
|
# Change public accessibility
|
||||||
|
|
|
@ -369,7 +369,7 @@ fi
|
||||||
# SOME HACKS
|
# SOME HACKS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ $mypads -eq 1 ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
# Find the /div just after the field to open a pad
|
# 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)
|
mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "</div>" | cut -d '-' -f 1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue