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

Merge pull request #42 from YunoHost-Apps/testing

Testing
This commit is contained in:
Maniack Crudelis 2020-01-02 18:56:19 +01:00 committed by GitHub
commit 316b3dfe87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 791 additions and 898 deletions

55
CHANGELOG.md Normal file
View file

@ -0,0 +1,55 @@
Changelog
=========
## Unreleased
- Nothing for now...
## [0.11.6~ynh1](https://github.com/YunoHost-Apps/lutim_ynh/pull/42) - 2020-01-02
#### Added
* [Set workers according to cpu](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/58e291949769d678ec48306199bcc03e3be20631)
- [Add changelog](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/b0859ab1612c22d210321d6302cad7872ec17abd)
#### Fixed
- [Fix cron tasks](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/dec8d0820fb46e984b2ca65e1012f5f737861965)
#### Changed
- [Update to last standard](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/5e5bf7c7a8f68b0768555005797ec3024a223299) [(twice)](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/51113ba7544991a3400abc9a78258ba594d58b4b)
- [Use toml for actions and config-panel](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/4f7bac24481138654e3e3128ba6637cdf8855855)
* [Update to 0.11.6](https://github.com/YunoHost-Apps/lutim_ynh/pull/42/commits/4b50a261fb4515aa2a32b7ca20c750c322bfd5c0)
## [0.11.5~ynh1](https://github.com/YunoHost-Apps/lutim_ynh/pull/35) - 2019-05-06
#### Changed
* [Update to Lutim 0.11.5](https://github.com/YunoHost-Apps/lutim_ynh/pull/35)
## [0.11.4~ynh3](https://github.com/YunoHost-Apps/lutim_ynh/pull/33) - 2019-02-18
#### Changed
- [Upgrade protected_regex](https://github.com/YunoHost-Apps/lutim_ynh/pull/33)
## [0.11.4~ynh2](https://github.com/YunoHost-Apps/lutim_ynh/pull/31) - 2019-02-03
#### Added
- [Add progression bar](https://github.com/YunoHost-Apps/lutim_ynh/pull/31/commits/6b63a2ce2feca4550e55f2404e8b18f13ef58fc7)
- [Changelog & html email](https://github.com/YunoHost-Apps/lutim_ynh/pull/31/commits/746d00174c3fde429f64b514d4f113b01780e701)
#### Fixed
- [Do not open port](https://github.com/YunoHost-Apps/lutim_ynh/pull/31/commits/0c2af89b610a420129588e62537bb248d7810777)
- [Delete dedicated user](https://github.com/YunoHost-Apps/lutim_ynh/pull/31/commits/f9d7f124f0966870004aa620ac4626dd8ebb19ff)
## [0.11.4~ynh1](https://github.com/YunoHost-Apps/lutim_ynh/pull/30) - 2019-01-21
#### Changed
* [Update to Lutim 0.11.4](https://github.com/YunoHost-Apps/lutim_ynh/pull/30/commits/0b3640581ce18b9f823baae7130ab0645f9f1e8e)
- [Update to last standart](https://github.com/YunoHost-Apps/lutim_ynh/pull/30/commits/9d37c8b9f50ef728ebe4a05031de4c70f76940b4)
## [0.10.4~ynh2](https://github.com/YunoHost-Apps/lutim_ynh/pull/29) - 2018-09-30
#### Added
* [Panel-config + actions fully tested](https://github.com/YunoHost-Apps/lutim_ynh/pull/29/commits/6cf6b6331170fd6f36575c9c06a17b11a9da66d0)

View file

@ -13,7 +13,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to
Lutim stores images and allows you to see them, download them or share them on social networks. Lutim stores images and allows you to see them, download them or share them on social networks.
Images are indefinitely stored unless you request that they will be deleted at first view or after 24 hours / one week / one month / one year. Images are indefinitely stored unless you request that they will be deleted at first view or after 24 hours / one week / one month / one year.
**Shipped version:** 0.11.5 **Shipped version:** 0.11.6
## Screenshots ## Screenshots
@ -39,9 +39,9 @@ Not relevant.
#### Supported architectures #### Supported architectures
* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/lutim%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/lutim/) * x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/lutim%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/lutim/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/lutim%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lutim/) * ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/lutim%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lutim/)
* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/lutim%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/lutim/) * Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/lutim%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/lutim/)
## Limitations ## Limitations
@ -51,6 +51,7 @@ Not relevant.
* Report a bug: https://github.com/YunoHost-Apps/lutim_ynh/issues * Report a bug: https://github.com/YunoHost-Apps/lutim_ynh/issues
* Lutim website: https://lut.im/ * Lutim website: https://lut.im/
* Dépôt de Lutim: https://framagit.org/fiat-tux/hat-softwares/lutim
* YunoHost website: https://yunohost.org/ * YunoHost website: https://yunohost.org/
--- ---

View file

@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/inst
Lutim stocke les images et vous permet de les voir, de les télécharger ou de les partager sur les réseaux sociaux. Lutim stocke les images et vous permet de les voir, de les télécharger ou de les partager sur les réseaux sociaux.
Les images sont stockées indéfiniment à moins que vous ne demandiez qu'elles soient effacées à la première vue ou après 24 heures / une semaine / un mois / un an. Les images sont stockées indéfiniment à moins que vous ne demandiez qu'elles soient effacées à la première vue ou après 24 heures / une semaine / un mois / un an.
**Version embarquée:** 0.11.5 **Version embarquée:** 0.11.6
## Captures d'écran ## Captures d'écran
@ -39,9 +39,9 @@ Non applicable.
#### Architectures supportées. #### Architectures supportées.
* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/lutim%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/lutim/) * x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/lutim%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/lutim/)
* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/lutim%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lutim/) * ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/lutim%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/lutim/)
* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/lutim%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/lutim/) * Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/lutim%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/lutim/)
## Limitations ## Limitations
@ -51,6 +51,7 @@ Non applicable.
* Reporter un bug: https://github.com/YunoHost-Apps/lutim_ynh/issues * Reporter un bug: https://github.com/YunoHost-Apps/lutim_ynh/issues
* Site de Lutim: https://lut.im/ * Site de Lutim: https://lut.im/
* Dépôt de Lutim: https://framagit.org/fiat-tux/hat-softwares/lutim
* Site de YunoHost: https://yunohost.org/ * Site de YunoHost: https://yunohost.org/
--- ---

View file

@ -1,64 +0,0 @@
[{
"id": "clean_ip",
"name": "Clean old ip from database",
"command": "/bin/bash scripts/actions/clean_ip",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Remove obsolete IP from the database.",
"fr": "Supprime les IP obsolètes de la base de donnée."
}
},
{
"id": "clean_images",
"name": "Clean old images",
"command": "/bin/bash scripts/actions/clean_images",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Remove expired images.",
"fr": "Supprime les images dont le délai a expiré."
}
},
{
"id": "check_quota",
"name": "Check disk quota",
"command": "/bin/bash scripts/actions/check_quota",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Check the disk quota for images stored by Lutim.",
"fr": "Vérifie l'occupation de l'espace du dossier des images."
}
},
{
"id": "reset_default_config",
"name": "Reset the config file and restore a default one.",
"command": "/bin/bash scripts/actions/reset_default_config \"lutim.conf\"",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Reset the config file lutim.conf.",
"fr": "Réinitialise le fichier de configuration lutim.conf."
}
},
{
"id": "public_private",
"name": "Move to public or private",
"command": "/bin/bash scripts/actions/public_private",
"user": "root",
"accepted_return_codes": [0],
"description": {
"en": "Change the public access of the app."
},
"arguments": [
{
"name": "is_public",
"type": "boolean",
"ask": {
"en": "Is it a public app ?"
},
"default": true
}
]
}]

35
actions.toml Normal file
View file

@ -0,0 +1,35 @@
[clean_ip]
name = "Clean old ip from database"
command = "/bin/bash scripts/actions/clean_ip"
accepted_return_codes = [0]
description = "Remove obsolete IP from the database."
[clean_images]
name = "Clean old images"
command = "/bin/bash scripts/actions/clean_images"
accepted_return_codes = [0]
description = "Remove expired images."
[check_quota]
name = "Check disk quota"
command = "/bin/bash scripts/actions/check_quota"
accepted_return_codes = [0]
description = "Check the disk quota for images stored by Lutim."
[reset_default_config]
name = "Reset the config file and restore a default one."
command = "/bin/bash scripts/actions/reset_default_config \"lutim.conf\""
accepted_return_codes = [0]
description = "Reset the config file lutim.conf."
[public_private]
name = "Move to public or private"
command = "/bin/bash scripts/actions/public_private"
accepted_return_codes = [0]
description = "Change the public access of the app."
[public_private.arguments]
[public_private.arguments.is_public]
type = "boolean"
ask = "Is it a public app ?"
default = true

View file

