mirror of
https://github.com/YunoHost-Apps/etherpad_mypads_ynh.git
synced 2024-09-03 18:36:09 +02:00
Merge branch 'add_actions_config' into testing
This commit is contained in:
commit
5899a0d69d
11 changed files with 1085 additions and 47 deletions
64
actions.json
Normal file
64
actions.json
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
[{
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
119
config_panel.json
Normal file
119
config_panel.json
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
{
|
||||||
|
"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:<br>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
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -22,6 +22,24 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
|
||||||
fi
|
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
|
# FUTUR OFFICIAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -30,6 +48,120 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
|
||||||
# EXPERIMENTAL HELPERS
|
# 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
|
# Send an email to inform the administrator
|
||||||
#
|
#
|
||||||
# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
|
# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
|
||||||
|
|
94
scripts/actions/add_remove_abiword
Executable file
94
scripts/actions/add_remove_abiword
Executable file
|
@ -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_INSTANCE_NAME:-$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
|
94
scripts/actions/add_remove_libreoffice
Executable file
94
scripts/actions/add_remove_libreoffice
Executable file
|
@ -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_INSTANCE_NAME:-$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
|
35
scripts/actions/list_all_pads
Executable file
35
scripts/actions/list_all_pads
Executable file
|
@ -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_INSTANCE_NAME:-$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
|
58
scripts/actions/public_private
Executable file
58
scripts/actions/public_private
Executable file
|
@ -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
|
72
scripts/actions/reset_default_config
Executable file
72
scripts/actions/reset_default_config
Executable file
|
@ -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"
|
289
scripts/config
Normal file
289
scripts/config
Normal file
|
@ -0,0 +1,289 @@
|
||||||
|
#!/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_INSTANCE_NAME:-$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)"
|
||||||
|
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
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# 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"
|
||||||
|
ynh_app_setting_set $app pad_config_nocolors "$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"
|
||||||
|
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"
|
||||||
|
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"
|
||||||
|
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"
|
||||||
|
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"
|
||||||
|
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
|
||||||
|
yunohost app action run $app public_private --args is_public=1
|
||||||
|
else
|
||||||
|
yunohost app action run $app public_private --args is_public=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
show) show_config;;
|
||||||
|
apply) apply_config;;
|
||||||
|
esac
|
|
@ -70,6 +70,16 @@ ynh_app_setting_set --app=$app --key=language --value=$language
|
||||||
ynh_app_setting_set --app=$app --key=export --value=$export
|
ynh_app_setting_set --app=$app --key=export --value=$export
|
||||||
ynh_app_setting_set --app=$app --key=mypads --value=$mypads
|
ynh_app_setting_set --app=$app --key=mypads --value=$mypads
|
||||||
ynh_app_setting_set --app=$app --key=useldap --value=$useldap
|
ynh_app_setting_set --app=$app --key=useldap --value=$useldap
|
||||||
|
ynh_app_setting_set --app=$app --key=overwrite_settings --value="1"
|
||||||
|
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
|
# STANDARD MODIFICATIONS
|
||||||
|
@ -191,7 +201,7 @@ ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --
|
||||||
# Use ldap for mypads
|
# Use ldap for mypads
|
||||||
if [ $mypads -eq 1 ] && [ $useldap -eq 1 ]
|
if [ $mypads -eq 1 ] && [ $useldap -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_replace_string --match_string="//noldap" --replace_string="" --target_file="$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
|
# Calculate and store the config file checksum into the app settings
|
||||||
|
|
163
scripts/upgrade
163
scripts/upgrade
|
@ -29,6 +29,17 @@ export=$(ynh_app_setting_get --app=$app --key=export)
|
||||||
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
|
||||||
mypads=$(ynh_app_setting_get --app=$app --key=mypads)
|
mypads=$(ynh_app_setting_get --app=$app --key=mypads)
|
||||||
useldap=$(ynh_app_setting_get --app=$app --key=useldap)
|
useldap=$(ynh_app_setting_get --app=$app --key=useldap)
|
||||||
|
overwrite_settings=$(ynh_app_setting_get --app=$app --key=overwrite_settings)
|
||||||
|
overwrite_credentials=$(ynh_app_setting_get --app=$app --key=overwrite_credentials)
|
||||||
|
overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx)
|
||||||
|
overwrite_systemd=$(ynh_app_setting_get --app=$app --key=overwrite_systemd)
|
||||||
|
|
||||||
|
# Optional parameters from config-panel feature
|
||||||
|
pad_config_nocolors=$(ynh_app_setting_get --app=$app --key=pad_config_nocolors)
|
||||||
|
pad_config_showlinenumbers=$(ynh_app_setting_get --app=$app --key=pad_config_showlinenumbers)
|
||||||
|
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)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK VERSION
|
# CHECK VERSION
|
||||||
|
@ -98,6 +109,30 @@ if [ -z "$path_url" ]; then
|
||||||
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
fi
|
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
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -159,8 +194,11 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
ynh_script_progression --message="Upgrading nginx web server configuration..."
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Overwrite the nginx configuration only if it's allowed
|
||||||
ynh_add_nginx_config
|
if [ $overwrite_nginx -eq 1 ]
|
||||||
|
then
|
||||||
|
ynh_add_nginx_config
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE NODEJS
|
# UPGRADE NODEJS
|
||||||
|
@ -205,49 +243,79 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Reconfiguring Etherpad..." --weight=3
|
ynh_script_progression --message="Reconfiguring Etherpad..." --weight=3
|
||||||
|
|
||||||
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
# Overwrite the settings config file only if it's allowed
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/settings.json"
|
if [ $overwrite_settings -eq 1 ]
|
||||||
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
then
|
||||||
ynh_backup_if_checksum_is_different --file="$final_path/credentials.json"
|
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||||
cp ../conf/settings.json "$final_path/settings.json"
|
ynh_backup_if_checksum_is_different --file="$final_path/settings.json"
|
||||||
cp ../conf/credentials.json "$final_path/credentials.json"
|
cp ../conf/settings.json "$final_path/settings.json"
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/settings.json"
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/settings.json"
|
||||||
ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$final_path/credentials.json"
|
|
||||||
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
|
||||||
ynh_print_OFF; password=$(ynh_app_setting_get --app=$app --key=password); ynh_print_ON
|
|
||||||
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/credentials.json"
|
|
||||||
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/credentials.json"
|
|
||||||
ynh_print_OFF; ynh_replace_special_string --match_string="__PASSWD__" --replace_string="$password" --target_file="$final_path/credentials.json"; ynh_print_ON
|
|
||||||
if [ "$export" = "abiword" ]
|
|
||||||
then
|
|
||||||
# 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
|
|
||||||
# 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
|
|
||||||
if test -z "$language"; then
|
|
||||||
# If upgrading from a version which doesn't support translations, set language to English by default
|
|
||||||
language=en
|
|
||||||
ynh_app_setting_set --app=$app --key=language --value=$language
|
|
||||||
fi
|
|
||||||
ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/settings.json"
|
|
||||||
|
|
||||||
# Use ldap for mypads
|
if [ "$export" = "abiword" ]
|
||||||
if [ $mypads -eq 1 ] && [ $useldap -eq 1 ]
|
then
|
||||||
then
|
# Get abiword binary path
|
||||||
ynh_replace_string --match_string="//noldap" --replace_string="" --target_file="$final_path/settings.json"
|
abiword_path=`which abiword`
|
||||||
fi
|
# 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
|
||||||
|
# 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
|
||||||
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
if test -z "$language"; then
|
||||||
ynh_store_file_checksum --file="$final_path/settings.json"
|
# If upgrading from a version which doesn't support translations, set language to English by default
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
language=en
|
||||||
ynh_store_file_checksum --file="$final_path/credentials.json"
|
ynh_app_setting_set --app=$app --key=language --value=$language
|
||||||
|
fi
|
||||||
|
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 --match_string="//noldap" --replace_string="" --target_file="$final_path/settings.json"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Optional parameters from config-panel feature
|
||||||
|
if [ -n "$pad_config_nocolors" ]; then
|
||||||
|
ynh_replace_string --match_string="\(\"noColors\" *: \).*," --replace_string="\1$pad_config_nocolors," --target_file="$final_path/settings.json"
|
||||||
|
fi
|
||||||
|
if [ -n "$pad_config_showlinenumbers" ]; then
|
||||||
|
ynh_replace_string --match_string="\(\"showLineNumbers\" *: \).*," --replace_string="\1$pad_config_showlinenumbers," --target_file="$final_path/settings.json"
|
||||||
|
fi
|
||||||
|
if [ -n "$pad_config_chatandusers" ]; then
|
||||||
|
ynh_replace_string --match_string="\(\"chatAndUsers\" *: \).*," --replace_string="\1$pad_config_chatandusers," --target_file="$final_path/settings.json"
|
||||||
|
fi
|
||||||
|
if [ -n "$pad_config_alwaysshowchat" ]; then
|
||||||
|
ynh_replace_string --match_string="\(\"alwaysShowChat\" *: \).*," --replace_string="\1$pad_config_alwaysshowchat," --target_file="$final_path/settings.json"
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
|
||||||
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
|
ynh_store_file_checksum --file="$final_path/settings.json"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Overwrite the credentials config file only if it's allowed
|
||||||
|
if [ $overwrite_credentials -eq 1 ]
|
||||||
|
then
|
||||||
|
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||||
|
ynh_backup_if_checksum_is_different --file="$final_path/credentials.json"
|
||||||
|
cp ../conf/credentials.json "$final_path/credentials.json"
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$final_path/credentials.json"
|
||||||
|
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||||
|
ynh_print_OFF; password=$(ynh_app_setting_get --app=$app --key=password); ynh_print_ON
|
||||||
|
ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/credentials.json"
|
||||||
|
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/credentials.json"
|
||||||
|
ynh_print_OFF; ynh_replace_special_string --match_string="__PASSWD__" --replace_string="$password" --target_file="$final_path/credentials.json"; ynh_print_ON
|
||||||
|
|
||||||
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
|
ynh_store_file_checksum --file="$final_path/credentials.json"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -289,9 +357,12 @@ ynh_use_logrotate --non-append
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
|
ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
|
||||||
|
|
||||||
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service"
|
# Overwrite the systemd configuration only if it's allowed
|
||||||
# Create a dedicated systemd config
|
if [ $overwrite_systemd -eq 1 ]
|
||||||
ynh_add_systemd_config
|
then
|
||||||
|
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service"
|
||||||
|
ynh_add_systemd_config
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SOME HACKS
|
# SOME HACKS
|
||||||
|
|
Loading…
Add table
Reference in a new issue