mirror of
https://github.com/YunoHost-Apps/etherpad_mypads_ynh.git
synced 2024-09-03 18:36:09 +02:00
Merge pull request #62 from YunoHost-Apps/update_package
Update package
This commit is contained in:
commit
ef1cb406b8
11 changed files with 657 additions and 408 deletions
11
README.md
11
README.md
|
@ -1,6 +1,6 @@
|
||||||
# Etherpad with mypads plugin for YunoHost
|
# Etherpad with mypads plugin for YunoHost
|
||||||
|
|
||||||
[](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20%28Official%29/lastBuild/consoleFull)
|
[](https://dash.yunohost.org/appci/app/etherpad_mypads)
|
||||||
[](https://install-app.yunohost.org/?app=etherpad_mypads)
|
[](https://install-app.yunohost.org/?app=etherpad_mypads)
|
||||||
|
|
||||||
*[Lire ce readme en français.](./README_fr.md)*
|
*[Lire ce readme en français.](./README_fr.md)*
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ Please do your pull request to the [testing branch](https://github.com/YunoHost-
|
||||||
|
|
||||||
To try the testing branch, please proceed like that.
|
To try the testing branch, please proceed like that.
|
||||||
```
|
```
|
||||||
sudo yunohost app install https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --verbose
|
sudo yunohost app install https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --debug
|
||||||
or
|
or
|
||||||
sudo yunohost app upgrade etherpad_mypads -u https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --verbose
|
sudo yunohost app upgrade etherpad_mypads -u https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --debug
|
||||||
```
|
```
|
||||||
|
|
11
README_fr.md
11
README_fr.md
|
@ -1,6 +1,6 @@
|
||||||
# Etherpad avec plugin mypads pour YunoHost
|
# Etherpad avec plugin mypads pour YunoHost
|
||||||
|
|
||||||
[](https://ci-apps.yunohost.org/jenkins/job/etherpad_mypads%20%28Official%29/lastBuild/consoleFull)
|
[](https://dash.yunohost.org/appci/app/etherpad_mypads)
|
||||||
[](https://install-app.yunohost.org/?app=etherpad_mypads)
|
[](https://install-app.yunohost.org/?app=etherpad_mypads)
|
||||||
|
|
||||||
*[Read this readme in english.](./README.md)*
|
*[Read this readme in english.](./README.md)*
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ Merci de faire vos pull request sur la [branche testing](https://github.com/Yuno
|
||||||
|
|
||||||
Pour tester la branche testing, merci de procéder ainsi.
|
Pour tester la branche testing, merci de procéder ainsi.
|
||||||
```
|
```
|
||||||
sudo yunohost app install https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --verbose
|
sudo yunohost app install https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --debug
|
||||||
ou
|
ou
|
||||||
sudo yunohost app upgrade etherpad_mypads -u https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --verbose
|
sudo yunohost app upgrade etherpad_mypads -u https://github.com/YunoHost-Apps/etherpad_mypads_ynh/tree/testing --debug
|
||||||
```
|
```
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Framapad clone, a online editor providing collaborative editing in real-time.",
|
"en": "Framapad clone, a online editor providing collaborative editing in real-time.",
|
||||||
"fr": "Clone de Framapad, un éditeur en ligne fournissant l'édition collaborative en temps réel."
|
"fr": "Clone de Framapad, un éditeur en ligne fournissant l'édition collaborative en temps réel."
|
||||||
},
|
},
|
||||||
"version": "1.7.0~ynh1",
|
"version": "1.7.0~ynh2",
|
||||||
"url": "https://framapad.org",
|
"url": "https://framapad.org",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
"email": "maniackc_dev@crudelis.fr"
|
"email": "maniackc_dev@crudelis.fr"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.7.12"
|
"yunohost": ">= 3.4"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
|
|
|
@ -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,22 +199,205 @@ 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
|
||||||
|
echo $return_value
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
echo "Please find here an extract of the end of the log of the service $service_name:"
|
||||||
|
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
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Print a message as INFO and show progression during an app script
|
||||||
|
#
|
||||||
|
# usage: ynh_script_progression --message=message [--weight=weight] [--time]
|
||||||
|
# | arg: -m, --message= - The text to print
|
||||||
|
# | arg: -w, --weight= - The weight for this progression. This value is 1 by default. Use a bigger value for a longer part of the script.
|
||||||
|
# | arg: -t, --time= - Print the execution time since the last call to this helper. Especially usefull to define weights.
|
||||||
|
# | arg: -l, --last= - Use for the last call of the helper, to fill te progression bar.
|
||||||
|
increment_progression=0
|
||||||
|
previous_weight=0
|
||||||
|
# Define base_time when the file is sourced
|
||||||
|
base_time=$(date +%s)
|
||||||
|
ynh_script_progression () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
declare -Ar args_array=( [m]=message= [w]=weight= [t]=time [l]=last )
|
||||||
|
local message
|
||||||
|
local weight
|
||||||
|
local time
|
||||||
|
local last
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
weight=${weight:-1}
|
||||||
|
time=${time:-0}
|
||||||
|
last=${last:-0}
|
||||||
|
|
||||||
|
# Get execution time since the last $base_time
|
||||||
|
local exec_time=$(( $(date +%s) - $base_time ))
|
||||||
|
base_time=$(date +%s)
|
||||||
|
|
||||||
|
# Get the number of occurrences of 'ynh_script_progression' in the script. Except those are commented.
|
||||||
|
local helper_calls="$(grep --count "^[^#]*ynh_script_progression" $0)"
|
||||||
|
# Get the number of call with a weight value
|
||||||
|
local weight_calls=$(grep --perl-regexp --count "^[^#]*ynh_script_progression.*(--weight|-w )" $0)
|
||||||
|
|
||||||
|
# Get the weight of each occurrences of 'ynh_script_progression' in the script using --weight
|
||||||
|
local weight_valuesA="$(grep --perl-regexp "^[^#]*ynh_script_progression.*--weight" $0 | sed 's/.*--weight[= ]\([[:digit:]].*\)/\1/g')"
|
||||||
|
# Get the weight of each occurrences of 'ynh_script_progression' in the script using -w
|
||||||
|
local weight_valuesB="$(grep --perl-regexp "^[^#]*ynh_script_progression.*-w " $0 | sed 's/.*-w[= ]\([[:digit:]].*\)/\1/g')"
|
||||||
|
# Each value will be on a different line.
|
||||||
|
# Remove each 'end of line' and replace it by a '+' to sum the values.
|
||||||
|
local weight_values=$(( $(echo "$weight_valuesA" | tr '\n' '+') + $(echo "$weight_valuesB" | tr '\n' '+') 0 ))
|
||||||
|
|
||||||
|
# max_progression is a total number of calls to this helper.
|
||||||
|
# Less the number of calls with a weight value.
|
||||||
|
# Plus the total of weight values
|
||||||
|
local max_progression=$(( $helper_calls - $weight_calls + $weight_values ))
|
||||||
|
|
||||||
|
# Increment each execution of ynh_script_progression in this script by the weight of the previous call.
|
||||||
|
increment_progression=$(( $increment_progression + $previous_weight ))
|
||||||
|
# Store the weight of the current call in $previous_weight for next call
|
||||||
|
previous_weight=$weight
|
||||||
|
|
||||||
|
# Set the scale of the progression bar
|
||||||
|
local scale=20
|
||||||
|
# progress_string(1,2) should have the size of the scale.
|
||||||
|
local progress_string1="####################"
|
||||||
|
local progress_string0="...................."
|
||||||
|
|
||||||
|
# Reduce $increment_progression to the size of the scale
|
||||||
|
if [ $last -eq 0 ]
|
||||||
|
then
|
||||||
|
local effective_progression=$(( $increment_progression * $scale / $max_progression ))
|
||||||
|
# If last is specified, fill immediately the progression_bar
|
||||||
|
else
|
||||||
|
local effective_progression=$scale
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build $progression_bar from progress_string(1,2) according to $effective_progression
|
||||||
|
local progression_bar="${progress_string1:0:$effective_progression}${progress_string0:0:$(( $scale - $effective_progression ))}"
|
||||||
|
|
||||||
|
local print_exec_time=""
|
||||||
|
if [ $time -eq 1 ]
|
||||||
|
then
|
||||||
|
print_exec_time=" [$(date +%Hh%Mm,%Ss --date="0 + $exec_time sec")]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_print_info "[$progression_bar] > ${message}${print_exec_time}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# 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 +450,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 +505,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,9 +6,9 @@ abiword_app_depencencies="abiword"
|
||||||
# Dependencies for libre office
|
# Dependencies for libre office
|
||||||
libreoffice_app_dependencies="unoconv libreoffice-writer"
|
libreoffice_app_dependencies="unoconv libreoffice-writer"
|
||||||
|
|
||||||
# Version of nodejs
|
# NodeJS version
|
||||||
nodejs_version=6
|
nodejs_version=6
|
||||||
|
|
||||||
# Version of mypads
|
# Mypads version
|
||||||
# This variable is mostly used to force an upgrade of the package in case of new versions of mypads.
|
# This variable is mostly used to force an upgrade of the package in case of new versions of mypads.
|
||||||
mypads_version=1.6.8
|
mypads_version=1.7.6
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -24,6 +19,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Load settings" --weight=2
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -34,21 +30,24 @@ db_name=$(ynh_app_setting_get $app db_name)
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD BACKUP STEPS
|
# STANDARD BACKUP STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP OF THE MAIN DIR OF THE APP
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup the app main dir" --weight=2
|
||||||
|
|
||||||
CHECK_SIZE "$final_path"
|
CHECK_SIZE "$final_path"
|
||||||
ynh_backup "$final_path"
|
ynh_backup "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP OF THE NGINX CONFIGURATION
|
# BACKUP NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup nginx configuration"
|
||||||
|
|
||||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP OF THE SQL BDD
|
# BACKUP THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup the mysql database" --weight=3
|
||||||
|
|
||||||
ynh_mysql_dump_db "$db_name" > db.sql
|
ynh_mysql_dump_db "$db_name" > db.sql
|
||||||
CHECK_SIZE "db.sql"
|
CHECK_SIZE "db.sql"
|
||||||
|
@ -58,18 +57,27 @@ CHECK_SIZE "db.sql"
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP LOGROTATE
|
# BACKUP LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup logrotate configuration"
|
||||||
|
|
||||||
ynh_backup "/etc/logrotate.d/$app"
|
ynh_backup "/etc/logrotate.d/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP SYSTEMD
|
# BACKUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup systemd configuration"
|
||||||
|
|
||||||
ynh_backup "/etc/systemd/system/$app.service"
|
ynh_backup "/etc/systemd/system/$app.service"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP FAIL2BAN CONFIGURATION
|
# BACKUP FAIL2BAN CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup fail2ban configuration"
|
||||||
|
|
||||||
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
|
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
|
||||||
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Backup completed" --last
|
||||||
|
|
|
@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Retrieve arguments from the manifest"
|
||||||
|
|
||||||
old_domain=$YNH_APP_OLD_DOMAIN
|
old_domain=$YNH_APP_OLD_DOMAIN
|
||||||
old_path=$YNH_APP_OLD_PATH
|
old_path=$YNH_APP_OLD_PATH
|
||||||
|
@ -21,11 +22,19 @@ new_path=$YNH_APP_NEW_PATH
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Load settings" --weight=5
|
||||||
|
|
||||||
|
final_path=$(ynh_app_setting_get $app final_path)
|
||||||
mypads=$(ynh_app_setting_get $app mypads)
|
mypads=$(ynh_app_setting_get $app mypads)
|
||||||
|
port=$(ynh_app_setting_get $app port)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK THE SYNTAX OF THE PATHS
|
# CHECK THE SYNTAX OF THE PATHS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Check the syntax of the paths"
|
||||||
|
|
||||||
test -n "$old_path" || old_path="/"
|
test -n "$old_path" || old_path="/"
|
||||||
test -n "$new_path" || new_path="/"
|
test -n "$new_path" || new_path="/"
|
||||||
|
@ -35,6 +44,7 @@ old_path=$(ynh_normalize_url_path $old_path)
|
||||||
#=================================================
|
#=================================================
|
||||||
# ACTIVATE MAINTENANCE MODE
|
# ACTIVATE MAINTENANCE MODE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Activate maintenance mode" --weight=2
|
||||||
|
|
||||||
path_url=$old_path
|
path_url=$old_path
|
||||||
domain=$old_domain
|
domain=$old_domain
|
||||||
|
@ -61,7 +71,7 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
# Nettoyage des résidus d'installation non pris en charge par le script remove.
|
# Clean installation remainings that are not handled by the remove script.
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
|
@ -72,6 +82,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY URL IN NGINX CONF
|
# MODIFY URL IN NGINX CONF
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Modify url in nginx configuration" --weight=3
|
||||||
|
|
||||||
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
|
|
||||||
|
@ -81,30 +92,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,28 +110,36 @@ 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_script_progression --message="Reload nginx"
|
||||||
|
|
||||||
ynh_system_reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK ETHERPAD STARTING
|
# CHECK ETHERPAD STARTING
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restart Etherpad" --weight=10
|
||||||
|
|
||||||
# Wait for etherpad 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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Disable maintenance mode" --weight=5
|
||||||
|
|
||||||
path_url=$old_path
|
path_url=$old_path
|
||||||
domain=$old_domain
|
domain=$old_domain
|
||||||
ynh_maintenance_mode_OFF
|
ynh_maintenance_mode_OFF
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Change of url completed" --last
|
||||||
|
|
153
scripts/install
153
scripts/install
|
@ -16,14 +16,16 @@ source _variables
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
# Nettoyage des résidus d'installation non pris en charge par le script remove.
|
# Clean installation remainings that are not handled by the remove script.
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
}
|
}
|
||||||
ynh_abort_if_errors # Active trap pour arrêter le script si une erreur est détectée.
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Retrieve arguments from the manifest"
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url=$YNH_APP_ARG_PATH
|
path_url=$YNH_APP_ARG_PATH
|
||||||
|
@ -40,11 +42,12 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Check if the app can be installed"
|
||||||
|
|
||||||
ynh_print_OFF
|
ynh_print_OFF
|
||||||
if [ "${#password}" -lt 8 ] || [ "${#password}" -gt 30 ]
|
if [ "${#password}" -lt 8 ] || [ "${#password}" -gt 30 ]
|
||||||
then
|
then
|
||||||
ynh_die "The password must have between 8 and 30 characters."
|
ynh_die "The password must be between 8 and 30 characters."
|
||||||
fi
|
fi
|
||||||
ynh_print_ON
|
ynh_print_ON
|
||||||
|
|
||||||
|
@ -54,14 +57,13 @@ 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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Store settings from manifest" --weight=3
|
||||||
|
|
||||||
ynh_app_setting_set $app domain $domain
|
ynh_app_setting_set $app domain $domain
|
||||||
ynh_app_setting_set $app path $path_url
|
ynh_app_setting_set $app path $path_url
|
||||||
|
@ -73,24 +75,21 @@ 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
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIND AND OPEN A PORT
|
# FIND AND OPEN A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Find a free port" --weight=2
|
||||||
|
|
||||||
port=$(ynh_find_port 9001) # Look for an available port
|
# Find a free port
|
||||||
|
port=$(ynh_find_port 9001)
|
||||||
ynh_app_setting_set $app port $port
|
ynh_app_setting_set $app port $port
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install dependencies" --weight=120
|
||||||
|
|
||||||
if [ "$export" = "abiword" ]; then
|
if [ "$export" = "abiword" ]; then
|
||||||
ynh_install_app_dependencies $abiword_app_depencencies
|
ynh_install_app_dependencies $abiword_app_depencencies
|
||||||
|
@ -101,12 +100,14 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL NODEJS
|
# INSTALL NODEJS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install NodeJS" --weight=12
|
||||||
|
|
||||||
ynh_install_nodejs $nodejs_version
|
ynh_install_nodejs $nodejs_version
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A SQL DB
|
# CREATE A MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Create a mysql database"
|
||||||
|
|
||||||
db_name=$(ynh_sanitize_dbid $app)
|
db_name=$(ynh_sanitize_dbid $app)
|
||||||
ynh_app_setting_set $app db_name $db_name
|
ynh_app_setting_set $app db_name $db_name
|
||||||
|
@ -115,32 +116,34 @@ ynh_mysql_setup_db $db_name $db_name
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Download, check and unpack source" --weight=4
|
||||||
|
|
||||||
ynh_app_setting_set $app final_path $final_path
|
ynh_app_setting_set $app final_path $final_path
|
||||||
ynh_setup_source "$final_path" # Download, check integrity and uncompress the source from app.src
|
# Download, check integrity and uncompress the source from app.src
|
||||||
|
ynh_setup_source "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure nginx" --weight=2
|
||||||
|
|
||||||
if [ "$path_url" != "/" ]
|
# Create a dedicated nginx config
|
||||||
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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Create a dedicated user" --weight=3
|
||||||
|
|
||||||
ynh_system_user_create $app $final_path # Create a dedicated system user
|
# Create a dedicated system user
|
||||||
|
ynh_system_user_create $app $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
#=================================================
|
#=================================================
|
||||||
# HANDLE LOG FILES AND LOGROTATE
|
# HANDLE LOG FILES AND LOGROTATE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure logrotate"
|
||||||
|
|
||||||
# Create log directory
|
# Create log directory
|
||||||
mkdir -p /var/log/$app
|
mkdir -p /var/log/$app
|
||||||
|
@ -155,8 +158,9 @@ ynh_use_logrotate
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL ETHERPAD
|
# INSTALL ETHERPAD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install Etherpad" --weight=90
|
||||||
|
|
||||||
# Install dependencies and proceed with the installation
|
# Install dependencies and proceed to the installation
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
"$final_path/bin/installDeps.sh" > $install_log 2>&1
|
"$final_path/bin/installDeps.sh" > $install_log 2>&1
|
||||||
npm install forever -g >> $install_log 2>&1
|
npm install forever -g >> $install_log 2>&1
|
||||||
|
@ -164,6 +168,7 @@ npm install forever -g >> $install_log 2>&1
|
||||||
#=================================================
|
#=================================================
|
||||||
# CONFIGURE ETHERPAD
|
# CONFIGURE ETHERPAD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure Etherpad" --weight=6
|
||||||
|
|
||||||
cp ../conf/settings.json "$final_path/settings.json"
|
cp ../conf/settings.json "$final_path/settings.json"
|
||||||
cp ../conf/credentials.json "$final_path/credentials.json"
|
cp ../conf/credentials.json "$final_path/credentials.json"
|
||||||
|
@ -174,12 +179,16 @@ ynh_replace_string "__ADMIN__" "$admin" "$final_path/credentials.json"
|
||||||
ynh_print_OFF; ynh_replace_special_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON
|
ynh_print_OFF; ynh_replace_special_string "__PASSWD__" "$password" "$final_path/credentials.json"; ynh_print_ON
|
||||||
if [ "$export" = "abiword" ]
|
if [ "$export" = "abiword" ]
|
||||||
then
|
then
|
||||||
abiword_path=`which abiword` # Get abiword binary path
|
# 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
|
abiword_path=`which abiword`
|
||||||
|
# Set the path of abiword into etherpad config
|
||||||
|
ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json"
|
||||||
elif [ "$export" = "libreoffice" ]
|
elif [ "$export" = "libreoffice" ]
|
||||||
then
|
then
|
||||||
soffice_path=`which soffice` # Get soffice binary path
|
# 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
|
soffice_path=`which soffice`
|
||||||
|
# Set the path of soffice into etherpad config
|
||||||
|
ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json"
|
||||||
fi
|
fi
|
||||||
ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json"
|
ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json"
|
||||||
|
|
||||||
|
@ -189,8 +198,10 @@ 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" # Store config file checksum
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum "$final_path/credentials.json" # Store config file checksum
|
ynh_store_file_checksum "$final_path/settings.json"
|
||||||
|
# Calculate and store the config file checksum into the app settings
|
||||||
|
ynh_store_file_checksum "$final_path/credentials.json"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURING FILES AND DIRECTORIES
|
# SECURING FILES AND DIRECTORIES
|
||||||
|
@ -198,44 +209,62 @@ ynh_store_file_checksum "$final_path/credentials.json" # Store config file check
|
||||||
|
|
||||||
# Set files ownership to etherpad
|
# Set files ownership to etherpad
|
||||||
chown -R $app: $final_path
|
chown -R $app: $final_path
|
||||||
chmod 600 $final_path/credentials.json # Restrict access to credentials.json
|
# Restrict access to credentials.json
|
||||||
|
chmod 600 $final_path/credentials.json
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure systemd" --weight=4
|
||||||
|
|
||||||
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
|
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
|
||||||
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENABLE SERVICE IN ADMIN PANEL
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Add service to YunoHost monitoring panel
|
|
||||||
yunohost service add $app --log "/var/log/$app/etherpad.log"
|
yunohost service add $app --log "/var/log/$app/etherpad.log"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL FRAMAPAD'S PLUGINS
|
# INSTALL FRAMAPAD'S PLUGINS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Install Etherpad plugins" --weight=90
|
||||||
|
|
||||||
pushd "$final_path"
|
pushd "$final_path"
|
||||||
npm install ep_align # Add Left/Center/Right/Justify to lines of text in a pad
|
# Add Left/Center/Right/Justify to lines of text in a pad
|
||||||
npm install ep_author_hover >> $install_log 2>&1 # Framapad - Adds author names to span titles
|
npm install ep_align >> $install_log 2>&1
|
||||||
npm install ep_automatic_logut >> $install_log 2>&1 # Automatically disconnects user after some period of time (Prevent server overload)
|
# Framapad - Adds author names to span titles
|
||||||
npm install ep_comments_page >> $install_log 2>&1 # Framapad - Adds comments on sidebar and link it to the text.
|
npm install ep_author_hover >> $install_log 2>&1
|
||||||
npm install ep_countable >> $install_log 2>&1 # Framapad - Displays paragraphs, sentences, words and characters counts.
|
# Automatically disconnects user after some period of time (Prevent server overload)
|
||||||
npm install ep_delete_empty_pads >> $install_log 2>&1 # Framapad - Delete pads which were never edited
|
npm install ep_automatic_logut >> $install_log 2>&1
|
||||||
npm install ep_font_color >> $install_log 2>&1 # Framapad - Apply colors to fonts
|
# Framapad - Adds comments on sidebar and link it to the text.
|
||||||
npm install ep_headings2 >> $install_log 2>&1 # Framapad - Adds heading support to Etherpad Lite.
|
npm install ep_comments_page >> $install_log 2>&1
|
||||||
npm install ep_markdown >> $install_log 2>&1 # Framapad - Edit and Export as Markdown in Etherpad
|
# Framapad - Displays paragraphs, sentences, words and characters counts.
|
||||||
|
npm install ep_countable >> $install_log 2>&1
|
||||||
|
# Framapad - Delete pads which were never edited
|
||||||
|
npm install ep_delete_empty_pads >> $install_log 2>&1
|
||||||
|
# Framapad - Apply colors to fonts
|
||||||
|
npm install ep_font_color >> $install_log 2>&1
|
||||||
|
# Framapad - Adds heading support to Etherpad Lite.
|
||||||
|
npm install ep_headings2 >> $install_log 2>&1
|
||||||
|
# Framapad - Edit and Export as Markdown in Etherpad
|
||||||
|
npm install ep_markdown >> $install_log 2>&1
|
||||||
if [ $mypads -eq 1 ]; then
|
if [ $mypads -eq 1 ]; then
|
||||||
npm install ep_mypads@${mypads_version} >> $install_log 2>&1 # Framapad - Groups and private pads for etherpad
|
# Framapad - Groups and private pads for etherpad
|
||||||
|
npm install ep_mypads@${mypads_version} >> $install_log 2>&1
|
||||||
fi
|
fi
|
||||||
npm install ep_page_view >> $install_log 2>&1 # Framapad - Add support to do 'page view', with a toggle on/off option in Settings, also Page Breaks with Control Enter
|
# Framapad - Add support to do 'page view', with a toggle on/off option in Settings, also Page Breaks with Control Enter
|
||||||
npm install ep_spellcheck >> $install_log 2>&1 # Framapad - Add support to do 'Spell checking'
|
npm install ep_page_view >> $install_log 2>&1
|
||||||
npm install ep_subscript_and_superscript >> $install_log 2>&1 # Framapad - Add support for Subscript and Superscript
|
# Framapad - Add support to do 'Spell checking'
|
||||||
npm install ep_table_of_contents >> $install_log 2>&1 # Framapad - View a table of contents for your pad
|
npm install ep_spellcheck >> $install_log 2>&1
|
||||||
npm install ep_user_font_size >> $install_log 2>&1 # Framapad - User Pad Contents font size can be set in settings, this does not effect other peoples views
|
# Framapad - Add support for Subscript and Superscript
|
||||||
|
npm install ep_subscript_and_superscript >> $install_log 2>&1
|
||||||
|
# Framapad - View a table of contents for your pad
|
||||||
|
npm install ep_table_of_contents >> $install_log 2>&1
|
||||||
|
# Framapad - User Pad Contents font size can be set in settings, this does not effect other peoples views
|
||||||
|
npm install ep_user_font_size >> $install_log 2>&1
|
||||||
popd
|
popd
|
||||||
chown -R $app: $final_path/node_modules
|
chown -R $app: $final_path/node_modules
|
||||||
|
|
||||||
|
@ -252,38 +281,46 @@ then
|
||||||
ynh_replace_string "^ *\"FOOTER\": .*2.0" "& | <a href='../admin'>Etherpad admin</a>" $final_path/node_modules/ep_mypads/static/l10n/en.json
|
ynh_replace_string "^ *\"FOOTER\": .*2.0" "& | <a href='../admin'>Etherpad admin</a>" $final_path/node_modules/ep_mypads/static/l10n/en.json
|
||||||
ynh_replace_string "^ *\"FOOTER\": .*2.0" "& | <a href='../admin'>Etherpad admin</a>" $final_path/node_modules/ep_mypads/static/l10n/fr.json
|
ynh_replace_string "^ *\"FOOTER\": .*2.0" "& | <a href='../admin'>Etherpad admin</a>" $final_path/node_modules/ep_mypads/static/l10n/fr.json
|
||||||
|
|
||||||
mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "</div>" | cut -d '-' -f 1) # Recherche le /div situé sous le champs d'ouverture de pad.
|
# Find the /div just after the field to open a pad
|
||||||
sed -i "$mod_line s@div>@&\n\t<center><br><font size="5"><a href="./mypads/">Mypads</a></font></center>@" $final_path/src/templates/index.html # Pour ajouter un lien vers le plugin mypads depuis la page d'Etherpad.
|
mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "</div>" | cut -d '-' -f 1)
|
||||||
|
# In order to add a link to mypads plugin.
|
||||||
|
sed -i "$mod_line s@div>@&\n\t<center><br><font size="5"><a href="./mypads/">Mypads</a></font></center>@" $final_path/src/templates/index.html
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP FAIL2BAN
|
# SETUP FAIL2BAN
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configure fail2ban" --weight=13
|
||||||
|
|
||||||
ynh_add_fail2ban_config "/var/log/nginx/$domain-access.log" "<HOST> .* \"POST /mypads/api/auth/login HTTP/1.1\" 400" 5
|
# Create a dedicated fail2ban config
|
||||||
|
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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Setup SSOwat"
|
||||||
|
|
||||||
if [ $is_public -eq 1 ]; then
|
if [ $is_public -eq 1 ]; then
|
||||||
ynh_app_setting_set $app skipped_uris "/"
|
ynh_app_setting_set $app skipped_uris "/"
|
||||||
else
|
else
|
||||||
ynh_app_setting_set $app skipped_uris "/admin" # etherpad admin page doesn't support SSO...
|
# etherpad admin page doesn't support SSO...
|
||||||
|
ynh_app_setting_set $app skipped_uris "/admin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reload nginx"
|
||||||
|
|
||||||
ynh_system_reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK ETHERPAD STARTING
|
# CHECK ETHERPAD STARTING
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restart Etherpad" --weight=20
|
||||||
|
|
||||||
# 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,15 +328,9 @@ 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
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# DEACTIVE MAINTENANCE MODE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
ynh_maintenance_mode_OFF
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SEND A README FOR THE ADMIN
|
# SEND A README FOR THE ADMIN
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -323,3 +354,9 @@ If you are facing an issue or want to improve this app, please open a new issue
|
||||||
|
|
||||||
ynh_send_readme_to_admin "$message" "$admin"
|
ynh_send_readme_to_admin "$message" "$admin"
|
||||||
ynh_print_ON
|
ynh_print_ON
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Installation completed" --last
|
||||||
|
|
|
@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Load settings" --weight=3
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -25,16 +26,19 @@ export=$(ynh_app_setting_get $app export)
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP AND REMOVE SERVICE
|
# STOP AND REMOVE SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Stop and remove the service" --weight=2
|
||||||
|
|
||||||
|
# Remove the dedicated systemd config
|
||||||
ynh_remove_systemd_config
|
ynh_remove_systemd_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DISABLE SERVICE IN ADMIN PANEL
|
# REMOVE SERVICE FROM ADMIN PANEL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if yunohost service status | grep -q $app # Check if service is declared in YunoHost
|
# Check if the service is declared in YunoHost
|
||||||
|
if yunohost service status | grep -q $app
|
||||||
then
|
then
|
||||||
ynh_print_info "Remove $app service" >&2
|
ynh_print_info "Remove $app service"
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -44,43 +48,56 @@ fi
|
||||||
|
|
||||||
if [ "$export" != "none" ]
|
if [ "$export" != "none" ]
|
||||||
then
|
then
|
||||||
|
ynh_script_progression --message="Remove dependencies" --weight=60
|
||||||
|
# Remove metapackage and its dependencies
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE NODEJS
|
# REMOVE NODEJS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove NodeJS version for Etherpad" --weight=3
|
||||||
|
|
||||||
ynh_remove_nodejs
|
ynh_remove_nodejs
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE SQL DB
|
# REMOVE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove the mysql database" --weight=2
|
||||||
|
|
||||||
ynh_mysql_remove_db $db_name $db_name # Remove the database along with the associated user
|
# Remove a database if it exists, along with the associated user
|
||||||
|
ynh_mysql_remove_db $db_name $db_name
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE MAIN DIR OF THE APP
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove app main directory"
|
||||||
|
|
||||||
ynh_secure_remove "/var/www/$app" # Remove the app directory securely
|
# Remove the app directory securely
|
||||||
|
ynh_secure_remove "/var/www/$app"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE NGINX CONFIGURATION
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove nginx configuration" --weight=2
|
||||||
|
|
||||||
ynh_remove_nginx_config # Remove the dedicated nginx config
|
# Remove the dedicated nginx config
|
||||||
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE LOGROTATE CONFIG
|
# REMOVE LOGROTATE CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove logrotate configuration"
|
||||||
|
|
||||||
ynh_remove_logrotate # Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
|
ynh_remove_logrotate
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE FAIL2BAN CONFIGURATION
|
# REMOVE FAIL2BAN CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove fail2ban configuration" --weight=7
|
||||||
|
|
||||||
|
# Remove the dedicated fail2ban config
|
||||||
ynh_remove_fail2ban_config
|
ynh_remove_fail2ban_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -88,5 +105,13 @@ ynh_remove_fail2ban_config
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Remove the dedicated user" --weight=2
|
||||||
|
|
||||||
|
# Delete dedicated system user
|
||||||
ynh_system_user_delete $app
|
ynh_system_user_delete $app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Deletion completed" --last
|
||||||
|
|
|
@ -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
|
||||||
|
@ -21,7 +16,7 @@ source ../settings/scripts/_variables
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
# Nettoyage des résidus d'installation non pris en charge par le script remove.
|
# Clean installation remainings that are not handled by the remove script.
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
|
@ -30,6 +25,7 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Load settings" --weight=4
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -54,26 +50,29 @@ test ! -d $final_path \
|
||||||
#=================================================
|
#=================================================
|
||||||
# ACTIVATE MAINTENANCE MODE
|
# ACTIVATE MAINTENANCE MODE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Activate maintenance mode" --weight=2
|
||||||
|
|
||||||
ynh_maintenance_mode_ON
|
ynh_maintenance_mode_ON
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD RESTORE STEPS
|
# STANDARD RESTORE STEPS
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE OF THE NGINX CONFIGURATION
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE OF THE MAIN DIR OF THE APP
|
# RESTORE THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restore the app main directory"
|
||||||
|
|
||||||
ynh_restore_file "$final_path"
|
ynh_restore_file "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE SQL DB
|
# RESTORE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restore the mysql database"
|
||||||
|
|
||||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||||
|
@ -82,8 +81,10 @@ ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||||
#=================================================
|
#=================================================
|
||||||
# RECREATE THE DEDICATED USER
|
# RECREATE THE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Recreate the dedicated user" --weight=2
|
||||||
|
|
||||||
ynh_system_user_create $app $final_path # Recreate the dedicated user, if it doesn't exist
|
# Create the dedicated user (if not existing)
|
||||||
|
ynh_system_user_create $app $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORE
|
# SPECIFIC RESTORE
|
||||||
|
@ -104,6 +105,7 @@ ynh_restore_file "/etc/logrotate.d/$app"
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reinstall dependencies" --weight=60
|
||||||
|
|
||||||
if [ "$export" = "abiword" ]; then
|
if [ "$export" = "abiword" ]; then
|
||||||
ynh_install_app_dependencies $abiword_app_depencencies
|
ynh_install_app_dependencies $abiword_app_depencencies
|
||||||
|
@ -114,26 +116,28 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL NODEJS
|
# INSTALL NODEJS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reinstall NodeJS" --weight=7
|
||||||
|
|
||||||
ynh_install_nodejs $nodejs_version
|
ynh_install_nodejs $nodejs_version
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL ETHERPAD DEPENDENCIES
|
# INSTALL ETHERPAD DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reinstall Etherpad node dependencies" --weight=17
|
||||||
|
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
npm cache clean
|
npm cache clean
|
||||||
npm install forever -g >> $install_log 2>&1
|
npm install forever -g >> $install_log 2>&1
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURING FILES AND DIRECTORIES
|
# RESTORE USER RIGHTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# Set files ownership to etherpad
|
# Restore permissions on app files
|
||||||
chown -R $app: $final_path
|
chown -R $app: $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ENABLE SERVICE IN ADMIN PANEL
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
yunohost service add $app --log "/var/log/$app/etherpad.log"
|
yunohost service add $app --log "/var/log/$app/etherpad.log"
|
||||||
|
@ -141,35 +145,39 @@ yunohost service add $app --log "/var/log/$app/etherpad.log"
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE SYSTEMD
|
# RESTORE SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restore the systemd configuration"
|
||||||
|
|
||||||
ynh_restore_file "/etc/systemd/system/$app.service"
|
ynh_restore_file "/etc/systemd/system/$app.service"
|
||||||
## Démarrage auto du service
|
|
||||||
systemctl enable $app.service
|
systemctl enable $app.service
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE FAIL2BAN CONFIGURATION
|
# RESTORE FAIL2BAN CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restore the fail2ban configuration" --weight=6
|
||||||
|
|
||||||
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_script_progression --message="Reload nginx"
|
||||||
|
|
||||||
ynh_system_reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK ETHERPAD STARTING
|
# CHECK ETHERPAD STARTING
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restart Etherpad" --weight=8
|
||||||
|
|
||||||
# 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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Disable maintenance mode" --weight=7
|
||||||
|
|
||||||
ynh_maintenance_mode_OFF
|
ynh_maintenance_mode_OFF
|
||||||
|
|
||||||
|
@ -196,3 +204,9 @@ If you are facing an issue or want to improve this app, please open a new issue
|
||||||
|
|
||||||
ynh_send_readme_to_admin "$message" "$admin"
|
ynh_send_readme_to_admin "$message" "$admin"
|
||||||
ynh_print_ON
|
ynh_print_ON
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Restoration completed" --last
|
||||||
|
|
180
scripts/upgrade
180
scripts/upgrade
|
@ -14,6 +14,7 @@ source _variables
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Load settings" --weight=20
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
@ -34,33 +35,38 @@ 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
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Ensure downward compatibility" --weight=2
|
||||||
|
|
||||||
|
# Convert is_public as a boolean
|
||||||
if [ "$is_public" = "Yes" ]; then
|
if [ "$is_public" = "Yes" ]; then
|
||||||
ynh_app_setting_set $app is_public 1 # Convert is_public to boolean
|
ynh_app_setting_set $app is_public 1
|
||||||
is_public=1
|
is_public=1
|
||||||
elif [ "$is_public" = "No" ]; then
|
elif [ "$is_public" = "No" ]; then
|
||||||
ynh_app_setting_set $app is_public 0
|
ynh_app_setting_set $app is_public 0
|
||||||
is_public=0
|
is_public=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $db_name ]; then # If db_name setting doesn't exist
|
# If db_name setting doesn't exist
|
||||||
|
if [ -z $db_name ]; then
|
||||||
db_name=$(ynh_sanitize_dbid $app)
|
db_name=$(ynh_sanitize_dbid $app)
|
||||||
ynh_app_setting_set $app db_name $db_name
|
ynh_app_setting_set $app db_name $db_name
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $abiword ]; then # If abiword setting doesn't exist
|
# If abiword setting doesn't exist
|
||||||
|
if [ -z $abiword ]; then
|
||||||
abiword=0
|
abiword=0
|
||||||
ynh_app_setting_set $app abiword $abiword
|
ynh_app_setting_set $app abiword $abiword
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n $abiword ]; then # If abiword setting exists
|
# If abiword setting exists
|
||||||
|
if [ -n $abiword ]; then
|
||||||
if [ $abiword -eq 1 ]; then
|
if [ $abiword -eq 1 ]; then
|
||||||
export=abiword
|
export=abiword
|
||||||
fi
|
fi
|
||||||
|
@ -68,22 +74,26 @@ if [ -n $abiword ]; then # If abiword setting exists
|
||||||
ynh_app_setting_delete $app abiword
|
ynh_app_setting_delete $app abiword
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $export ]; then # If export setting doesn't exist
|
# If export setting doesn't exist
|
||||||
|
if [ -z $export ]; then
|
||||||
export=none
|
export=none
|
||||||
ynh_app_setting_set $app export $export
|
ynh_app_setting_set $app export $export
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $mypads ]; then # If mypads setting doesn't exist
|
# If mypads setting doesn't exist
|
||||||
|
if [ -z $mypads ]; then
|
||||||
mypads=1
|
mypads=1
|
||||||
ynh_app_setting_set $app mypads $mypads
|
ynh_app_setting_set $app mypads $mypads
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $useldap ]; then # If useldap setting doesn't exist
|
# If useldap setting doesn't exist
|
||||||
|
if [ -z $useldap ]; then
|
||||||
useldap=0
|
useldap=0
|
||||||
ynh_app_setting_set $app useldap $useldap
|
ynh_app_setting_set $app useldap $useldap
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $path_url ]; then # If path_url setting doesn't exist
|
# If path_url setting doesn't exist
|
||||||
|
if [ -z $path_url ]; then
|
||||||
path_url="/"
|
path_url="/"
|
||||||
ynh_app_setting_set $app path $path_url
|
ynh_app_setting_set $app path $path_url
|
||||||
fi
|
fi
|
||||||
|
@ -91,14 +101,15 @@ fi
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backup the app before upgrading" --weight=35
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
ynh_clean_setup () {
|
ynh_clean_setup () {
|
||||||
# Cleanup installatioNettoyage des résidus d'installation non pris en charge par le script remove.
|
# Clean installation remainings that are not handled by the remove script.
|
||||||
ynh_clean_check_starting
|
ynh_clean_check_starting
|
||||||
|
|
||||||
# restore it if the upgrade fails
|
# Restore it if the upgrade fails
|
||||||
ynh_restore_upgradebackup
|
ynh_restore_upgradebackup
|
||||||
}
|
}
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
|
@ -107,14 +118,16 @@ ynh_abort_if_errors
|
||||||
#=================================================
|
#=================================================
|
||||||
# ACTIVATE MAINTENANCE MODE
|
# ACTIVATE MAINTENANCE MODE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Activate maintenance mode" --weight=2
|
||||||
|
|
||||||
ynh_maintenance_mode_ON
|
ynh_maintenance_mode_ON
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP ETHERPAD
|
# STOP ETHERPAD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Stop Etherpad service" --weight=3
|
||||||
|
|
||||||
ynh_system_reload $app stop
|
ynh_systemd_action --action=stop
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD UPGRADE STEPS
|
# STANDARD UPGRADE STEPS
|
||||||
|
@ -122,22 +135,35 @@ 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
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source "$final_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Download, check and unpack source" --weight=5
|
||||||
|
|
||||||
|
if [ "$export" = "abiword" ]; then
|
||||||
|
ynh_install_app_dependencies $abiword_app_depencencies
|
||||||
|
elif [ "$export" = "libreoffice" ]; then
|
||||||
|
ynh_install_app_dependencies $libreoffice_app_dependencies
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reconfigure nginx"
|
||||||
|
|
||||||
if [ "$path_url" != "/" ]
|
# Create a dedicated nginx config
|
||||||
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
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE NODEJS
|
# UPGRADE NODEJS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrade NodeJS" --weight=4
|
||||||
|
|
||||||
# Remove the old nvm helper.
|
# Remove the old nvm helper.
|
||||||
if [ -d /opt/nvm ]
|
if [ -d /opt/nvm ]
|
||||||
|
@ -151,6 +177,7 @@ ynh_install_nodejs $nodejs_version
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE NPM MODULES
|
# UPGRADE NPM MODULES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrade Etherpad npm modules" --weight=60
|
||||||
|
|
||||||
# Update the main modules of etherpad
|
# Update the main modules of etherpad
|
||||||
(cd "$final_path/src"
|
(cd "$final_path/src"
|
||||||
|
@ -172,46 +199,61 @@ 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_script_progression --message="Reconfigure Etherpad" --weight=3
|
||||||
ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
|
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||||
elif [ "$export" = "libreoffice" ]
|
ynh_backup_if_checksum_is_different "$final_path/settings.json"
|
||||||
then
|
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||||
soffice_path=`which soffice` # Get soffice binary path
|
ynh_backup_if_checksum_is_different "$final_path/credentials.json"
|
||||||
ynh_replace_string "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$final_path/settings.json" # Renseigne l'emplacement de abiword dans la config de etherpad
|
cp ../conf/settings.json "$final_path/settings.json"
|
||||||
fi
|
cp ../conf/credentials.json "$final_path/credentials.json"
|
||||||
if test -z $language; then
|
ynh_replace_string "__PORT__" "$port" "$final_path/settings.json"
|
||||||
language=en # If upgrading from a version which doesn't support translations, set language to English by default
|
ynh_replace_string "__DB_USER__" "$app" "$final_path/credentials.json"
|
||||||
ynh_app_setting_set $app language $language
|
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||||
fi
|
ynh_print_OFF; password=$(ynh_app_setting_get $app password); ynh_print_ON
|
||||||
ynh_replace_string "__LANGUAGE__" "$language" "$final_path/settings.json"
|
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
|
||||||
|
# Get abiword binary path
|
||||||
|
abiword_path=`which abiword`
|
||||||
|
# Set the path of abiword into etherpad config
|
||||||
|
ynh_replace_string "\"abiword\" : null" "\"abiword\" : \"$abiword_path\"" "$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 "\"soffice\" : null" "\"soffice\" : \"$soffice_path\"" "$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 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
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
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/settings.json"
|
||||||
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
|
ynh_store_file_checksum "$final_path/credentials.json"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Create a dedicated user"
|
||||||
|
|
||||||
ynh_system_user_create $app $final_path # Create the dedicated user, if it doesn't exist
|
# Create a dedicated user (if not existing)
|
||||||
|
ynh_system_user_create $app $final_path
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SECURING FILES AND DIRECTORIES
|
# SECURING FILES AND DIRECTORIES
|
||||||
|
@ -219,26 +261,33 @@ ynh_system_user_create $app $final_path # Create the dedicated user, if it doesn
|
||||||
|
|
||||||
# Set files ownership to etherpad
|
# Set files ownership to etherpad
|
||||||
chown -R $app: $final_path
|
chown -R $app: $final_path
|
||||||
chmod 600 "$final_path/credentials.json" # Restrict access to credentials.json
|
chmod 600 "$final_path/credentials.json"
|
||||||
|
# Restrict access to credentials.json
|
||||||
chown $app -R /var/log/$app/etherpad.log
|
chown $app -R /var/log/$app/etherpad.log
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE FAIL2BAN
|
# UPGRADE FAIL2BAN
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reconfigure fail2ban" --weight=8
|
||||||
|
|
||||||
ynh_add_fail2ban_config "/var/log/nginx/$domain-access.log" "<HOST> .* \"POST /mypads/api/auth/login HTTP/1.1\" 400" 5
|
# Create a dedicated fail2ban config
|
||||||
|
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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reconfigure logrotate"
|
||||||
|
|
||||||
|
# Use logrotate to manage app-specific logfile(s)
|
||||||
ynh_use_logrotate --non-append
|
ynh_use_logrotate --non-append
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SYSTEMD
|
# SETUP SYSTEMD
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reconfigure systemd" --weight=2
|
||||||
|
|
||||||
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
|
ynh_replace_string "__ENV_PATH__" "$PATH" "../conf/systemd.service"
|
||||||
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -247,36 +296,49 @@ ynh_add_systemd_config
|
||||||
|
|
||||||
if [ $mypads -eq 1 ]
|
if [ $mypads -eq 1 ]
|
||||||
then
|
then
|
||||||
mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "</div>" | cut -d '-' -f 1) # Recherche le /div situé sous le champs d'ouverture de pad.
|
# Find the /div just after the field to open a pad
|
||||||
sed -i "$mod_line s@div>@&\n\t<center><br><font size="5"><a href="./mypads/">Mypads</a></font></center>@" $final_path/src/templates/index.html # Pour ajouter un lien vers le plugin mypads depuis la page d'Etherpad.
|
mod_line=$(grep -nA5 "index.createOpenPad" $final_path/src/templates/index.html | grep "</div>" | cut -d '-' -f 1)
|
||||||
|
# In order to add a link to mypads plugin.
|
||||||
|
sed -i "$mod_line s@div>@&\n\t<center><br><font size="5"><a href="./mypads/">Mypads</a></font></center>@" $final_path/src/templates/index.html
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reconfigure SSOwat"
|
||||||
|
|
||||||
# Make app public if necessary
|
# Make app public if necessary
|
||||||
if [ $is_public -eq 1 ]; then
|
if [ $is_public -eq 1 ]; then
|
||||||
ynh_app_setting_set $app skipped_uris "/"
|
ynh_app_setting_set $app skipped_uris "/"
|
||||||
else
|
else
|
||||||
ynh_app_setting_set $app skipped_uris "/admin" # etherpad admin page doesn't support SSO...
|
# etherpad admin page doesn't support SSO...
|
||||||
|
ynh_app_setting_set $app skipped_uris "/admin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reload nginx"
|
||||||
|
|
||||||
ynh_system_reload nginx
|
ynh_systemd_action --action=reload --service_name=nginx
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK ETHERPAD STARTING
|
# CHECK ETHERPAD STARTING
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restart Etherpad" --weight=9
|
||||||
|
|
||||||
# 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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Disable maintenance mode" --weight=5
|
||||||
|
|
||||||
ynh_maintenance_mode_OFF
|
ynh_maintenance_mode_OFF
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Upgrade completed" --last
|
||||||
|
|
Loading…
Add table
Reference in a new issue