@ -15,22 +15,11 @@
upgrade=1 from_commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d upgrade=1 from_commit=4c29aa94f9d9048411c6e165e122e03574fb9b8d
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
incorrect_path=1
port_already_use=1 (8095) port_already_use=1 (8095)
change_url=1 change_url=1
;;; Levels ;;; Levels
Level 1=auto
Level 2=auto
Level 3=auto
# Level 4: Pas de gestion des utilisateurs
Level 4=na
# Level 5: https://github.com/YunoHost/package_linter/issues/36 # Level 5: https://github.com/YunoHost/package_linter/issues/36
Level 5=1 Level 5=1
Level 6=auto
Level 7=auto
Level 8=0
Level 9=0
Level 10=0
;;; Options ;;; Options
Email= Email=
Notification=down Notification=down

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lutim/-/archive/0.11.5/lutim-0.11.5.tar.gz SOURCE_URL=https://framagit.org/fiat-tux/hat-softwares/lutim/-/archive/0.11.6/lutim-0.11.6.tar.gz
SOURCE_SUM=5fd0197495da3ddcf122d0c701b62035 SOURCE_SUM=092fc5b914fc8a2dd46f7101fe94c493
SOURCE_SUM_PRG=md5sum SOURCE_SUM_PRG=md5sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -1,11 +1,11 @@
# Génération des statistiques. Tous les jours, à 5h. # Génération des statistiques. Tous les jours, à 5h.
0 5 * * * www-data cd "__FINALPATH__" && $(which carton) exec script/lutim cron stats 0 5 * * * __APP__ cd "__FINALPATH__" && $(which carton) exec script/lutim cron stats
# Suppression des adresses IP obsolètes. Tous les jours, à 6h. # Suppression des adresses IP obsolètes. Tous les jours, à 6h.
0 6 * * * www-data cd "__FINALPATH__" && $(which carton) exec script/lutim cron cleanbdd 0 6 * * * __APP__ cd "__FINALPATH__" && $(which carton) exec script/lutim cron cleanbdd
# Suppression des images dont le délai a expiré. Tous les jours, à 6h. # Suppression des images dont le délai a expiré. Tous les jours, à 6h.
0 6 * * * www-data cd "__FINALPATH__" && $(which carton) exec script/lutim cron cleanfiles 0 6 * * * __APP__ cd "__FINALPATH__" && $(which carton) exec script/lutim cron cleanfiles
# Vérification de l'occupation du dossier des images. Tous les jours, à 7h. # Vérification de l'occupation du dossier des images. Tous les jours, à 7h.
0 7 * * * www-data cd "__FINALPATH__" && $(which carton) exec script/lutim cron watch 0 7 * * * __APP__ cd "__FINALPATH__" && $(which carton) exec script/lutim cron watch

View file

@ -11,6 +11,9 @@
# if you use Lutim behind a reverse proxy like Nginx, you want to set proxy to 1 # if you use Lutim behind a reverse proxy like Nginx, you want to set proxy to 1
# if you use Lutim directly, let it commented # if you use Lutim directly, let it commented
proxy => 1, proxy => 1,
# Number of worker processes
workers => __WORKERS__,
}, },
################ ################
@ -69,7 +72,6 @@
# here's an example to put the logo of your hoster # here's an example to put the logo of your hoster
# optional, no default # optional, no default
#hosted_by => 'My super hoster <img src="http://hoster.example.com" alt="Hoster logo">', #hosted_by => 'My super hoster <img src="http://hoster.example.com" alt="Hoster logo">',
hosted_by => '<a href="stats">Statistiques</a>',
# DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED # DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED
# Lutim now checks if the X-Forwarded-Proto header is present and equal to https. # Lutim now checks if the X-Forwarded-Proto header is present and equal to https.

View file

