mirror of
https://github.com/YunoHost-Apps/etherpad_mypads_ynh.git
synced 2024-09-03 18:36:09 +02:00
Update to last standart
This commit is contained in:
parent
037e1c446f
commit
c663ec74c1
8 changed files with 319 additions and 315 deletions
|
@ -40,8 +40,9 @@ Supported, with LDAP.
|
||||||
|
|
||||||
#### Supported architectures
|
#### Supported architectures
|
||||||
|
|
||||||
* x86-64b - [/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20(Official)/)
|
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/etherpad_mypads/)
|
||||||
* ARMv8-A - [%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/etherpad_mypads%20(Official)%20(%7EARM%7E)/)
|
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/etherpad_mypads/)
|
||||||
|
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/etherpad_mypads/)
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,9 @@ Supportée, avec LDAP.
|
||||||
|
|
||||||
#### Architectures supportées.
|
#### Architectures supportées.
|
||||||
|
|
||||||
* x86-64b - [/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20(Official)/)
|
* x86-64b - [](https://ci-apps.yunohost.org/ci/apps/etherpad_mypads/)
|
||||||
* ARMv8-A - [%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/etherpad_mypads%20(Official)%20(%7EARM%7E)/)
|
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/etherpad_mypads/)
|
||||||
|
* Jessie x86-64b - [](https://ci-stretch.nohost.me/ci/apps/etherpad_mypads/)
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
|
|
|
@ -23,146 +23,37 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# EXPERIMENTAL HELPERS
|
# FUTUR OFFICIAL 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
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Create a dedicated fail2ban config (jail and filter conf files)
|
# Create a dedicated fail2ban config (jail and filter conf files)
|
||||||
#
|
#
|
||||||
# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]]
|
# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]]
|
||||||
# | arg: log_file - Log file to be checked by fail2ban
|
# | arg: -l, --logpath= - Log file to be checked by fail2ban
|
||||||
# | arg: failregex - Failregex to be looked for by fail2ban
|
# | arg: -r, --failregex= - Failregex to be looked for by fail2ban
|
||||||
# | arg: max_retry - Maximum number of retries allowed before banning IP address - default: 3
|
# | arg: -m, --max_retry= - Maximum number of retries allowed before banning IP address - default: 3
|
||||||
# | arg: ports - Ports blocked for a banned IP address - default: http,https
|
# | arg: -p, --ports= - Ports blocked for a banned IP address - default: http,https
|
||||||
ynh_add_fail2ban_config () {
|
ynh_add_fail2ban_config () {
|
||||||
# Process parameters
|
# Declare an array to define the options of this helper.
|
||||||
logpath=$1
|
declare -Ar args_array=( [l]=logpath= [r]=failregex= [m]=max_retry= [p]=ports= )
|
||||||
failregex=$2
|
local logpath
|
||||||
max_retry=${3:-3}
|
local failregex
|
||||||
ports=${4:-http,https}
|
local max_retry
|
||||||
|
local ports
|
||||||
test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
|
# Manage arguments with getopts
|
||||||
test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
|
ynh_handle_getopts_args "$@"
|
||||||
|
max_retry=${max_retry:-3}
|
||||||
finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf"
|
ports=${ports:-http,https}
|
||||||
finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf"
|
|
||||||
ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1
|
test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
|
||||||
ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1
|
test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
|
||||||
|
|
||||||
sudo tee $finalfail2banjailconf <<EOF
|
finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf"
|
||||||
|
finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf"
|
||||||
|
ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1
|
||||||
|
ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1
|
||||||
|
|
||||||
|
tee $finalfail2banjailconf <<EOF
|
||||||
[$app]
|
[$app]
|
||||||
enabled = true
|
enabled = true
|
||||||
port = $ports
|
port = $ports
|
||||||
|
@ -171,7 +62,7 @@ logpath = $logpath
|
||||||
maxretry = $max_retry
|
maxretry = $max_retry
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
sudo tee $finalfail2banfilterconf <<EOF
|
tee $finalfail2banfilterconf <<EOF
|
||||||
[INCLUDES]
|
[INCLUDES]
|
||||||
before = common.conf
|
before = common.conf
|
||||||
[Definition]
|
[Definition]
|
||||||
|
@ -179,25 +70,33 @@ failregex = $failregex
|
||||||
ignoreregex =
|
ignoreregex =
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
ynh_store_file_checksum "$finalfail2banjailconf"
|
ynh_store_file_checksum "$finalfail2banjailconf"
|
||||||
ynh_store_file_checksum "$finalfail2banfilterconf"
|
ynh_store_file_checksum "$finalfail2banfilterconf"
|
||||||
|
|
||||||
systemctl restart fail2ban
|
if [ "$(lsb_release --codename --short)" != "jessie" ]; then
|
||||||
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
|
systemctl reload fail2ban
|
||||||
if [ -n "$fail2ban_error" ]
|
else
|
||||||
then
|
systemctl restart fail2ban
|
||||||
echo "[ERR] Fail2ban failed to load the jail for $app" >&2
|
fi
|
||||||
echo "WARNING${fail2ban_error#*WARNING}" >&2
|
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
|
||||||
fi
|
if [ -n "$fail2ban_error" ]
|
||||||
|
then
|
||||||
|
echo "[ERR] Fail2ban failed to load the jail for $app" >&2
|
||||||
|
echo "WARNING${fail2ban_error#*WARNING}" >&2
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove the dedicated fail2ban config (jail and filter conf files)
|
# Remove the dedicated fail2ban config (jail and filter conf files)
|
||||||
#
|
#
|
||||||
# usage: ynh_remove_fail2ban_config
|
# usage: ynh_remove_fail2ban_config
|
||||||
ynh_remove_fail2ban_config () {
|
ynh_remove_fail2ban_config () {
|
||||||
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
|
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
|
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
|
||||||
systemctl restart fail2ban
|
if [ "$(lsb_release --codename --short)" != "jessie" ]; then
|
||||||
|
systemctl reload fail2ban
|
||||||
|
else
|
||||||
|
systemctl restart fail2ban
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -205,28 +104,39 @@ ynh_remove_fail2ban_config () {
|
||||||
# Read the value of a key in a ynh manifest file
|
# Read the value of a key in a ynh manifest file
|
||||||
#
|
#
|
||||||
# usage: ynh_read_manifest manifest key
|
# usage: ynh_read_manifest manifest key
|
||||||
# | arg: manifest - Path of the manifest to read
|
# | arg: -m, --manifest= - Path of the manifest to read
|
||||||
# | arg: key - Name of the key to find
|
# | arg: -k, --key= - Name of the key to find
|
||||||
ynh_read_manifest () {
|
ynh_read_manifest () {
|
||||||
manifest="$1"
|
# Declare an array to define the options of this helper.
|
||||||
key="$2"
|
declare -Ar args_array=( [m]=manifest= [k]=manifest_key= )
|
||||||
python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])"
|
local manifest
|
||||||
|
local manifest_key
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
|
python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$manifest_key'])"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read the upstream version from the manifest
|
# Read the upstream version from the manifest
|
||||||
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
|
||||||
# For example : 4.3-2~ynh3
|
# For example : 4.3-2~ynh3
|
||||||
# This include the number before ~ynh
|
# This include the number before ~ynh
|
||||||
# In the last example it return 4.3-2
|
# In the last example it return 4.3-2
|
||||||
#
|
#
|
||||||
# usage: ynh_app_upstream_version
|
# usage: ynh_app_upstream_version [-m manifest]
|
||||||
|
# | arg: -m, --manifest= - Path of the manifest to read
|
||||||
ynh_app_upstream_version () {
|
ynh_app_upstream_version () {
|
||||||
manifest_path="../manifest.json"
|
declare -Ar args_array=( [m]=manifest= )
|
||||||
if [ ! -e "$manifest_path" ]; then
|
local manifest
|
||||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
# Manage arguments with getopts
|
||||||
fi
|
ynh_handle_getopts_args "$@"
|
||||||
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
|
||||||
echo "${version_key/~ynh*/}"
|
manifest="${manifest:-../manifest.json}"
|
||||||
|
if [ ! -e "$manifest" ]; then
|
||||||
|
manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||||
|
fi
|
||||||
|
version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
|
||||||
|
echo "${version_key/~ynh*/}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read package version from the manifest
|
# Read package version from the manifest
|
||||||
|
@ -235,34 +145,50 @@ ynh_app_upstream_version () {
|
||||||
# This include the number after ~ynh
|
# This include the number after ~ynh
|
||||||
# In the last example it return 3
|
# In the last example it return 3
|
||||||
#
|
#
|
||||||
# usage: ynh_app_package_version
|
# usage: ynh_app_package_version [-m manifest]
|
||||||
|
# | arg: -m, --manifest= - Path of the manifest to read
|
||||||
ynh_app_package_version () {
|
ynh_app_package_version () {
|
||||||
manifest_path="../manifest.json"
|
declare -Ar args_array=( [m]=manifest= )
|
||||||
if [ ! -e "$manifest_path" ]; then
|
local manifest
|
||||||
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
# Manage arguments with getopts
|
||||||
fi
|
ynh_handle_getopts_args "$@"
|
||||||
version_key=$(ynh_read_manifest "$manifest_path" "version")
|
|
||||||
echo "${version_key/*~ynh/}"
|
manifest="${manifest:-../manifest.json}"
|
||||||
|
if [ ! -e "$manifest" ]; then
|
||||||
|
manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
|
||||||
|
fi
|
||||||
|
version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version")
|
||||||
|
echo "${version_key/*~ynh/}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Exit without error if the package is up to date
|
# Checks the app version to upgrade with the existing app version and returns:
|
||||||
|
# - UPGRADE_APP if the upstream app version has changed
|
||||||
|
# - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||||
#
|
#
|
||||||
# This helper should be used to avoid an upgrade of a package
|
## It stops the current script without error if the package is up-to-date
|
||||||
# when it's not needed.
|
#
|
||||||
|
# This helper should be used to avoid an upgrade of an app, or the upstream part
|
||||||
|
# of it, when it's not needed
|
||||||
#
|
#
|
||||||
# To force an upgrade, even if the package is up to date,
|
# To force an upgrade, even if the package is up to date,
|
||||||
# you have to set the variable YNH_FORCE_UPGRADE before.
|
# you have to set the variable YNH_FORCE_UPGRADE before.
|
||||||
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
|
||||||
#
|
#
|
||||||
# usage: ynh_abort_if_up_to_date
|
# usage: ynh_check_app_version_changed
|
||||||
ynh_abort_if_up_to_date () {
|
ynh_check_app_version_changed () {
|
||||||
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
|
||||||
local package_check=${PACKAGE_CHECK_EXEC:-0}
|
local package_check=${PACKAGE_CHECK_EXEC:-0}
|
||||||
|
|
||||||
local version=$(ynh_read_manifest "/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" "version" || echo 1.0)
|
# By default, upstream app version has changed
|
||||||
local last_version=$(ynh_read_manifest "../manifest.json" "version" || echo 1.0)
|
local return_value="UPGRADE_APP"
|
||||||
if [ "$version" = "$last_version" ]
|
|
||||||
then
|
local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version" || echo 1.0)
|
||||||
|
local current_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")"
|
||||||
|
local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version" || echo 1.0)
|
||||||
|
local update_upstream_version="$(ynh_app_upstream_version)"
|
||||||
|
|
||||||
|
if [ "$current_version" == "$update_version" ] ; then
|
||||||
|
# Complete versions are the same
|
||||||
if [ "$force_upgrade" != "0" ]
|
if [ "$force_upgrade" != "0" ]
|
||||||
then
|
then
|
||||||
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
|
||||||
|
@ -273,7 +199,122 @@ ynh_abort_if_up_to_date () {
|
||||||
else
|
else
|
||||||
ynh_die "Up-to-date, nothing to do" 0
|
ynh_die "Up-to-date, nothing to do" 0
|
||||||
fi
|
fi
|
||||||
|
elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then
|
||||||
|
# Upstream versions are the same, only YunoHost package versions differ
|
||||||
|
return_value="UPGRADE_PACKAGE"
|
||||||
fi
|
fi
|
||||||
|
echo $return_value
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Delete a file checksum from the app settings
|
||||||
|
#
|
||||||
|
# $app should be defined when calling this helper
|
||||||
|
#
|
||||||
|
# usage: ynh_remove_file_checksum file
|
||||||
|
# | arg: -f, --file= - The file for which the checksum will be deleted
|
||||||
|
ynh_delete_file_checksum () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
declare -Ar args_array=( [f]=file= )
|
||||||
|
local file
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
|
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||||
|
ynh_app_setting_delete $app $checksum_setting_name
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
||||||
|
#
|
||||||
|
# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
|
||||||
|
# | arg: -n, --service_name= - Name of the service to reload. Default : $app
|
||||||
|
# | arg: -a, --action= - Action to perform with systemctl. Default: start
|
||||||
|
# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot.
|
||||||
|
# If not defined it don't wait until the service is completely started.
|
||||||
|
# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log
|
||||||
|
# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds.
|
||||||
|
# | arg: -e, --length= - Length of the error log : Default : 20
|
||||||
|
ynh_systemd_action() {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= )
|
||||||
|
local service_name
|
||||||
|
local action
|
||||||
|
local line_match
|
||||||
|
local length
|
||||||
|
local log_path
|
||||||
|
local timeout
|
||||||
|
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
|
local service_name="${service_name:-$app}"
|
||||||
|
local action=${action:-start}
|
||||||
|
local log_path="${log_path:-/var/log/$service_name/$service_name.log}"
|
||||||
|
local length=${length:-20}
|
||||||
|
local timeout=${timeout:-300}
|
||||||
|
|
||||||
|
# Start to read the log
|
||||||
|
if [[ -n "${line_match:-}" ]]
|
||||||
|
then
|
||||||
|
local templog="$(mktemp)"
|
||||||
|
# Following the starting of the app in its log
|
||||||
|
if [ "$log_path" == "systemd" ] ; then
|
||||||
|
# Read the systemd journal
|
||||||
|
journalctl -u $service_name -f --since=-45 > "$templog" &
|
||||||
|
else
|
||||||
|
# Read the specified log file
|
||||||
|
tail -F -n0 "$log_path" > "$templog" &
|
||||||
|
fi
|
||||||
|
# Get the PID of the tail command
|
||||||
|
local pid_tail=$!
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${action^} the service $service_name" >&2
|
||||||
|
systemctl $action $service_name \
|
||||||
|
|| ( journalctl --lines=$length -u $service_name >&2 \
|
||||||
|
; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \
|
||||||
|
; false )
|
||||||
|
|
||||||
|
# Start the timeout and try to find line_match
|
||||||
|
if [[ -n "${line_match:-}" ]]
|
||||||
|
then
|
||||||
|
local i=0
|
||||||
|
for i in $(seq 1 $timeout)
|
||||||
|
do
|
||||||
|
# Read the log until the sentence is found, that means the app finished to start. Or run until the timeout
|
||||||
|
if grep --quiet "$line_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 started before the timeout." >&2
|
||||||
|
journalctl --lines=$length -u $service_name >&2
|
||||||
|
test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
ynh_clean_check_starting
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -281,14 +322,20 @@ ynh_abort_if_up_to_date () {
|
||||||
# Send an email to inform the administrator
|
# Send an email to inform the administrator
|
||||||
#
|
#
|
||||||
# usage: ynh_send_readme_to_admin app_message [recipients]
|
# usage: ynh_send_readme_to_admin app_message [recipients]
|
||||||
# | arg: app_message - The message to send to the administrator.
|
# | arg: -m --app_message= - The message to send to the administrator.
|
||||||
# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
||||||
# example: "root admin@domain"
|
# example: "root admin@domain"
|
||||||
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
|
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
|
||||||
# example: "root admin@domain user1 user2"
|
# example: "root admin@domain user1 user2"
|
||||||
ynh_send_readme_to_admin() {
|
ynh_send_readme_to_admin() {
|
||||||
local app_message="${1:-...No specific information...}"
|
# Declare an array to define the options of this helper.
|
||||||
local recipients="${2:-root}"
|
declare -Ar args_array=( [m]=app_message= [r]=recipients= )
|
||||||
|
local app_message
|
||||||
|
local recipients
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
local app_message="${app_message:-...No specific information...}"
|
||||||
|
local recipients="${recipients:-root}"
|
||||||
|
|
||||||
# Retrieve the email of users
|
# Retrieve the email of users
|
||||||
find_mails () {
|
find_mails () {
|
||||||
|
@ -341,35 +388,15 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Reload (or other actions) a service and print a log in case of failure.
|
|
||||||
#
|
|
||||||
# usage: ynh_system_reload service_name [action]
|
|
||||||
# | arg: service_name - Name of the service to reload
|
|
||||||
# | arg: action - Action to perform with systemctl. Default: reload
|
|
||||||
ynh_system_reload () {
|
|
||||||
local service_name=$1
|
|
||||||
local action=${2:-reload}
|
|
||||||
|
|
||||||
# Reload, restart or start and print the log if the service fail to start or reload
|
|
||||||
systemctl $action $service_name || ( journalctl --lines=20 -u $service_name >&2 && false)
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Delete a file checksum from the app settings
|
|
||||||
#
|
|
||||||
# $app should be defined when calling this helper
|
|
||||||
#
|
|
||||||
# usage: ynh_remove_file_checksum file
|
|
||||||
# | arg: file - The file for which the checksum will be deleted
|
|
||||||
ynh_delete_file_checksum () {
|
|
||||||
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
|
||||||
ynh_app_setting_delete $app $checksum_setting_name
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_maintenance_mode_ON () {
|
ynh_maintenance_mode_ON () {
|
||||||
|
# Load value of $path_url and $domain from the config if their not set
|
||||||
|
if [ -z $path_url ]; then
|
||||||
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
|
fi
|
||||||
|
if [ -z $domain ]; then
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
fi
|
||||||
|
|
||||||
# Create an html to serve as maintenance notice
|
# Create an html to serve as maintenance notice
|
||||||
echo "<!DOCTYPE html>
|
echo "<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
@ -416,6 +443,14 @@ include conf.d/yunohost_panel.conf.inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ynh_maintenance_mode_OFF () {
|
ynh_maintenance_mode_OFF () {
|
||||||
|
# Load value of $path_url and $domain from the config if their not set
|
||||||
|
if [ -z $path_url ]; then
|
||||||
|
path_url=$(ynh_app_setting_get $app path)
|
||||||
|
fi
|
||||||
|
if [ -z $domain ]; then
|
||||||
|
domain=$(ynh_app_setting_get $app domain)
|
||||||
|
fi
|
||||||
|
|
||||||
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app.
|
# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app.
|
||||||
echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
|
echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
|
||||||
systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
|
@ -6,12 +6,7 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ ! -e _common.sh ]; then
|
source ../settings/scripts/_common.sh
|
||||||
# Get the _common.sh file if it's not in the current directory
|
|
||||||
cp ../settings/scripts/_common.sh ./_common.sh
|
|
||||||
chmod a+rx _common.sh
|
|
||||||
fi
|
|
||||||
source _common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -21,6 +21,11 @@ new_path=$YNH_APP_NEW_PATH
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
mypads=$(ynh_app_setting_get $app mypads)
|
mypads=$(ynh_app_setting_get $app mypads)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -81,30 +86,15 @@ then
|
||||||
# Make a backup of the original nginx config file if modified
|
# Make a backup of the original nginx config file if modified
|
||||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||||
|
|
||||||
# Move from sub path to root
|
# Set global variables for nginx helper
|
||||||
if [ "$new_path" == "/" ]
|
domain="$old_domain"
|
||||||
then
|
path_url="$new_path"
|
||||||
ynh_replace_string "^location $old_path/" "location $new_path" "$nginx_conf_path"
|
|
||||||
ynh_replace_string "^.*rewrite.*\^/" "#sub_path_only&" "$nginx_conf_path"
|
|
||||||
ynh_replace_string "^location ~\* $old_path/" "location ~* $new_path" "$nginx_conf_path"
|
|
||||||
|
|
||||||
# Change the path in the two rewrite instructions
|
# Store path_url setting
|
||||||
ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path" "$nginx_conf_path"
|
ynh_app_setting_set $app path "$path_url"
|
||||||
ynh_replace_string "\(rewrite *\^\)$old_path/*admin\$ $old_path/*" "\1${new_path}admin\$ $new_path" "$nginx_conf_path"
|
|
||||||
|
|
||||||
# Move to a sub path
|
# Create a dedicated nginx config
|
||||||
else
|
ynh_add_nginx_config
|
||||||
ynh_replace_string "^location $old_path.*" "location $new_path/ {" "$nginx_conf_path"
|
|
||||||
ynh_replace_string "^#sub_path_only" "" "$nginx_conf_path"
|
|
||||||
ynh_replace_string "^location ~\* $old_path/*" "location ~* $new_path/" "$nginx_conf_path"
|
|
||||||
|
|
||||||
# Change the path in the two rewrite instructions
|
|
||||||
ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path/" "$nginx_conf_path"
|
|
||||||
ynh_replace_string "\(rewrite *\^\)$old_path/*admin\$ $old_path/*" "\1$new_path/admin\$ $new_path/" "$nginx_conf_path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Calculate and store the nginx config file checksum
|
|
||||||
ynh_store_file_checksum "$nginx_conf_path"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change the domain for nginx
|
# Change the domain for nginx
|
||||||
|
@ -114,23 +104,22 @@ then
|
||||||
ynh_delete_file_checksum "$nginx_conf_path"
|
ynh_delete_file_checksum "$nginx_conf_path"
|
||||||
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$new_domain.d/$app.conf
|
# Store file checksum for the new config file location
|
||||||
# Calculate and store the nginx config file checksum
|
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf"
|
||||||
ynh_store_file_checksum "$nginx_conf_path"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_system_reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK ETHERPAD STARTING
|
# CHECK ETHERPAD STARTING
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Wait for etherpad fully started
|
# Wait for etherpad 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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEACTIVE MAINTENANCE MODE
|
# DEACTIVE MAINTENANCE MODE
|
||||||
|
|
|
@ -54,8 +54,6 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
||||||
# Normalize the url path syntax
|
# Normalize the url path syntax
|
||||||
path_url=$(ynh_normalize_url_path $path_url)
|
path_url=$(ynh_normalize_url_path $path_url)
|
||||||
|
|
||||||
# Check web path availability
|
|
||||||
ynh_webpath_available $domain $path_url
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register $app $domain $path_url
|
ynh_webpath_register $app $domain $path_url
|
||||||
|
|
||||||
|
@ -73,12 +71,6 @@ ynh_app_setting_set $app export $export
|
||||||
ynh_app_setting_set $app mypads $mypads
|
ynh_app_setting_set $app mypads $mypads
|
||||||
ynh_app_setting_set $app useldap $useldap
|
ynh_app_setting_set $app useldap $useldap
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# ACTIVATE MAINTENANCE MODE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_maintenance_mode_ON
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD MODIFICATIONS
|
# STANDARD MODIFICATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -123,11 +115,6 @@ ynh_setup_source "$final_path" # Download, check integrity and uncompress the so
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
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
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -260,7 +247,7 @@ fi
|
||||||
# SETUP FAIL2BAN
|
# SETUP FAIL2BAN
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_add_fail2ban_config "/var/log/nginx/$domain-access.log" "<HOST> .* \"POST /mypads/api/auth/login HTTP/1.1\" 400" 5
|
ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex="<HOST> .* \"POST /mypads/api/auth/login HTTP/1.1\" 400" --max_retry=5
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
@ -276,14 +263,14 @@ fi
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_system_reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK ETHERPAD STARTING
|
# CHECK ETHERPAD STARTING
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
||||||
if [ $mypads -eq 1 ]
|
if [ $mypads -eq 1 ]
|
||||||
then
|
then
|
||||||
|
@ -291,7 +278,7 @@ then
|
||||||
mysql -u $db_name -p$db_pwd $db_name < "../conf/lang_mypads.sql"
|
mysql -u $db_name -p$db_pwd $db_name < "../conf/lang_mypads.sql"
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -6,12 +6,7 @@
|
||||||
# IMPORT GENERIC HELPERS
|
# IMPORT GENERIC HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ ! -e _common.sh ]; then
|
source ../settings/scripts/_common.sh
|
||||||
# Get the _common.sh file if it's not in the current directory
|
|
||||||
cp ../settings/scripts/_common.sh ./_common.sh
|
|
||||||
chmod a+rx _common.sh
|
|
||||||
fi
|
|
||||||
source _common.sh
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
# Load common variables for all scripts.
|
# Load common variables for all scripts.
|
||||||
source ../settings/scripts/_variables
|
source ../settings/scripts/_variables
|
||||||
|
@ -152,20 +147,20 @@ systemctl enable $app.service
|
||||||
|
|
||||||
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
|
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
|
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
|
||||||
ynh_system_reload fail2ban restart
|
ynh_systemd_action --action=restart --service_name=fail2ban
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_system_reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK ETHERPAD STARTING
|
# CHECK ETHERPAD STARTING
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEACTIVE MAINTENANCE MODE
|
# DEACTIVE MAINTENANCE MODE
|
||||||
|
|
|
@ -34,9 +34,9 @@ useldap=$(ynh_app_setting_get $app useldap)
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
||||||
ynh_abort_if_up_to_date
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIX OLD THINGS
|
# FIX OLD THINGS
|
||||||
|
@ -114,7 +114,7 @@ ynh_maintenance_mode_ON
|
||||||
# STOP ETHERPAD
|
# STOP ETHERPAD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_system_reload $app stop
|
ynh_systemd_action --action=stop
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
|
@ -122,17 +122,15 @@ ynh_system_reload $app stop
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_setup_source "$final_path" # Download, check integrity and uncompress the source from app.src
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
|
then
|
||||||
|
ynh_setup_source "$final_path" # Download, check integrity and uncompress the source from app.src
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
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
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -172,40 +170,43 @@ done <<< "$(ls -1 "$final_path/node_modules" | grep "^ep_")")
|
||||||
# CONFIGURE ETHERPAD
|
# CONFIGURE ETHERPAD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different "$final_path/settings.json" # Verify the checksum and backup the file if it's different
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
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" ]
|
|
||||||
then
|
then
|
||||||
abiword_path=`which abiword` # Get abiword binary path
|
ynh_backup_if_checksum_is_different "$final_path/settings.json" # Verify the checksum and backup the file if it's different
|
||||||
ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
|
ynh_backup_if_checksum_is_different "$final_path/credentials.json" # Verify the checksum and backup the file if it's different
|
||||||
elif [ "$export" = "libreoffice" ]
|
cp ../conf/settings.json "$final_path/settings.json"
|
||||||
then
|
cp ../conf/credentials.json "$final_path/credentials.json"
|
||||||
soffice_path=`which soffice` # Get soffice binary path
|
ynh_replace_string "__PORT__" "$port" "$final_path/settings.json"
|
||||||
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 "__DB_USER__" "$app" "$final_path/credentials.json"
|
||||||
fi
|
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||||
if test -z $language; then
|
ynh_print_OFF; password=$(ynh_app_setting_get $app password); ynh_print_ON
|
||||||
language=en # If upgrading from a version which doesn't support translations, set language to English by default
|
ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/credentials.json"
|
||||||
ynh_app_setting_set $app language $language
|
ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json"
|
||||||
fi
|
ynh_print_OFF; ynh_replace_special_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON
|
||||||
ynh_replace_string "__LANGUAGE__" "$language" "$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
|
# Use ldap for mypads
|
||||||
if [ $mypads -eq 1 ] && [ $useldap -eq 1 ]
|
if [ $mypads -eq 1 ] && [ $useldap -eq 1 ]
|
||||||
then
|
then
|
||||||
ynh_replace_string "//noldap" "" "$final_path/settings.json"
|
ynh_replace_string "//noldap" "" "$final_path/settings.json"
|
||||||
fi
|
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/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
|
ynh_store_file_checksum "$final_path/credentials.json" # Recalculate and store the config file checksum into the app settings
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
|
@ -226,7 +227,7 @@ chown $app -R /var/log/$app/etherpad.log
|
||||||
# UPGRADE FAIL2BAN
|
# UPGRADE FAIL2BAN
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_add_fail2ban_config "/var/log/nginx/$domain-access.log" "<HOST> .* \"POST /mypads/api/auth/login HTTP/1.1\" 400" 5
|
ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex="<HOST> .* \"POST /mypads/api/auth/login HTTP/1.1\" 400" --max_retry=5
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
|
@ -266,14 +267,14 @@ fi
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_system_reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK ETHERPAD STARTING
|
# CHECK ETHERPAD STARTING
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DEACTIVE MAINTENANCE MODE
|
# DEACTIVE MAINTENANCE MODE
|
||||||
|
|
Loading…
Add table
Reference in a new issue