@ -1,5 +1,6 @@
location __PATH__ { location __PATH__ {
# Force usage of https
if ($scheme = http) { if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
} }

View file

@ -1,80 +0,0 @@
{
"name": "Lutim configuration panel",
"version": "0.1",
"panel": [{
"name": "Lutim configuration",
"id": "main",
"sections": [{
"name": "Lutim configuration",
"id": "configuration",
"options": [{
"name": "Force the encryption of images ?",
"id": "always_encrypt",
"type": "bool",
"default": true
},
{
"name": "Anti-flood protection delay (seconds)",
"help": "Users won't be able to ask Lutim to download images more than one per anti_flood_delay seconds.",
"id": "antiflood",
"type": "number",
"default": 0
},
{
"name": "Default time limit for files",
"help": "We can't use a choices field for now. In the meantime please choose between one of this values:<br>None, Day, Week, Month, Year.",
"id": "delay",
"type": "text",
"//": "\"choices\" : [\"None\", \"Day\", \"Week\", \"Month\", \"Year\"]",
"default" : "Year"
}]
},
{
"name": "Public access",
"id": "is_public",
"options": [{
"name": "Is it a public app ?",
"id": "is_public",
"type": "bool",
"default": true
}]
},
{
"name": "Overwriting config files",
"id": "overwrite_files",
"options": [{
"name": "Overwrite the config file lutim.conf ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_settings",
"type": "bool",
"default": true
},
{
"name": "Overwrite the nginx config file ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_nginx",
"type": "bool",
"default": true
},
{
"name": "Overwrite the systemd config file ?",
"help": "If the file is overwritten, a backup will be created.",
"id": "overwrite_systemd",
"type": "bool",
"default": true
}]
},
{
"name": "Global configuration",
"id": "global_config",
"options": [{
"name": "Send HTML email to admin ?",
"help": "Allow app scripts to send HTML mails instead of plain text.",
"id": "email_type",
"type": "bool",
"default": true
}]
}]
}
]
}

63
config_panel.toml Normal file
View file

@ -0,0 +1,63 @@
version = "0.1"
name = "Lutim configuration panel"
[main]
name = "Lutim configuration"
[main.configuration]
name = "Lutim configuration"
[main.configuration.always_encrypt]
ask = "Force the encryption of images ?"
type = "boolean"
default = true
[main.configuration.antiflood]
ask = "Anti-flood protection delay (seconds)"
type = "number"
default = 0
help = "Users won't be able to ask Lutim to download images more than one per anti_flood_delay seconds."
[main.configuration.delay]
ask = "Default time limit for files"
choices = ["None", "Day", "Week", "Month", "Year"]
default = "Year"
help = "Users won't be able to ask Lutim to download images more than one per anti_flood_delay seconds."
[main.is_public]
name = "Public access"
[main.is_public.is_public]
ask = "Is it a public website?"
type = "boolean"
default = true
[main.overwrite_files]
name = "Overwriting config files"
[main.overwrite_files.overwrite_settings]
ask = "Overwrite the config file lutim.conf ?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
[main.overwrite_files.overwrite_nginx]
ask = "Overwrite the nginx config file ?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
[main.overwrite_files.overwrite_systemd]
ask = "Overwrite the systemd config file ?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
[main.global_config]
name = "Global configuration"
[main.global_config.email_type]
ask = "Send HTML email to admin ?"
type = "boolean"
default = true
help = "Allow app scripts to send HTML mails instead of plain text."

View file

@ -6,7 +6,7 @@
"en": "Self hosting images and sharing anonymous application", "en": "Self hosting images and sharing anonymous application",
"fr": "Application d'hébergement et de partage d'images anonyme" "fr": "Application d'hébergement et de partage d'images anonyme"
}, },
"version": "0.11.5~ynh1", "version": "0.11.6~ynh1",
"url": "https://lut.im", "url": "https://lut.im",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"maintainer": { "maintainer": {
@ -14,7 +14,7 @@
"email": "maniackc_dev@crudelis.fr" "email": "maniackc_dev@crudelis.fr"
}, },
"requirements": { "requirements": {
"yunohost": ">= 3.4" "yunohost": ">= 3.5"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [

View file

@ -1,5 +1,9 @@
#!/bin/bash #!/bin/bash
#=================================================
# PERSONAL HELPERS
#=================================================
#================================================= #=================================================
# BACKUP # BACKUP
#================================================= #=================================================
@ -27,25 +31,12 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
#================================================= #=================================================
IS_PACKAGE_CHECK () { IS_PACKAGE_CHECK () {
return $(env | grep -c container=lxc) if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]
} then
return 0
#================================================= else
# BOOLEAN CONVERTER return 1
#================================================= fi
bool_to_01 () {
local var="$1"
[ "$var" = "true" ] && var=1
[ "$var" = "false" ] && var=0
echo "$var"
}
bool_to_true_false () {
local var="$1"
[ "$var" = "1" ] && var=true
[ "$var" = "0" ] && var=false
echo "$var"
} }
#================================================= #=================================================
@ -129,359 +120,6 @@ ynh_multimedia_addaccess () {
usermod -a -G multimedia $user_name usermod -a -G multimedia $user_name
} }
#=================================================
# Create a dedicated fail2ban config (jail and filter conf files)
#
# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]]
# | arg: -l, --logpath= - Log file to be checked by fail2ban
# | arg: -r, --failregex= - Failregex to be looked for by fail2ban
# | arg: -m, --max_retry= - Maximum number of retries allowed before banning IP address - default: 3
# | arg: -p, --ports= - Ports blocked for a banned IP address - default: http,https
ynh_add_fail2ban_config () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [l]=logpath= [r]=failregex= [m]=max_retry= [p]=ports= )
local logpath
local failregex
local max_retry
local ports
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
max_retry=${max_retry:-3}
ports=${ports:-http,https}
test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing."
test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing."
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]
enabled = true
port = $ports
filter = $app
logpath = $logpath
maxretry = $max_retry
EOF
tee $finalfail2banfilterconf <<EOF
[INCLUDES]
before = common.conf
[Definition]
failregex = $failregex
ignoreregex =
EOF
ynh_store_file_checksum "$finalfail2banjailconf"
ynh_store_file_checksum "$finalfail2banfilterconf"
if [ "$(lsb_release --codename --short)" != "jessie" ]; then
systemctl reload fail2ban
else
systemctl restart fail2ban
fi
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
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)
#
# usage: ynh_remove_fail2ban_config
ynh_remove_fail2ban_config () {
ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf"
ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf"
if [ "$(lsb_release --codename --short)" != "jessie" ]; then
systemctl reload fail2ban
else
systemctl restart fail2ban
fi
}
#=================================================
# Read the value of a key in a ynh manifest file
#
# usage: ynh_read_manifest manifest key
# | arg: -m, --manifest= - Path of the manifest to read
# | arg: -k, --key= - Name of the key to find
ynh_read_manifest () {
# Declare an array to define the options of this helper.
declare -Ar args_array=( [m]=manifest= [k]=manifest_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
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
# For example : 4.3-2~ynh3
# This include the number before ~ynh
# In the last example it return 4.3-2
#
# usage: ynh_app_upstream_version [-m manifest]
# | arg: -m, --manifest= - Path of the manifest to read
ynh_app_upstream_version () {
declare -Ar args_array=( [m]=manifest= )
local manifest
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
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
# The version number in the manifest is defined by <upstreamversion>~ynh<packageversion>
# For example : 4.3-2~ynh3
# This include the number after ~ynh
# In the last example it return 3
#
# usage: ynh_app_package_version [-m manifest]
# | arg: -m, --manifest= - Path of the manifest to read
ynh_app_package_version () {
declare -Ar args_array=( [m]=manifest= )
local manifest
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
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/}"
}
# 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
#
## It stops the current script without error if the package is up-to-date
#
# 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,
# you have to set the variable YNH_FORCE_UPGRADE before.
# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp
#
# usage: ynh_check_app_version_changed
ynh_check_app_version_changed () {
local force_upgrade=${YNH_FORCE_UPGRADE:-0}
local package_check=${PACKAGE_CHECK_EXEC:-0}
# By default, upstream app version has changed
local return_value="UPGRADE_APP"
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" ]
then
echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2
unset YNH_FORCE_UPGRADE
elif [ "$package_check" != "0" ]
then
echo "Upgrade forced for package check." >&2
else
ynh_die "Up-to-date, nothing to do" 0
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
}
# 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 # EXPERIMENTAL HELPERS
#================================================= #=================================================
@ -660,6 +298,8 @@ ynh_maintenance_mode_ON () {
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
fi fi
mkdir -p /var/www/html/
# Create an html to serve as maintenance notice # Create an html to serve as maintenance notice
echo "<!DOCTYPE html> echo "<!DOCTYPE html>
<html> <html>
@ -730,128 +370,381 @@ ynh_maintenance_mode_OFF () {
#================================================= #=================================================
# Download and check integrity of a file from app.src_file # Create a changelog for an app after an upgrade from the file CHANGELOG.md.
# #
# The file conf/app.src_file need to contains: # usage: ynh_app_changelog [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source]
# | arg: -f --format= - Format in which the changelog will be printed
# markdown: Default format.
# html: Turn urls into html format.
# plain: Plain text changelog
# | arg: -o --output= - Output file for the changelog file (Default ./changelog)
# | arg: -c --changelog= - CHANGELOG.md source (Default ../CHANGELOG.md)
# #
# FILE_URL=Address to download the file # The changelog is printed into the file ./changelog and ./changelog_lite
# FILE_SUM=Control sum ynh_app_changelog () {
# # (Optional) Program to check the integrity (sha256sum, md5sum...)
# # default: sha256
# FILE_SUM_PRG=sha256
# # (Optionnal) Name of the local archive (offline setup support)
# # default: Name of the downloaded file.
# FILENAME=example.deb
#
# usage: ynh_download_file --dest_dir="/destination/directory" [--source_id=myfile]
# | arg: -d, --dest_dir= - Directory where to download the file
# | arg: -s, --source_id= - Name of the source file 'app.src_file' if it isn't '$app'
ynh_download_file () {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
declare -Ar args_array=( [d]=dest_dir= [s]=source_id= ) local legacy_args=foc
local dest_dir declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= )
local source_id local format
local output
local changelog
# Manage arguments with getopts # Manage arguments with getopts
ynh_handle_getopts_args "$@" ynh_handle_getopts_args "$@"
format=${format:-markdown}
output=${output:-changelog}
changelog=${changelog:-../CHANGELOG.md}
source_id=${source_id:-app} # If the argument is not given, source_id equals "$app" local original_changelog="$changelog"
local temp_changelog="changelog_temp"
local final_changelog="$output"
# Load value from configuration file (see above for a small doc about this file if [ ! -n "$original_changelog" ]
# format)
local src_file="$YNH_CWD/../conf/${source_id}.src_file"
# If the src_file doesn't exist, use the backup path instead, with a "settings" directory
if [ ! -e "$src_file" ]
then then
src_file="$YNH_CWD/../settings/conf/${source_id}.src_file" echo "No changelog available..." > "$final_changelog"
fi echo "No changelog available..." > "${final_changelog}_lite"
local file_url=$(grep 'FILE_URL=' "$src_file" | cut -d= -f2-) return 0
local file_sum=$(grep 'FILE_SUM=' "$src_file" | cut -d= -f2-)
local file_sumprg=$(grep 'FILE_SUM_PRG=' "$src_file" | cut -d= -f2-)
local filename=$(grep 'FILENAME=' "$src_file" | cut -d= -f2-)
# Default value
file_sumprg=${file_sumprg:-sha256sum}
if [ "$filename" = "" ] ; then
filename="$(basename "$file_url")"
fi
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${filename}"
if test -e "$local_src"
then # Use the local source file if it is present
cp $local_src $filename
else # If not, download the source
local out=`wget -nv -O $filename $file_url 2>&1` || ynh_print_err $out
fi fi
# Check the control sum local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
echo "${file_sum} ${filename}" | ${file_sumprg} -c --status \ local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version")
|| ynh_die "Corrupt file"
# Create the destination directory, if it's not already. # Get the line of the version to update to into the changelog
mkdir -p "$dest_dir" local update_version_line=$(grep --max-count=1 --line-number "^## \[$update_version" "$original_changelog" | cut -d':' -f1)
# If there's no entry for this version yet into the changelog
# Get the first available version
if [ -z "$update_version_line" ]
then
update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1)
fi
# Move the file to its destination # Get the length of the complete changelog.
mv $filename $dest_dir local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}')
# Cut the file before the version to update to.
tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog"
# Get the length of the troncated changelog.
changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}')
# Get the line of the current version into the changelog
# Keep only the last line found
local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1)
# If there's no entry for this version into the changelog
# Get the last available version
if [ -z "$current_version_line" ]
then
current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1)
fi
# Cut the file before the current version.
# Then grep the previous version into the changelog to get the line number of the previous version
local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \
"$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1)
# If there's no previous version into the changelog
# Go until the end of the changelog
if [ -z "$previous_version_line" ]
then
previous_version_line=$changelog_length
fi
# Cut the file after the previous version to keep only the changelog between the current version and the version to update to.
head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog"
if [ "$format" = "html" ]
then
# Replace markdown links by html links
ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="<a href=\"\2\">\1</a>)" --target_file="$final_changelog"
ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="<a href=\"\2\">\1</a>" --target_file="$final_changelog"
elif [ "$format" = "plain" ]
then
# Change title format.
ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog"
# Change modifications lines format.
ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog"
fi
# else markdown. As the file is already in markdown, nothing to do.
# Keep only important changes into the changelog
# Remove all minor changes
sed '/^-/d' "$final_changelog" > "${final_changelog}_lite"
# Remove all blank lines (to keep a clear workspace)
sed --in-place '/^$/d' "${final_changelog}_lite"
# Add a blank line at the end
echo "" >> "${final_changelog}_lite"
# Clean titles if there's no significative changes
local line
local previous_line=""
while read line <&3
do
if [ -n "$previous_line" ]
then
# Remove the line if it's a title or a blank line, and the previous one was a title as well.
if ( [ "${line:0:1}" = "#" ] || [ ${#line} -eq 0 ] ) && [ "${previous_line:0:1}" = "#" ]
then
ynh_replace_special_string --match_string="${previous_line//[/.}" --replace_string="" --target_file="${final_changelog}_lite"
fi
fi
previous_line="$line"
done 3< "${final_changelog}_lite"
# Remove all blank lines again
sed --in-place '/^$/d' "${final_changelog}_lite"
# Restore changelog format with blank lines
ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_file="${final_changelog}_lite"
# Remove the 2 first blank lines
sed --in-place '1,2d' "${final_changelog}_lite"
# Add a blank line at the end
echo "" >> "${final_changelog}_lite"
# If changelog are empty, add an info
if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ]
then
echo "No changes from the changelog..." > "$final_changelog"
fi
if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ]
then
echo "No significative changes from the changelog..." > "${final_changelog}_lite"
fi
} }
#================================================= #=================================================
# Create a changelog for an app after an upgrade. # Check the amount of available RAM
# #
# The changelog is printed into the file ./changelog for the time of the upgrade. # usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram]
# # | arg: -r, --required= - Amount of RAM required in Mb. The helper will return 0 is there's enough RAM, or 1 otherwise.
# In order to create a changelog, ynh_app_changelog will get info from /etc/yunohost/apps/$app/status.json # If --required isn't set, the helper will print the amount of RAM, in Mb.
# In order to find the current commit use by the app. # | arg: -s, --no_swap - Ignore swap
# The remote repository, and the branch. # | arg: -o, --only_swap - Ignore real RAM, consider only swap.
# The changelog will be only the commits since the current revision. # | arg: -f, --free_ram - Count only free RAM, not the total amount of RAM available.
# ynh_check_ram () {
# Because of the need of those info, ynh_app_changelog works only # Declare an array to define the options of this helper.
# with apps that have been installed from a list. declare -Ar args_array=( [r]=required= [s]=no_swap [o]=only_swap [f]=free_ram )
# local required
# usage: ynh_app_changelog local no_swap
ynh_app_changelog () { local only_swap
get_value_from_settings () # Manage arguments with getopts
{ ynh_handle_getopts_args "$@"
local value="$1" required=${required:-}
# Extract a value from the status.json file of an installed app. no_swap=${no_swap:-0}
only_swap=${only_swap:-0}
grep "$value\": \"" /etc/yunohost/apps/$app/status.json | sed "s/.*$value\": \"\([^\"]*\).*/\1/" local total_ram=$(vmstat --stats --unit M | grep "total memory" | awk '{print $1}')
} local total_swap=$(vmstat --stats --unit M | grep "total swap" | awk '{print $1}')
local total_ram_swap=$(( total_ram + total_swap ))
local current_revision="$(get_value_from_settings revision)" local free_ram=$(vmstat --stats --unit M | grep "free memory" | awk '{print $1}')
local repo="$(get_value_from_settings url)" local free_swap=$(vmstat --stats --unit M | grep "free swap" | awk '{print $1}')
local branch="$(get_value_from_settings branch)" local free_ram_swap=$(( free_ram + free_swap ))
# ynh_app_changelog works only with an app installed from a list.
if [ -z "$current_revision" ] || [ -z "$repo" ] || [ -z "$branch" ] # Use the total amount of ram
local ram=$total_ram_swap
if [ $free_ram -eq 1 ]
then then
ynh_print_warn "Unable to build the changelog..." # Use the total amount of free ram
touch changelog ram=$free_ram_swap
if [ $no_swap -eq 1 ]
then
# Use only the amount of free ram
ram=$free_ram
elif [ $only_swap -eq 1 ]
then
# Use only the amount of free swap
ram=$free_swap
fi
else
if [ $no_swap -eq 1 ]
then
# Use only the amount of free ram
ram=$total_ram
elif [ $only_swap -eq 1 ]
then
# Use only the amount of free swap
ram=$total_swap
fi
fi
if [ -n "$required" ]
then
# Return 1 if the amount of ram isn't enough.
if [ $ram -lt $required ]
then
return 1
else
return 0 return 0
fi fi
# Fetch the history of the repository, without cloning it # If no RAM is required, return the amount of available ram.
mkdir git_history else
(cd git_history echo $ram
ynh_exec_warn_less git init fi
ynh_exec_warn_less git remote add -f origin $repo }
# Get the line of the current commit of the installed app in the history.
local line_to_head=$(git log origin/$branch --pretty=oneline | grep --line-number "$current_revision" | cut -d':' -f1) #=================================================
# Cut the history before the current commit, to keep only newer commits.
# Then use sed to reorganise each lines and have a nice list of commits since the last upgrade. # Define the values to configure php-fpm
# This list is redirected into the file changelog #
git log origin/$branch --pretty=oneline | head --lines=$(($line_to_head-1)) | sed 's/^\([[:alnum:]]*\)\(.*\)/*(\1) -> \2/g' > ../changelog) # usage: ynh_get_scalable_phpfpm --usage=usage --footprint=footprint [--print]
# Remove 'Merge pull request' commits # | arg: -f, --footprint - Memory footprint of the service (low/medium/high).
sed -i '/Merge pull request #[[:digit:]]* from/d' changelog # low - Less than 20Mb of ram by pool.
# As well as conflict resolving commits # medium - Between 20Mb and 40Mb of ram by pool.
sed -i '/Merge branch .* into/d' changelog # high - More than 40Mb of ram by pool.
# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value.
# Get the value of admin_mail_html # To have this value, use the following command and stress the service.
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) # watch -n0.5 ps -o user,cmd,%cpu,rss -u APP
admin_mail_html="${admin_mail_html:-0}" #
# | arg: -u, --usage - Expected usage of the service (low/medium/high).
# If a html email is required. Apply html to the changelog. # low - Personal usage, behind the sso.
if [ "$admin_mail_html" -eq 1 ] # medium - Low usage, few people or/and publicly accessible.
then # high - High usage, frequently visited website.
sed -in-place "s@\*(\([[:alnum:]]*\)) -> \(.*\)@* __URL_TAG1__\2__URL_TAG2__${repo}/commit/\1__URL_TAG3__@g" changelog #
# | arg: -p, --print - Print the result
#
#
#
# The footprint of the service will be used to defined the maximum footprint we can allow, which is half the maximum RAM.
# So it will be used to defined 'pm.max_children'
# A lower value for the footprint will allow more children for 'pm.max_children'. And so for
# 'pm.start_servers', 'pm.min_spare_servers' and 'pm.max_spare_servers' which are defined from the
# value of 'pm.max_children'
# NOTE: 'pm.max_children' can't exceed 4 times the number of processor's cores.
#
# The usage value will defined the way php will handle the children for the pool.
# A value set as 'low' will set the process manager to 'ondemand'. Children will start only if the
# service is used, otherwise no child will stay alive. This config gives the lower footprint when the
# service is idle. But will use more proc since it has to start a child as soon it's used.
# Set as 'medium', the process manager will be at dynamic. If the service is idle, a number of children
# equal to pm.min_spare_servers will stay alive. So the service can be quick to answer to any request.
# The number of children can grow if needed. The footprint can stay low if the service is idle, but
# not null. The impact on the proc is a little bit less than 'ondemand' as there's always a few
# children already available.
# Set as 'high', the process manager will be set at 'static'. There will be always as many children as
# 'pm.max_children', the footprint is important (but will be set as maximum a quarter of the maximum
# RAM) but the impact on the proc is lower. The service will be quick to answer as there's always many
# children ready to answer.
ynh_get_scalable_phpfpm () {
local legacy_args=ufp
# Declare an array to define the options of this helper.
declare -Ar args_array=( [u]=usage= [f]=footprint= [p]=print )
local usage
local footprint
local print
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
# Set all characters as lowercase
footprint=${footprint,,}
usage=${usage,,}
print=${print:-0}
if [ "$footprint" = "low" ]
then
footprint=20
elif [ "$footprint" = "medium" ]
then
footprint=35
elif [ "$footprint" = "high" ]
then
footprint=50
fi
# Define the way the process manager handle child processes.
if [ "$usage" = "low" ]
then
php_pm=ondemand
elif [ "$usage" = "medium" ]
then
php_pm=dynamic
elif [ "$usage" = "high" ]
then
php_pm=static
else
ynh_die --message="Does not recognize '$usage' as an usage value."
fi
# Get the total of RAM available, except swap.
local max_ram=$(ynh_check_ram --no_swap)
less0() {
# Do not allow value below 1
if [ $1 -le 0 ]
then
echo 1
else
echo $1
fi
}
# Define pm.max_children
# The value of pm.max_children is the total amount of ram divide by 2 and divide again by the footprint of a pool for this app.
# So if php-fpm start the maximum of children, it won't exceed half of the ram.
php_max_children=$(( $max_ram / 2 / $footprint ))
# If process manager is set as static, use half less children.
# Used as static, there's always as many children as the value of pm.max_children
if [ "$php_pm" = "static" ]
then
php_max_children=$(( $php_max_children / 2 ))
fi
php_max_children=$(less0 $php_max_children)
# To not overload the proc, limit the number of children to 4 times the number of cores.
local core_number=$(nproc)
local max_proc=$(( $core_number * 4 ))
if [ $php_max_children -gt $max_proc ]
then
php_max_children=$max_proc
fi
if [ "$php_pm" = "dynamic" ]
then
# Define pm.start_servers, pm.min_spare_servers and pm.max_spare_servers for a dynamic process manager
php_min_spare_servers=$(( $php_max_children / 8 ))
php_min_spare_servers=$(less0 $php_min_spare_servers)
php_max_spare_servers=$(( $php_max_children / 2 ))
php_max_spare_servers=$(less0 $php_max_spare_servers)
php_start_servers=$(( $php_min_spare_servers + ( $php_max_spare_servers - $php_min_spare_servers ) /2 ))
php_start_servers=$(less0 $php_start_servers)
else
php_min_spare_servers=0
php_max_spare_servers=0
php_start_servers=0
fi
if [ $print -eq 1 ]
then
ynh_debug --message="Footprint=${footprint}Mb by pool."
ynh_debug --message="Process manager=$php_pm"
ynh_debug --message="Max RAM=${max_ram}Mb"
if [ "$php_pm" != "static" ]; then
ynh_debug --message="\nMax estimated footprint=$(( $php_max_children * $footprint ))"
ynh_debug --message="Min estimated footprint=$(( $php_min_spare_servers * $footprint ))"
fi
if [ "$php_pm" = "dynamic" ]; then
ynh_debug --message="Estimated average footprint=$(( $php_max_spare_servers * $footprint ))"
elif [ "$php_pm" = "static" ]; then
ynh_debug --message="Estimated footprint=$(( $php_max_children * $footprint ))"
fi
ynh_debug --message="\nRaw php-fpm values:"
ynh_debug --message="pm.max_children = $php_max_children"
if [ "$php_pm" = "dynamic" ]; then
ynh_debug --message="pm.start_servers = $php_start_servers"
ynh_debug --message="pm.min_spare_servers = $php_min_spare_servers"
ynh_debug --message="pm.max_spare_servers = $php_max_spare_servers"
fi
fi
}
#=================================================
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
exec_as() {
local USER=$1
shift 1
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi fi
} }

View file

@ -12,11 +12,10 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
ynh_script_progression --message="Retrieve arguments from the manifest"
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# CHECK IF ARGUMENTS ARE CORRECT # CHECK IF ARGUMENTS ARE CORRECT
@ -31,9 +30,9 @@ final_path=$(ynh_app_setting_get $app final_path)
#================================================= #=================================================
# CHECK THE DISK QUOTA FOR IMAGES STORED BY LUTIM # CHECK THE DISK QUOTA FOR IMAGES STORED BY LUTIM
#================================================= #=================================================
ynh_script_progression --message="Check the disk quota for images stored by lutim" --weight=9 ynh_script_progression --message="Checking the disk quota for images stored by lutim..." --weight=9
(cd "$final_path" && $(which carton) exec script/lutim cron watch) (cd "$final_path" && exec_as $app $(which carton) exec script/lutim cron watch)
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -12,11 +12,10 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
ynh_script_progression --message="Retrieve arguments from the manifest"
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# CHECK IF ARGUMENTS ARE CORRECT # CHECK IF ARGUMENTS ARE CORRECT
@ -31,9 +30,9 @@ final_path=$(ynh_app_setting_get $app final_path)
#================================================= #=================================================
# REMOVE EXPIRED IMAGES # REMOVE EXPIRED IMAGES
#================================================= #=================================================
ynh_script_progression --message="Remove expired images" --weight=9 ynh_script_progression --message="Removing expired images..." --weight=9
(cd "$final_path" && $(which carton) exec script/lutim cron cleanfiles) (cd "$final_path" && exec_as $app $(which carton) exec script/lutim cron cleanfiles)
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -12,11 +12,10 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
ynh_script_progression --message="Retrieve arguments from the manifest"
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# CHECK IF ARGUMENTS ARE CORRECT # CHECK IF ARGUMENTS ARE CORRECT
@ -31,9 +30,9 @@ final_path=$(ynh_app_setting_get $app final_path)
#================================================= #=================================================
# REMOVE OBSOLETE IP FROM THE DATABASE # REMOVE OBSOLETE IP FROM THE DATABASE
#================================================= #=================================================
ynh_script_progression --message="Remove obsolete ip from the database" --weight=9 ynh_script_progression --message="Removing obsolete ip from the database..." --weight=9
(cd "$final_path" && $(which carton) exec script/lutim cron cleanbdd) (cd "$final_path" && exec_as $app $(which carton) exec script/lutim cron cleanbdd)
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -12,14 +12,13 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
ynh_script_progression --message="Retrieve arguments from the manifest"
# Get is_public # Get is_public
is_public=${YNH_ACTION_IS_PUBLIC} is_public=${YNH_ACTION_IS_PUBLIC}
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get --app=$app --key=path)
#================================================= #=================================================
# CHECK IF ARGUMENTS ARE CORRECT # CHECK IF ARGUMENTS ARE CORRECT
@ -29,11 +28,11 @@ path_url=$(ynh_app_setting_get $app path)
# CHECK IF AN ACTION HAS TO BE DONE # CHECK IF AN ACTION HAS TO BE DONE
#================================================= #=================================================
is_public_old=$(ynh_app_setting_get $app is_public) is_public_old=$(ynh_app_setting_get --app=$app --key=is_public)
if [ $is_public -eq $is_public_old ] if [ $is_public -eq $is_public_old ]
then then
ynh_die "is_public is already set as $is_public." 0 ynh_die --message="is_public is already set as $is_public." --ret_code=0
fi fi
#================================================= #=================================================
@ -41,12 +40,13 @@ fi
#================================================= #=================================================
# MOVE TO PUBLIC OR PRIVATE # MOVE TO PUBLIC OR PRIVATE
#================================================= #=================================================
if [ $is_public -eq 0 ]; then if [ $is_public -eq 0 ]; then
public_private="private" public_private="private"
else else
public_private="public" public_private="public"
fi fi
ynh_script_progression --message="Move the application to $public_private" --weight=3 ynh_script_progression --message="Moving the application to $public_private..." --weight=3
if [ $is_public -eq 0 ] if [ $is_public -eq 0 ]
then then
@ -57,23 +57,24 @@ then
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g') domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set $app protected_regex "$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$" ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
else else
ynh_app_setting_delete $app protected_regex ynh_app_setting_delete --app=$app --key=protected_regex
fi fi
ynh_script_progression --message="Upgrading SSOwat configuration..."
# Regen ssowat configuration # Regen ssowat configuration
yunohost app ssowatconf yunohost app ssowatconf
# Update the config of the app # Update the config of the app
ynh_app_setting_set $app is_public $is_public ynh_app_setting_set --app=$app --key=is_public --value=$is_public
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reload nginx" ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --action=reload --service_name=nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -12,15 +12,14 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
ynh_script_progression --message="Retrieve arguments from the manifest" --weight=3
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get --app=$app --key=path)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get --app=$app --key=port)
always_encrypt=$(ynh_app_setting_get $app always_encrypt) always_encrypt=$(ynh_app_setting_get --app=$app --key=always_encrypt)
secret=$(ynh_app_setting_get $app secret) secret=$(ynh_app_setting_get --app=$app --key=secret)
#================================================= #=================================================
# SORT OUT THE CONFIG FILE TO HANDLE # SORT OUT THE CONFIG FILE TO HANDLE
@ -37,10 +36,10 @@ fi
#================================================= #=================================================
# RESET THE CONFIG FILE # RESET THE CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Reset the config file $config_file" --weight=9 ynh_script_progression --message="Resetting the config file $config_file..." --weight=9
# Verify the checksum and backup the file if it's different # Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$config_file" ynh_backup_if_checksum_is_different --file="$config_file"
if [ "$file" = "lutim.conf" ] if [ "$file" = "lutim.conf" ]
then then
@ -48,17 +47,19 @@ then
cp /etc/yunohost/apps/$app/conf/lutim.conf.template "$config_file" cp /etc/yunohost/apps/$app/conf/lutim.conf.template "$config_file"
# Recreate the default config # Recreate the default config
ynh_replace_string "__DOMAIN__" "$domain" "$config_file" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config_file"
ynh_replace_string "__PATH__" "$path_url" "$config_file" ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config_file"
ynh_replace_string "__PORT__" "$port" "$config_file" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$config_file"
ynh_replace_string "__ENCRYPT__" "$always_encrypt" "$config_file" ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$config_file"
ynh_replace_string "__SECRET__" "$secret" "$config_file" ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$config_file"
# Set the number of process for Lutim to twice the number of CPU core.
ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf"
fi fi
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$config_file" ynh_store_file_checksum --file="$config_file"
ynh_script_progression --message="Restart Lutim" --weight=5 ynh_script_progression --message="Restarting Lutim..." --weight=5
# Wait for lutim to be fully started # Wait for lutim to be fully started
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"

View file

@ -19,55 +19,55 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Load settings" --weight=2 ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
#================================================= #=================================================
# STANDARD BACKUP STEPS # STANDARD BACKUP STEPS
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Backup the app main dir" --weight=4 ynh_script_progression --message="Backing up the main app directory..."
CHECK_SIZE "$final_path" CHECK_SIZE "$final_path"
ynh_backup "$final_path" ynh_backup --src_path="$final_path"
#================================================= #=================================================
# BACKUP NGINX CONFIGURATION # BACKUP NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Backup nginx configuration" ynh_script_progression --message="Backing up nginx web server configuration..."
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Backup logrotate configuration" ynh_script_progression --message="Backing up logrotate configuration"
ynh_backup "/etc/logrotate.d/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Backup systemd configuration" ynh_script_progression --message="Backing up systemd configuration"
ynh_backup "/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
#================================================= #=================================================
# BACKUP A CRON FILE # BACKUP A CRON FILE
#================================================= #=================================================
ynh_script_progression --message="Backup cron file" ynh_script_progression --message="Backing up cron file"
ynh_backup "/etc/cron.d/$app" ynh_backup --src_path="/etc/cron.d/$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Backup script completed. Please wait for YunoHost to create the backup." --last ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last

View file

@ -12,7 +12,6 @@ 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
@ -25,26 +24,33 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Load settings" --weight=2 ynh_script_progression --message="Loading installation settings..." --weight=2
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
is_public=$(ynh_app_setting_get $app is_public) is_public=$(ynh_app_setting_get --app=$app --key=is_public)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get --app=$app --key=port)
#================================================= #=================================================
# CHECK THE SYNTAX OF THE PATHS # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Check the syntax of the paths" ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --weight=20
test -n "$old_path" || old_path="/" # Backup the current version of the app
test -n "$new_path" || new_path="/" ynh_backup_before_upgrade
new_path=$(ynh_normalize_url_path $new_path) ynh_clean_setup () {
old_path=$(ynh_normalize_url_path $old_path) # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Activate maintenance mode" ynh_script_progression --message="Activating maintenance mode..."
path_url=$old_path path_url=$old_path
domain=$old_domain domain=$old_domain
@ -82,7 +88,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=2 ynh_script_progression --message="Updating nginx web server configuration..." --weight=2
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
@ -90,15 +96,12 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
if [ $change_path -eq 1 ] if [ $change_path -eq 1 ]
then 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 --file="$nginx_conf_path"
# Set global variables for nginx helper # Set global variables for nginx helper
domain="$old_domain" domain="$old_domain"
path_url="$new_path" path_url="$new_path"
# Store path_url setting
ynh_app_setting_set $app path_url "$path_url"
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
fi fi
@ -107,17 +110,17 @@ fi
if [ $change_domain -eq 1 ] if [ $change_domain -eq 1 ]
then then
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
ynh_delete_file_checksum "$nginx_conf_path" ynh_delete_file_checksum --file="$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
# Store file checksum for the new config file location # Store file checksum for the new config file location
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi fi
#================================================= #=================================================
# UPDATE SSOWAT # UPDATE SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Reconfigure SSOwat" ynh_script_progression --message="Reconfiguring SSOwat..."
if [ $is_public -eq 0 ] if [ $is_public -eq 0 ]
then then
@ -128,7 +131,7 @@ then
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$new_domain" | sed 's@-@.@g') domain_regex=$(echo "$new_domain" | sed 's@-@.@g')
ynh_app_setting_set $app protected_regex "$domain_regex$new_path/stats/?$","$domain_regex$new_path/manifest.webapp/?$","$domain_regex$new_path/?$","$domain_regex$new_path/[d-m]/.*$" ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$new_path/stats/?$","$domain_regex$new_path/manifest.webapp/?$","$domain_regex$new_path/?$","$domain_regex$new_path/[d-m]/.*$"
fi fi
#================================================= #=================================================
@ -137,21 +140,21 @@ fi
# REPLACE THE PATH IN THE CONFIG OF LUTIM # REPLACE THE PATH IN THE CONFIG OF LUTIM
#================================================= #=================================================
ynh_replace_string "\(^ *prefix.*=> '\).*" "\1$new_path'," "$final_path/lutim.conf" ynh_replace_string --match_string="\(^ *prefix.*=> '\).*" --replace_string="\1$new_path'," --target_file="$final_path/lutim.conf"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reload nginx" --weight=2 ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --action=reload --service_name=nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# START AND CHECK LUTIM BOOTING # START AND CHECK LUTIM BOOTING
#================================================= #=================================================
ynh_script_progression --message="Restart Lutim" --weight=3 ynh_script_progression --message="Restarting Lutim..." --weight=3
# Wait for lutim to be fully started # Wait for lutim to be fully started
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
@ -159,7 +162,7 @@ ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="
#================================================= #=================================================
# DEACTIVE MAINTENANCE MODE # DEACTIVE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Disable maintenance mode" --weight=5 ynh_script_progression --message="Disabling maintenance mode..."
path_url=$old_path path_url=$old_path
domain=$old_domain domain=$old_domain
@ -169,4 +172,4 @@ ynh_maintenance_mode_OFF
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of url completed" --last ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# SPECIFIC CODE # SPECIFIC CODE
@ -42,7 +42,6 @@ get_config_value() {
# always_encrypt # always_encrypt
old_always_encrypt="$(get_config_value always_encrypt)" old_always_encrypt="$(get_config_value always_encrypt)"
old_always_encrypt=$(bool_to_true_false $old_always_encrypt)
always_encrypt="${YNH_CONFIG_MAIN_CONFIGURATION_ALWAYS_ENCRYPT:-$old_always_encrypt}" always_encrypt="${YNH_CONFIG_MAIN_CONFIGURATION_ALWAYS_ENCRYPT:-$old_always_encrypt}"
# antiflood # antiflood
old_antiflood="$(get_config_value anti_flood_delay)" old_antiflood="$(get_config_value anti_flood_delay)"
@ -63,28 +62,23 @@ fi
delay="${YNH_CONFIG_MAIN_CONFIGURATION_DELAY:-$old_delay}" delay="${YNH_CONFIG_MAIN_CONFIGURATION_DELAY:-$old_delay}"
# is_public # is_public
old_is_public="$(ynh_app_setting_get $app is_public)" old_is_public="$(ynh_app_setting_get --app=$app --key=is_public)"
old_is_public=$(bool_to_true_false $old_is_public)
is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}" is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}"
# Overwrite settings.json file # Overwrite settings.json file
old_overwrite_settings="$(ynh_app_setting_get $app overwrite_settings)" old_overwrite_settings="$(ynh_app_setting_get --app=$app --key=overwrite_settings)"
old_overwrite_settings=$(bool_to_true_false $old_overwrite_settings)
overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}" overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}"
# Overwrite nginx configuration # Overwrite nginx configuration
old_overwrite_nginx="$(ynh_app_setting_get $app overwrite_nginx)" old_overwrite_nginx="$(ynh_app_setting_get --app=$app --key=overwrite_nginx)"
old_overwrite_nginx=$(bool_to_true_false $old_overwrite_nginx)
overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}" overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}"
# Overwrite systemd configuration # Overwrite systemd configuration
old_overwrite_systemd="$(ynh_app_setting_get $app overwrite_systemd)" old_overwrite_systemd="$(ynh_app_setting_get --app=$app --key=overwrite_systemd)"
old_overwrite_systemd=$(bool_to_true_false $old_overwrite_systemd)
overwrite_systemd="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD:-$old_overwrite_systemd}" overwrite_systemd="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD:-$old_overwrite_systemd}"
# Type of admin mail configuration # Type of admin mail configuration
old_admin_mail_html="$(ynh_app_setting_get $app admin_mail_html)" old_admin_mail_html="$(ynh_app_setting_get --app=$app --key=admin_mail_html)"
old_admin_mail_html=$(bool_to_true_false $old_admin_mail_html)
admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}" admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}"
#================================================= #=================================================
@ -119,20 +113,19 @@ apply_config() {
# always_encrypt # always_encrypt
if [ "$always_encrypt" != "$old_always_encrypt" ] if [ "$always_encrypt" != "$old_always_encrypt" ]
then then
always_encrypt=$(bool_to_01 $always_encrypt) ynh_replace_string --match_string=".*always_encrypt *=>.*" --replace_string=" always_encrypt => $always_encrypt," --target_file="$config_file"
ynh_replace_string ".*always_encrypt *=>.*" " always_encrypt => $always_encrypt," "$config_file"
restart_lutim=1 restart_lutim=1
fi fi
# antiflood # antiflood
if [ "$antiflood" != "$old_antiflood" ] if [ "$antiflood" != "$old_antiflood" ]
then then
ynh_replace_string ".*anti_flood_delay *=>.*" " anti_flood_delay => $antiflood," "$config_file" ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$config_file"
# Disable anti_flood_delay if the delay is 0 # Disable anti_flood_delay if the delay is 0
if [ $antiflood = 0 ]; then if [ $antiflood = 0 ]; then
ynh_replace_string "\(anti_flood_delay *=>.*\)" "#\1" "$config_file" ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$config_file"
fi fi
ynh_app_setting_set $app antiflood "$antiflood" ynh_app_setting_set --app=$app --key=antiflood --value="$antiflood"
restart_lutim=1 restart_lutim=1
fi fi
@ -150,8 +143,8 @@ apply_config() {
else else
delay=360 delay=360
fi fi
ynh_replace_string ".*default_delay *=>.*" " default_delay => $delay," "$config_file" ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$config_file"
ynh_app_setting_set $app delay "$delay" ynh_app_setting_set --app=$app --key=delay --value="$delay"
restart_lutim=1 restart_lutim=1
fi fi
@ -170,18 +163,14 @@ apply_config() {
fi fi
# Set overwrite_settings # Set overwrite_settings
overwrite_settings=$(bool_to_01 $overwrite_settings) ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings"
ynh_app_setting_set $app overwrite_settings "$overwrite_settings"
# Set overwrite_nginx # Set overwrite_nginx
overwrite_nginx=$(bool_to_01 $overwrite_nginx) ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx"
ynh_app_setting_set $app overwrite_nginx "$overwrite_nginx"
# Set overwrite_systemd # Set overwrite_systemd
overwrite_systemd=$(bool_to_01 $overwrite_systemd) ynh_app_setting_set --app=$app --key=overwrite_systemd --value="$overwrite_systemd"
ynh_app_setting_set $app overwrite_systemd "$overwrite_systemd"
# Set admin_mail_html # Set admin_mail_html
admin_mail_html=$(bool_to_01 $admin_mail_html) ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
ynh_app_setting_set $app admin_mail_html "$admin_mail_html"
} }
#================================================= #=================================================

View file

@ -24,7 +24,6 @@ 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
@ -36,61 +35,59 @@ 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" --weight=2 ynh_script_progression --message="Validating installation parameters..." --weight=2
final_path=/var/www/$app final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder" test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_script_progression --message="Store settings from manifest" --weight=2 ynh_script_progression --message="Storing installation settings..." --weight=2
ynh_app_setting_set $app domain $domain ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set $app is_public $is_public ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set $app always_encrypt $always_encrypt ynh_app_setting_set --app=$app --key=always_encrypt --value=$always_encrypt
ynh_app_setting_set $app overwrite_settings "1" ynh_app_setting_set --app=$app --key=overwrite_settings --value=1
ynh_app_setting_set $app overwrite_nginx "1" ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1
ynh_app_setting_set $app overwrite_systemd "1" ynh_app_setting_set --app=$app --key=overwrite_systemd --value=1
ynh_app_setting_set $app admin_mail_html "1" ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_script_progression --message="Find a free port" --weight=3 ynh_script_progression --message="Configuring firewall..." --weight=3
# Find a free port # Find a free port
port=$(ynh_find_port 8095) port=$(ynh_find_port --port=8095)
ynh_app_setting_set $app port $port ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..."
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity and uncompress the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path" ynh_setup_source --dest_dir="$final_path"
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Install dependencies" --weight=60 ynh_script_progression --message="Installing dependencies..." --weight=60
ynh_install_app_dependencies $app_depencencies ynh_install_app_dependencies $app_depencencies
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Configure nginx" --weight=2 ynh_script_progression --message="Configuring nginx web server..." --weight=2
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
@ -98,7 +95,7 @@ ynh_add_nginx_config
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Create a dedicated user" --weight=2 ynh_script_progression --message="Configuring system user..." --weight=2
# Create a dedicated system user # Create a dedicated system user
ynh_system_user_create $app ynh_system_user_create $app
@ -112,20 +109,22 @@ ynh_script_progression --message="Configure Lutim" --weight=2
# Configure Lutim # Configure Lutim
cp ../conf/lutim.conf.template "$final_path/lutim.conf" cp ../conf/lutim.conf.template "$final_path/lutim.conf"
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/lutim.conf" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/lutim.conf"
ynh_replace_string "__PATH__" "$path_url" "$final_path/lutim.conf" ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/lutim.conf"
ynh_replace_string "__PORT__" "$port" "$final_path/lutim.conf" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/lutim.conf"
ynh_replace_string "__ENCRYPT__" "$always_encrypt" "$final_path/lutim.conf" ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$final_path/lutim.conf"
secret=$(ynh_string_random) secret=$(ynh_string_random)
ynh_replace_string "__SECRET__" "$secret" "$final_path/lutim.conf" ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$final_path/lutim.conf"
ynh_app_setting_set $app secret "$secret" ynh_app_setting_set --app=$app --key=secret --value="$secret"
# Set the number of process for Lutim to twice the number of CPU core.
ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf"
# Calculate and store the config file checksum into the app settings # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/lutim.conf" ynh_store_file_checksum --file="$final_path/lutim.conf"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Configure systemd" --weight=2 ynh_script_progression --message="Configuring a systemd service..." --weight=2
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
@ -135,13 +134,14 @@ ynh_add_systemd_config
#================================================= #=================================================
cp ../conf/cron_lutim /etc/cron.d/$app cp ../conf/cron_lutim /etc/cron.d/$app
ynh_replace_string "__FINALPATH__" "$final_path/" /etc/cron.d/$app ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file=/etc/cron.d/$app
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=/etc/cron.d/$app
chmod +x $final_path/script/lutim chmod +x $final_path/script/lutim
#================================================= #=================================================
# INSTALL LUTIM WITH CARTON # INSTALL LUTIM WITH CARTON
#================================================= #=================================================
ynh_script_progression --message="Install Lutim with Carton" --weight=60 ynh_script_progression --message="Installing Lutim with Carton..." --weight=60
mkdir -p /var/log/$app/ mkdir -p /var/log/$app/
(cd $final_path (cd $final_path
@ -151,9 +151,9 @@ carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log")
arch_dir=$(ls -1 $final_path/local/lib/perl5/ | grep linux-gnu) arch_dir=$(ls -1 $final_path/local/lib/perl5/ | grep linux-gnu)
if [ "$?" -ne 0 ] if [ "$?" -ne 0 ]
then then
ynh_die "Unable to find the perl directory for your architecture." ynh_die --message="Unable to find the perl directory for your architecture."
fi fi
ynh_replace_string "__ARCHDIR__" "$arch_dir" "$final_path/script/lutim" ynh_replace_string --match_string="__ARCHDIR__" --replace_string="$arch_dir" --target_file="$final_path/script/lutim"
#================================================= #=================================================
# SETUP LOG FILE # SETUP LOG FILE
@ -176,7 +176,7 @@ chown -R $app: $final_path
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Configure logrotate" --weight=2 ynh_script_progression --message="Configuring log rotation..." --weight=2
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_use_logrotate
@ -185,14 +185,14 @@ ynh_use_logrotate
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add lutim -l $final_path/log/production.log yunohost service add $app --log $final_path/log/production.log
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Setup SSOwat" ynh_script_progression --message="Configuring SSOwat..."
ynh_app_setting_set $app skipped_uris "/" ynh_app_setting_set --app=$app --key=skipped_uris --value="/"
if [ $is_public -eq 0 ] if [ $is_public -eq 0 ]
then then
# If the app is private, viewing images stays publicly accessible. # If the app is private, viewing images stays publicly accessible.
@ -202,20 +202,20 @@ then
fi fi
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g') domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set $app protected_regex "$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$" ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reload nginx" --weight=2 ynh_script_progression --message="Reloading nginx web server..." --weight=2
ynh_systemd_action --action=reload --service_name=nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# CHECK LUTIM BOOTING # CHECK LUTIM BOOTING
#================================================= #=================================================
ynh_script_progression --message="Restart Lutim" --weight=6 ynh_script_progression --message="Restarting Lutim..." --weight=6
# Wait for lutim to be fully started # Wait for lutim to be fully started
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
@ -237,10 +237,10 @@ You can also find some specific actions for this app by using the experimental _
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/lutim_ynh__URL_TAG3__." > mail_to_send If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/lutim_ynh__URL_TAG3__." > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="install" ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=install
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation completed" --last ynh_script_progression --message="Installation of $app completed" --time --last

View file

@ -12,18 +12,19 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Load settings" --weight=2 ynh_script_progression --message="Loading installation settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
#================================================= #=================================================
# STOP AND REMOVE SERVICE # STOP AND REMOVE SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stop and remove the service" --weight=6 ynh_script_progression --message="Stopping and removing the systemd service..." --weight=6
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
@ -33,16 +34,16 @@ ynh_remove_systemd_config
#================================================= #=================================================
# Check if the service is declared in YunoHost # Check if the service is declared in YunoHost
if yunohost service status | grep -q $app if ynh_exec_fully_quiet yunohost service status $app
then then
ynh_print_info "Remove $app service" >&2 ynh_script_progression --message="Removing $app service..."
yunohost service remove $app yunohost service remove $app
fi fi
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Remove dependencies" --weight=20 ynh_script_progression --message="Removing dependencies..." --weight=20
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -50,15 +51,15 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Remove app main directory" --weight=2 ynh_script_progression --message="Removing app main directory..." --weight=2
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove "/var/www/$app" ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Remove nginx configuration" ynh_script_progression --message="Removing nginx web server configuration..."
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -66,7 +67,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Remove logrotate configuration" ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
@ -77,20 +78,20 @@ ynh_remove_logrotate
# REMOVE CRON JOB # REMOVE CRON JOB
#================================================= #=================================================
ynh_secure_remove "/etc/cron.d/$app" ynh_secure_remove --file="/etc/cron.d/$app"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Remove the dedicated user" --weight=5 ynh_script_progression --message="Removing the dedicated system user..." --weight=5
# Delete dedicated system user # Delete dedicated system user
ynh_system_user_delete $app ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Deletion completed" --last ynh_script_progression --message="Removal of $app completed" --time --last

View file

@ -25,27 +25,28 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Load settings" --weight=2 ynh_script_progression --message="Loading settings..." --weight=2
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get --app=$app --key=path)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..."
ynh_webpath_available $domain $path_url \ ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die "There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Activate maintenance mode" --weight=2 ynh_script_progression --message="Activating maintenance mode..." --weight=2
ynh_maintenance_mode_ON ynh_maintenance_mode_ON
@ -55,22 +56,22 @@ ynh_maintenance_mode_ON
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restore the app main directory" ynh_script_progression --message="Restoring the app main directory..."
ynh_restore_file "$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreate the dedicated user" --weight=2 ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create --username=$app
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
@ -84,7 +85,7 @@ chown -R $app: $final_path
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstall dependencies" --weight=60 ynh_script_progression --message="Reinstalling dependencies..." --weight=60
ynh_install_app_dependencies $app_depencencies ynh_install_app_dependencies $app_depencencies
@ -92,21 +93,21 @@ ynh_install_app_dependencies $app_depencencies
# ADVERTISE SERVICE IN ADMIN PANEL # ADVERTISE SERVICE IN ADMIN PANEL
#================================================= #=================================================
yunohost service add $app --log "/var/log/$app/APP.log" yunohost service add $app --log $final_path/log/production.log
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Restore the systemd configuration" ynh_script_progression --message="Restoring the systemd configuration..."
ynh_restore_file "/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service systemctl enable $app.service
#================================================= #=================================================
# RESTORE THE CRON FILE # RESTORE THE CRON FILE
#================================================= #=================================================
ynh_restore_file "/etc/cron.d/$app" ynh_restore_file --origin_path="/etc/cron.d/$app"
#================================================= #=================================================
# SETUP LOG FILE # SETUP LOG FILE
@ -121,21 +122,21 @@ chown $app -R /var/log/$app
# RESTORE LOGROTATE CONFIGURATION # RESTORE LOGROTATE CONFIGURATION
#================================================= #=================================================
ynh_restore_file "/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reload nginx" --weight=2 ynh_script_progression --message="Reloading nginx web server..." --weight=2
ynh_systemd_action --action=reload --service_name=nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# START AND CHECK LUTIM BOOTING # START AND CHECK LUTIM BOOTING
#================================================= #=================================================
ynh_script_progression --message="Restart Lutim" --weight=3 ynh_script_progression --message="Restarting Lutim..." --weight=3
# Wait for lutim to be fully started # Wait for lutim to be fully started
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
@ -143,7 +144,7 @@ ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="
#================================================= #=================================================
# DEACTIVE MAINTENANCE MODE # DEACTIVE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Disable maintenance mode" --weight=7 ynh_script_progression --message="Disabling maintenance mode..." --weight=7
ynh_maintenance_mode_OFF ynh_maintenance_mode_OFF
@ -161,10 +162,10 @@ You can also find some specific actions for this app by using the experimental _
If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/lutim_ynh__URL_TAG3__." > mail_to_send If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/lutim_ynh__URL_TAG3__." > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="restore" ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=restore
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed" --last ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -14,24 +14,26 @@ source _variables
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Load settings" --weight=4 ynh_script_progression --message="Loading installation settings..." --weight=4
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get --app=$app --key=path)
is_public=$(ynh_app_setting_get $app is_public) is_public=$(ynh_app_setting_get --app=$app --key=is_public)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get --app=$app --key=port)
always_encrypt=$(ynh_app_setting_get $app always_encrypt) always_encrypt=$(ynh_app_setting_get --app=$app --key=always_encrypt)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
secret=$(ynh_app_setting_get $app secret) secret=$(ynh_app_setting_get --app=$app --key=secret)
overwrite_settings=$(ynh_app_setting_get $app overwrite_settings)
overwrite_nginx=$(ynh_app_setting_get $app overwrite_nginx) overwrite_settings=$(ynh_app_setting_get --app=$app --key=overwrite_settings)
overwrite_systemd=$(ynh_app_setting_get $app overwrite_systemd) overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx)
overwrite_systemd=$(ynh_app_setting_get --app=$app --key=overwrite_systemd)
admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
# Optional parameters from config-panel feature # Optional parameters from config-panel feature
antiflood=$(ynh_app_setting_get $app antiflood) antiflood=$(ynh_app_setting_get --app=$app --key=antiflood)
delay=$(ynh_app_setting_get $app delay) delay=$(ynh_app_setting_get --app=$app --key=delay)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -42,55 +44,54 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensure downward compatibility" --weight=2 ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
# Fix is_public as a boolean # Fix is_public as a boolean
if [ "$is_public" = "Yes" ]; then if [ "$is_public" = "Yes" ]; then
ynh_app_setting_set $app is_public 1 ynh_app_setting_set --app=$app --key=is_public --value=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=$app --key=is_public --value=0
is_public=0 is_public=0
fi fi
# if final_path isn't set, which can happens with old scripts, set final_path. # if final_path isn't set, which can happens with old scripts, set final_path.
if [ "${#final_path}" -eq 0 ] if [ -z "$final_path" ]; then
then
final_path=/var/www/$app final_path=/var/www/$app
ynh_app_setting_set $app final_path $final_path ynh_app_setting_set --app=$app --key=final_path --value=$final_path
fi fi
# Fix always_encrypt as a boolean # Fix always_encrypt as a boolean
if [ "$always_encrypt" = "Yes" ]; then if [ "$always_encrypt" = "Yes" ]; then
ynh_app_setting_set $app always_encrypt 1 ynh_app_setting_set --app=$app --key=always_encrypt --value=1
always_encrypt=1 always_encrypt=1
elif [ "$always_encrypt" = "No" ]; then elif [ "$always_encrypt" = "No" ]; then
ynh_app_setting_set $app always_encrypt 0 ynh_app_setting_set --app=$app --key=always_encrypt --value=0
always_encrypt=0 always_encrypt=0
fi fi
# If overwrite_settings doesn't exist, create it # If overwrite_settings doesn't exist, create it
if [ -z "$overwrite_settings" ]; then if [ -z "$overwrite_settings" ]; then
overwrite_settings=1 overwrite_settings=1
ynh_app_setting_set $app overwrite_settings $overwrite_settings ynh_app_setting_set --app=$app --key=overwrite_settings --value=$overwrite_settings
fi fi
# If overwrite_nginx doesn't exist, create it # If overwrite_nginx doesn't exist, create it
if [ -z "$overwrite_nginx" ]; then if [ -z "$overwrite_nginx" ]; then
overwrite_nginx=1 overwrite_nginx=1
ynh_app_setting_set $app overwrite_nginx $overwrite_nginx ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx
fi fi
# If overwrite_systemd doesn't exist, create it # If overwrite_systemd doesn't exist, create it
if [ -z "$overwrite_systemd" ]; then if [ -z "$overwrite_systemd" ]; then
overwrite_systemd=1 overwrite_systemd=1
ynh_app_setting_set $app overwrite_systemd $overwrite_systemd ynh_app_setting_set --app=$app --key=overwrite_systemd --value=$overwrite_systemd
fi fi
# If secret doesn't exist, create it # If secret doesn't exist, create it
if [ -z "$secret" ]; then if [ -z "$secret" ]; then
secret=$(grep "secrets *=>" "$final_path/lutim.conf" | cut -d\' -f2) secret=$(grep "secrets *=>" "$final_path/lutim.conf" | cut -d\' -f2)
ynh_app_setting_set $app secret $secret ynh_app_setting_set --app=$app --key=secret --value=$secret
fi fi
# Close opened port # Close opened port
@ -102,7 +103,7 @@ fi
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backup the app before upgrading" --weight=15 ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=15
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
@ -120,12 +121,12 @@ ynh_abort_if_errors
#================================================= #=================================================
# 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=$path_url)
#================================================= #=================================================
# ACTIVATE MAINTENANCE MODE # ACTIVATE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Activate maintenance mode" --weight=2 ynh_script_progression --message="Activating maintenance mode..." --weight=2
ynh_maintenance_mode_ON ynh_maintenance_mode_ON
@ -137,15 +138,15 @@ ynh_maintenance_mode_ON
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Download, check and unpack source" ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path" ynh_setup_source --dest_dir="$final_path"
fi fi
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrade dependencies" --weight=9 ynh_script_progression --message="Upgrading dependencies..." --weight=9
ynh_install_app_dependencies $app_depencencies ynh_install_app_dependencies $app_depencencies
@ -156,17 +157,17 @@ ynh_install_app_dependencies $app_depencencies
# Overwrite the nginx configuration only if it's allowed # Overwrite the nginx configuration only if it's allowed
if [ $overwrite_nginx -eq 1 ] if [ $overwrite_nginx -eq 1 ]
then then
ynh_script_progression --message="Reconfigure nginx" --weight=2 ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2
ynh_add_nginx_config ynh_add_nginx_config
fi fi
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Create a dedicated user" ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create $app ynh_system_user_create --username=$app
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -180,26 +181,28 @@ if [ $overwrite_settings -eq 1 ]
then then
# Configure Lutim # Configure Lutim
# Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
ynh_backup_if_checksum_is_different "$final_path/lutim.conf" ynh_backup_if_checksum_is_different --file="$final_path/lutim.conf"
cp ../conf/lutim.conf.template "$final_path/lutim.conf" cp ../conf/lutim.conf.template "$final_path/lutim.conf"
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/lutim.conf" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/lutim.conf"
ynh_replace_string "__PATH__" "$path_url" "$final_path/lutim.conf" ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$final_path/lutim.conf"
ynh_replace_string "__PORT__" "$port" "$final_path/lutim.conf" ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$final_path/lutim.conf"
ynh_replace_string "__ENCRYPT__" "$always_encrypt" "$final_path/lutim.conf" ynh_replace_string --match_string="__ENCRYPT__" --replace_string="$always_encrypt" --target_file="$final_path/lutim.conf"
ynh_replace_string "__SECRET__" "$secret" "$final_path/lutim.conf" ynh_replace_string --match_string="__SECRET__" --replace_string="$secret" --target_file="$final_path/lutim.conf"
# Set the number of process for Lutim to twice the number of CPU core.
ynh_replace_string --match_string="__WORKERS__" --replace_string="$(( $(nproc) * 2 ))" --target_file="$final_path/lutim.conf"
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum "$final_path/lutim.conf" ynh_store_file_checksum --file="$final_path/lutim.conf"
# Optional parameters from config-panel feature # Optional parameters from config-panel feature
if [ -n "$antiflood" ]; then if [ -n "$antiflood" ]; then
ynh_replace_string ".*anti_flood_delay *=>.*" " anti_flood_delay => $antiflood," "$final_path/lutim.conf" ynh_replace_string --match_string=".*anti_flood_delay *=>.*" --replace_string=" anti_flood_delay => $antiflood," --target_file="$final_path/lutim.conf"
# Disable anti_flood_delay if the delay is 0 # Disable anti_flood_delay if the delay is 0
if [ $antiflood = 0 ]; then if [ $antiflood = 0 ]; then
ynh_replace_string "\(anti_flood_delay *=>.*\)" "#\1" "$final_path/lutim.conf" ynh_replace_string --match_string="\(anti_flood_delay *=>.*\)" --replace_string="#\1" --target_file="$final_path/lutim.conf"
fi fi
fi fi
if [ -n "$delay" ]; then if [ -n "$delay" ]; then
ynh_replace_string ".*default_delay *=>.*" " default_delay => $delay," "$final_path/lutim.conf" ynh_replace_string --match_string=".*default_delay *=>.*" --replace_string=" default_delay => $delay," --target_file="$final_path/lutim.conf"
fi fi
fi fi
@ -210,7 +213,7 @@ fi
# Overwrite the systemd configuration only if it's allowed # Overwrite the systemd configuration only if it's allowed
if [ $overwrite_systemd -eq 1 ] if [ $overwrite_systemd -eq 1 ]
then then
ynh_script_progression --message="Reconfigure systemd" --weight=2 ynh_script_progression --message="Upgrading systemd configuration..." --weight=2
ynh_add_systemd_config ynh_add_systemd_config
fi fi
@ -219,7 +222,8 @@ fi
#================================================= #=================================================
cp ../conf/cron_lutim /etc/cron.d/$app cp ../conf/cron_lutim /etc/cron.d/$app
ynh_replace_string "__FINALPATH__" "$final_path/" /etc/cron.d/$app ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path/" --target_file=/etc/cron.d/$app
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file=/etc/cron.d/$app
#================================================= #=================================================
# UPDATE LUTIM WITH CARTON # UPDATE LUTIM WITH CARTON
@ -227,7 +231,7 @@ ynh_replace_string "__FINALPATH__" "$final_path/" /etc/cron.d/$app
if [ "$upgrade_type" == "UPGRADE_APP" ] if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrade Lutim with carton" --weight=4 ynh_script_progression --message="Upgrading Lutim with carton..." --weight=4
(cd $final_path (cd $final_path
carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log") carton install 2>&1 | tee -a "/var/log/$app/setup_carton.log")
fi fi
@ -244,7 +248,7 @@ chown -R $app: $final_path
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Reconfigure logrotate" ynh_script_progression --message="Upgrading logrotate configuration..."
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
chown $app -R /var/log/$app chown $app -R /var/log/$app
@ -252,28 +256,28 @@ chown $app -R /var/log/$app
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Reconfigure SSOwat" ynh_script_progression --message="Upgrading SSOwat configuration..."
ynh_app_setting_set $app skipped_uris "/" ynh_app_setting_set --app=$app --key=skipped_uris --value="/"
if [ $is_public -eq 0 ] if [ $is_public -eq 0 ]
then then
# If the app is private, viewing images stays publicly accessible. # If the app is private, viewing images stays publicly accessible.
# Modify the domain to be used in a regex # Modify the domain to be used in a regex
domain_regex=$(echo "$domain" | sed 's@-@.@g') domain_regex=$(echo "$domain" | sed 's@-@.@g')
ynh_app_setting_set $app protected_regex "$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$" ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$"
fi fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reload nginx" ynh_script_progression --message="Reloading nginx web server..."
ynh_systemd_action --action=reload --service_name=nginx ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# START AND CHECK LUTIM BOOTING # START AND CHECK LUTIM BOOTING
#================================================= #=================================================
ynh_script_progression --message="Restart Lutim" --weight=4 ynh_script_progression --message="Restarting Lutim..." --weight=4
# Wait for lutim to be fully started # Wait for lutim to be fully started
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
@ -281,7 +285,7 @@ ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="
#================================================= #=================================================
# DEACTIVE MAINTENANCE MODE # DEACTIVE MAINTENANCE MODE
#================================================= #=================================================
ynh_script_progression --message="Disable maintenance mode" --weight=7 ynh_script_progression --message="Disabling maintenance mode..." --weight=7
ynh_maintenance_mode_OFF ynh_maintenance_mode_OFF
@ -307,10 +311,10 @@ If you're facing an issue or want to improve this app, please open a new issue i
Changelog since your last upgrade: Changelog since your last upgrade:
$(cat changelog)" > mail_to_send $(cat changelog)" > mail_to_send
ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="upgrade" ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=upgrade
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade completed" --last ynh_script_progression --message="Upgrade of $app completed" --last