diff --git a/README.md b/README.md
index 9dbba40..e768edc 100644
--- a/README.md
+++ b/README.md
@@ -5,13 +5,13 @@
*[Lire ce readme en français.](./README_fr.md)*
-> *This package allow you to install Jenkins quickly and simply on a YunoHost server.
-If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.*
+> *This package allows you to install Jenkins quickly and simply on a YunoHost server.
+If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
The leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project.
-**Shipped version:** 2.263.1
+**Shipped version:** 2.263.4
## Screenshots
@@ -28,35 +28,30 @@ Use the admin panel of your Jenkins to configure this app.
## Documentation
* Official documentation: https://jenkins.io/doc/
- * YunoHost documentation: There no other documentations, feel free to contribute.
## YunoHost specific features
-#### Multi-users support
+#### Multi-user support
Supported, with LDAP and SSO.
#### Supported architectures
-* x86-64 - [![](https://ci-apps.yunohost.org/ci/logs/jenkins%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/jenkins/)
-* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/jenkins%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/jenkins/)
-
-## Limitations
-
-## Additionnal informations
+* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/jenkins%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/jenkins/)
+* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jenkins%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/jenkins/)
## Links
* Report a bug: https://github.com/YunoHost-Apps/jenkins_ynh/issues
- * Jenkins website: https://jenkins.io
- * Jenkins repository: https://github.com/jenkinsci/jenkins
+ * App website: https://jenkins.io
+ * Upstream app repository: https://github.com/jenkinsci/jenkins
* YunoHost website: https://yunohost.org/
---
-## Developers infos
+## Developer info
-Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/jenkins_ynh/tree/testing).
+Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/jenkins_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
diff --git a/README_fr.md b/README_fr.md
index 2ed3ad1..e9213b5 100644
--- a/README_fr.md
+++ b/README_fr.md
@@ -6,12 +6,12 @@
*[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer Jenkins rapidement et simplement sur un serveur YunoHost.
-Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/install_fr) pour savoir comment l'installer et en profiter.*
+Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.*
## Vue d'ensemble
Premier serveur d'automatisation open source, Jenkins fournit des centaines de plugins pour supporter la construction, le déploiement et l'automatisation de n'importe quel projet.
-**Version embarquée :** 2.263.1
+**Version incluse :** 2.263.4
## Captures d'écran
@@ -30,35 +30,31 @@ Utiliser le panneau d'administration de Jenkins pour configurer cette applicatio
* Documentation officielle : https://jenkins.io/doc/
* Documentation YunoHost : Il n'y a pas d'autre documentation, n'hésitez pas à contribuer.
-## Fonctionnalités spécifiques à YunoHost
+## Caractéristiques spécifiques YunoHost
#### Support multi-utilisateurs
Supportée, avec LDAP et SSO.
-#### Architectures supportées.
+#### Architectures supportées
-* x86-64 - [![](https://ci-apps.yunohost.org/ci/logs/jenkins%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/jenkins/)
-* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/jenkins%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/jenkins/)
-
-## Limitations
-
-## Informations additionnelles
+* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/jenkins%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/jenkins/)
+* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jenkins%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/jenkins/)
## Liens
- * Reporter un bug : https://github.com/YunoHost-Apps/jenkins_ynh/issues
- * Site de jenkins : https://jenkins.io
- * Dépôt git de Jenkins : https://github.com/jenkinsci/jenkins
- * Site de YunoHost : https://yunohost.org/
+ * Signaler un bug : https://github.com/YunoHost-Apps/jenkins_ynh/issues
+ * Site de l'application : https://jenkins.io
+ * Dépôt de l'application principale : https://github.com/jenkinsci/jenkins
+ * Site web YunoHost : https://yunohost.org/
---
-## Informations à l'intention des développeurs
+## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/jenkins_ynh/tree/testing).
-Pour tester la branche testing, merci de procéder ainsi.
+Pour essayer la branche testing, procédez comme suit.
```
sudo yunohost app install https://github.com/YunoHost-Apps/jenkins_ynh/tree/testing --debug
ou
diff --git a/YEP.md b/YEP.md
deleted file mode 100644
index 3b505b5..0000000
--- a/YEP.md
+++ /dev/null
@@ -1,117 +0,0 @@
-#### [Level 0](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-0)
-[YEP 1.1 - Nommer son app et son dépot](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-11)
-`Validated`
-[YEP 1.2 - Inscrire l'app sur un "répertoire" connu](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-12)
-`Validated`
-
-#### [Level 1](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-1)
-[YEP 2.2 - Utiliser bash pour les scripts principaux](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-22)
-`Validated`
-[YEP 2.5 - Copier correctement des fichiers](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-25)
-`Don't know`
-[YEP 2.7 - Donner des permissions suffisantes aux instructions bash](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-27)
-`Validated`
-[YEP 2.15 - Suivre les instructions d'installation de l'application](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-215)
-`Validated`
-
-#### [Level 2](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-2)
-[YEP 1.5 - Mettre à jour régulièrement le statut de l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-11)
-`Validated`
-[YEP 2.18.2 - Gérer l'installation à la racine d’un nom de domaine](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2182)
-`Validated` - *Automatically verified.*
-[YEP 2.18.3 - Gérer l'installation sur un sous-domaine](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2183)
-`Validated` - *Automatically verified.*
-[YEP 2.18.4 - Gérer l'installation sur un chemin /path](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2184)
-`Validated` - *Automatically verified.*
-[YEP 4.6 - Gère le multi-instance](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-11)
-`Not applicable`
-
-#### [Level 3](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-3)
-[YEP 2.3 - Sauvegarder les réponses lors de l'installation](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-23)
-`Validated`
-
-#### [Level 4](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-4)
-[YEP 4.1 - Lier au ldap](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-41)
-`Validated`
-[YEP 4.2 - Lier l'authentification au sso](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-42)
-`Validated`
-
-#### [Level 5](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-5)
-[YEP 1.3 - Indiquer la licence associée au paquet](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-13)
-`Validated`
-[YEP 2.1 - Respecter le format du manifeste](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-21)
-`Validated` - *Automatically verified.*
-[YEP 2.12 - Utiliser les commandes pratiques (helpers)](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-212)
-`Validated`
-[YEP 2.18.1 - Lancer le script d'installation d'une webapp correctement](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2181)
-`Not applicable`
-
-#### [Level 6](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-6)
-[YEP 1.4 - Informer sur l'intention de maintenir un paquet](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-14)
-`Validated`
-[YEP 1.6 - Se tenir informé sur l'évolution du packaging d'apps](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-16)
-`Validated`
-[YEP 1.7 - Ajouter l'app à l'organisation YunoHost-Apps](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-17)
-`Validated` - *Automatically verified.*
-[YEP 1.8 - Publier des demandes de test](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-18)
-`Validated`
-[YEP 1.9 - Documenter l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-19)
-`Validated`
-[YEP 1.10 - Garder un historique de version propre](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-110)
-`Don't know`
-[YEP 2.9 - Enlever toutes traces de l'app lors de la suppression](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-29)
-`Validated`
-[YEP 3.3 - Faciliter le contrôle de l'intégrité des sources](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-33)
-`Not yet validated`
-[YEP 3.5 - Suivre les recommendations de la documentation de l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-35)
-`Validated`
-[YEP 3.6 - Mettre à jour les versions contenant des CVE](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-36)
-`Validated`
-[YEP 4.3 - Fournir un script de sauvegarde YunoHost fonctionnel](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-43)
-`Validated` - *Automatically verified.*
-[YEP 4.4 - Fournir un script de restauration YunoHost fonctionnel](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-44)
-`Validated` - *Automatically verified.*
-
-#### [Level 7](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-7)
-[YEP 2.6 - Annuler l'action si les valeurs d'entrées sont incorrectes](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-26)
-`Validated`
-[YEP 3.2 - Ouvrir un port correctement](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-32)
-`Validated`
-
-#### [Level 8](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-8)
-[YEP 2.4 - Détecter et gérer les erreurs](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-24)
-`Validated`
-[YEP 2.8 - Modifier correctement une configuration système](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-28)
-`Validated`
-[YEP 2.16 - Vérifier la disponibilité des dépendances sur ARM, x86 et x64](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-216)
-`Not yet validated` - *Automatically verified.*
-[YEP 2.18.5 - Gérer la tuile YunoHost pour faciliter la navigation entre les applications](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-2185)
-`Validated`
-[YEP 3.4 - Isoler l'app](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-34)
-`Not yet validated`
-[YEP 4.5 - Utiliser les hooks](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-45)
-`Not applicable`
-
-#### [Level 9](https://github.com/YunoHost/doc/blob/master/packaging_apps_levels_fr.md#niveau-9)
-[YEP 2.10 - Configurer les logs de l'application](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-210)
-`Not applicable`
-[YEP 2.11 - Utiliser une variable plutôt que l'app id directement](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-211)
-`Validated`
-[YEP 2.13 - Traduire le paquet en anglais](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-213)
-`Not yet validated`
-[YEP 2.14 - Remplir correctement un fichier de conf](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-214)
-`Not yet validated`
-[YEP 2.17 - Prendre en compte la version d'origine lors des mises à jour](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-217)
-`Validated`
-[YEP 4.2.1 - Déconnexion](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-421)
-`Don't know`
-
-#### Other YEP
-[YEP 3.1 - Ne pas demander ou stocker de mot de passe LDAP](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-31)
-`Validated`
-[YEP 4.7 - Ajouter un module à la CLI](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-47)
-`Not applicable`
-[YEP 4.8 - Ajouter un module à l'admin web](https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-48)
-`Not applicable`
-
-State of each YEP can be one of these: `Validated`, `Partially validated`, `Not yet validated`, `Not applicable`, `Don't know`.
diff --git a/check_process b/check_process
index ff22049..622fe43 100644
--- a/check_process
+++ b/check_process
@@ -11,10 +11,12 @@
setup_private=1
setup_public=1
upgrade=1
+ # 2.150.2~ynh2
upgrade=1 from_commit=29141b702f2954e0f72925121aea82a7fa3fc118
+ # 2.263.1~ynh1
+ upgrade=1 from_commit=0e1aae7be82034650e2c1f6c1ad6d68a41b80176
backup_restore=1
multi_instance=0
- incorrect_path=1
port_already_use=1 (8080)
change_url=1
;;; Options
@@ -22,5 +24,7 @@ Email=
Notification=down
;;; Upgrade options
; commit=29141b702f2954e0f72925121aea82a7fa3fc118
- name= Fix for getopts 13 Apr 2019
+ name=Fix for getopts 13 Apr 2019
manifest_arg=domain=DOMAIN&path=PATH&is_public=1&
+ ; commit=0e1aae7be82034650e2c1f6c1ad6d68a41b80176
+ name=2.263.1~ynh1
diff --git a/conf/app.src b/conf/app.src
index fe47360..7b489dd 100644
--- a/conf/app.src
+++ b/conf/app.src
@@ -1,5 +1,5 @@
-SOURCE_URL=https://pkg.jenkins.io/debian-stable/binary/jenkins_2.263.1_all.deb
-SOURCE_SUM=faae72cc486c3032be31d47ddcaa7bce77aba54ad6bb900ec73550f8096348ba
+SOURCE_URL=https://pkg.jenkins.io/debian-stable/binary/jenkins_2.263.4_all.deb
+SOURCE_SUM=0c7b15c9502c7d045755b2d0c7f8dfbc35a05adea27c1f7c35bbeca049bcc0ae
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=deb
SOURCE_IN_SUBDIR=true
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 87652d7..5771bc8 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -1,30 +1,30 @@
location __PATH__ {
- proxy_pass http://127.0.0.1:__PORT__;
- proxy_redirect http://127.0.0.1:__PORT__ https://__DOMAIN____PATH__;
+ proxy_pass http://127.0.0.1:__PORT__;
+ proxy_redirect http://127.0.0.1:__PORT__ https://__DOMAIN____PATH__;
- proxy_set_header Host $host:$server_port;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
- proxy_set_header X-NginX-Proxy true;
- proxy_set_header X-Forwarded-User $remote_user;
+ proxy_set_header Host $host:$server_port;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header X-NginX-Proxy true;
+ proxy_set_header X-Forwarded-User $remote_user;
- sendfile off;
+ sendfile off;
- proxy_max_temp_file_size 0;
+ proxy_max_temp_file_size 0;
- client_max_body_size 10m;
- client_body_buffer_size 128k;
+ client_max_body_size 10m;
+ client_body_buffer_size 128k;
- proxy_connect_timeout 90;
- proxy_send_timeout 90;
- proxy_read_timeout 90;
+ proxy_connect_timeout 90;
+ proxy_send_timeout 90;
+ proxy_read_timeout 90;
- proxy_buffer_size 4k;
- proxy_buffers 4 32k;
- proxy_busy_buffers_size 64k;
- proxy_temp_file_write_size 64k;
+ proxy_buffer_size 4k;
+ proxy_buffers 4 32k;
+ proxy_busy_buffers_size 64k;
+ proxy_temp_file_write_size 64k;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
diff --git a/manifest.json b/manifest.json
index 6ea98dd..9e55626 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,63 +1,63 @@
{
- "name": "Jenkins",
- "id": "jenkins",
- "packaging_format": 1,
- "description": {
- "en": "Extendable continuous integration server",
- "fr": "Serveur d'intégration continue extensible"
- },
- "version": "2.263.1~ynh1",
- "url": "https://jenkins.io/index.html",
- "license": "MIT",
- "maintainer": {
- "name": "None...",
- "email": ""
- },
- "previous_maintainers": [{
- "name": "Julien Malik et Maniack Crudelis",
- "email": "maniackc_dev@crudelis.fr"
- }],
- "requirements": {
- "yunohost": ">= 4.0.0"
- },
- "multi_instance": false,
- "services": [
- "nginx"
- ],
- "arguments": {
- "install" : [
- {
- "name": "domain",
- "type": "domain",
- "ask": {
- "en": "Choose a domain for Jenkins",
- "fr": "Choisissez un domaine pour Jenkins"
- },
- "example": "domain.org"
- },
- {
- "name": "path",
- "type": "path",
- "ask": {
- "en": "Choose a path for Jenkins",
- "fr": "Choisissez un chemin pour Jenkins"
- },
- "example": "/jenkins",
- "default": "/jenkins"
- },
- {
- "name": "is_public",
- "type": "boolean",
- "ask": {
- "en": "Is it a public site?",
- "fr": "Est-ce un site public ?"
- },
- "default": true,
- "help": {
- "en": "A public Jenkins will be accessible by everyone unless you configure the security into jenkins admin panel.",
- "fr": "Un Jenkins public sera accessible par tout le monde à moins que vous ne configuriez la sécurité dans le panneau d'administration de jenkins."
- }
- }
- ]
- }
+ "name": "Jenkins",
+ "id": "jenkins",
+ "packaging_format": 1,
+ "description": {
+ "en": "Extendable continuous integration server",
+ "fr": "Serveur d'intégration continue extensible"
+ },
+ "version": "2.263.1~ynh1",
+ "url": "https://jenkins.io/index.html",
+ "license": "MIT",
+ "maintainer": {
+ "name": "",
+ "email": ""
+ },
+ "previous_maintainers": [{
+ "name": "Julien Malik et Maniack Crudelis",
+ "email": "maniackc_dev@crudelis.fr"
+ }],
+ "requirements": {
+ "yunohost": ">= 4.1.3"
+ },
+ "multi_instance": false,
+ "services": [
+ "nginx"
+ ],
+ "arguments": {
+ "install" : [
+ {
+ "name": "domain",
+ "type": "domain",
+ "ask": {
+ "en": "Choose a domain for Jenkins",
+ "fr": "Choisissez un domaine pour Jenkins"
+ },
+ "example": "example.com"
+ },
+ {
+ "name": "path",
+ "type": "path",
+ "ask": {
+ "en": "Choose a path for Jenkins",
+ "fr": "Choisissez un chemin pour Jenkins"
+ },
+ "example": "/jenkins",
+ "default": "/jenkins"
+ },
+ {
+ "name": "is_public",
+ "type": "boolean",
+ "ask": {
+ "en": "Is it a public application?",
+ "fr": "Est-ce une application publique ?"
+ },
+ "default": true,
+ "help": {
+ "en": "A public Jenkins will be accessible by everyone unless you configure the security into jenkins admin panel.",
+ "fr": "Un Jenkins public sera accessible par tout le monde à moins que vous ne configuriez la sécurité dans le panneau d'administration de jenkins."
+ }
+ }
+ ]
+ }
}
diff --git a/scripts/_common.sh b/scripts/_common.sh
index d25a65a..0fdcedc 100755
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -4,25 +4,13 @@
# COMMON VARIABLES
#=================================================
-app_depencencies="openjdk-11-jdk daemon net-tools"
+# dependencies used by the app
+pkg_dependencies="openjdk-11-jdk daemon net-tools"
#=================================================
# PERSONAL HELPERS
#=================================================
-#=================================================
-# PACKAGE CHECK BYPASSING...
-#=================================================
-
-IS_PACKAGE_CHECK () {
- if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]
- then
- return 0
- else
- return 1
- fi
-}
-
#=================================================
# BOOLEAN CONVERTER
#=================================================
@@ -41,393 +29,10 @@ bool_to_true_false () {
echo "$var"
}
-#=================================================
-# FUTUR OFFICIAL HELPERS
-#=================================================
-
-# Install or update the main directory yunohost.multimedia
-#
-# usage: ynh_multimedia_build_main_dir
-ynh_multimedia_build_main_dir () {
- local ynh_media_release="v1.2"
- local checksum="806a827ba1902d6911095602a9221181"
-
- # Download yunohost.multimedia scripts
- wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz 2>&1
-
- # Check the control sum
- echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \
- || ynh_die "Corrupt source"
-
- # Check if the package acl is installed. Or install it.
- ynh_package_is_installed 'acl' \
- || ynh_package_install acl
-
- # Extract
- mkdir yunohost.multimedia-master
- tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1
- ./yunohost.multimedia-master/script/ynh_media_build.sh
-}
-
-# Add a directory in yunohost.multimedia
-# This "directory" will be a symbolic link to a existing directory.
-#
-# usage: ynh_multimedia_addfolder "Source directory" "Destination directory"
-#
-# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias.
-# | arg: -d, --dest_dir= - Destination directory - The name and the place of the symbolic link, relative to "/home/yunohost.multimedia"
-ynh_multimedia_addfolder () {
- # Declare an array to define the options of this helper.
- declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= )
- local source_dir
- local dest_dir
- # Manage arguments with getopts
- ynh_handle_getopts_args "$@"
-
- ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --source="$source_dir" --dest="$dest_dir"
-}
-
-# Move a directory in yunohost.multimedia, and replace by a symbolic link
-#
-# usage: ynh_multimedia_movefolder "Source directory" "Destination directory"
-#
-# | arg: -s, --source_dir= - Source directory - The real directory which contains your medias.
-# It will be moved to "Destination directory"
-# A symbolic link will replace it.
-# | arg: -d, --dest_dir= - Destination directory - The new name and place of the directory, relative to "/home/yunohost.multimedia"
-ynh_multimedia_movefolder () {
- # Declare an array to define the options of this helper.
- declare -Ar args_array=( [s]=source_dir= [d]=dest_dir= )
- local source_dir
- local dest_dir
- # Manage arguments with getopts
- ynh_handle_getopts_args "$@"
-
- ./yunohost.multimedia-master/script/ynh_media_addfolder.sh --inv --source="$source_dir" --dest="$dest_dir"
-}
-
-# Allow an user to have an write authorisation in multimedia directories
-#
-# usage: ynh_multimedia_addaccess user_name
-#
-# | arg: -u, --user_name= - The name of the user which gain this access.
-ynh_multimedia_addaccess () {
- # Declare an array to define the options of this helper.
- declare -Ar args_array=( [u]=user_name=)
- local user_name
- # Manage arguments with getopts
- ynh_handle_getopts_args "$@"
-
- groupadd -f multimedia
- usermod -a -G multimedia $user_name
-}
-
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
-# Send an email to inform the administrator
-#
-# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
-# | arg: -m --app_message= - The file with the content to send to the administrator.
-# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
-# example: "root admin@domain"
-# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
-# example: "root admin@domain user1 user2"
-# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade'
-ynh_send_readme_to_admin() {
- # Declare an array to define the options of this helper.
- declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= )
- local app_message
- local recipients
- local type
- # Manage arguments with getopts
-
- ynh_handle_getopts_args "$@"
- app_message="${app_message:-}"
- recipients="${recipients:-root}"
- type="${type:-install}"
-
- # Get the value of admin_mail_html
- admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
- admin_mail_html="${admin_mail_html:-0}"
-
- # Retrieve the email of users
- find_mails () {
- local list_mails="$1"
- local mail
- local recipients=" "
- # Read each mail in argument
- for mail in $list_mails
- do
- # Keep root or a real email address as it is
- if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
- then
- recipients="$recipients $mail"
- else
- # But replace an user name without a domain after by its email
- if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
- then
- recipients="$recipients $mail"
- fi
- fi
- done
- echo "$recipients"
- }
- recipients=$(find_mails "$recipients")
-
- # Subject base
- local mail_subject="☁️🆈🅽🅷☁️: \`$app\`"
-
- # Adapt the subject according to the type of mail required.
- if [ "$type" = "backup" ]; then
- mail_subject="$mail_subject has just been backup."
- elif [ "$type" = "change_url" ]; then
- mail_subject="$mail_subject has just been moved to a new URL!"
- elif [ "$type" = "remove" ]; then
- mail_subject="$mail_subject has just been removed!"
- elif [ "$type" = "restore" ]; then
- mail_subject="$mail_subject has just been restored!"
- elif [ "$type" = "upgrade" ]; then
- mail_subject="$mail_subject has just been upgraded!"
- else # install
- mail_subject="$mail_subject has just been installed!"
- fi
-
- local mail_message="This is an automated message from your beloved YunoHost server.
-
-Specific information for the application $app.
-
-$(if [ -n "$app_message" ]
-then
- cat "$app_message"
-else
- echo "...No specific information..."
-fi)
-
----
-Automatic diagnosis data from YunoHost
-
-__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__"
-
- # Store the message into a file for further modifications.
- echo "$mail_message" > mail_to_send
-
- # If a html email is required. Apply html tags to the message.
- if [ "$admin_mail_html" -eq 1 ]
- then
- # Insert 'br' tags at each ending of lines.
- ynh_replace_string "$" "
" mail_to_send
-
- # Insert starting HTML tags
- sed --in-place '1s@^@\n\n
" mail_to_send - ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send - - # Insert finishing HTML tags - echo -e "\n\n" >> mail_to_send - - # Otherwise, remove tags to keep a plain text. - else - # Remove URL tags - ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send - ynh_replace_string "__URL_TAG2__" ": " mail_to_send - - # Remove PRE tags - ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send - fi - - # Define binary to use for mail command - if [ -e /usr/bin/bsd-mailx ] - then - local mail_bin=/usr/bin/bsd-mailx - else - local mail_bin=/usr/bin/mail.mailutils - fi - - if [ "$admin_mail_html" -eq 1 ] - then - content_type="text/html" - else - content_type="text/plain" - fi - - # Send the email to the recipients - cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients" -} - #================================================= - -ynh_debian_release () { - lsb_release --codename --short -} - -is_stretch () { - if [ "$(ynh_debian_release)" == "stretch" ] - then - return 0 - else - return 1 - fi -} - -is_jessie () { - if [ "$(ynh_debian_release)" == "jessie" ] - then - return 0 - else - return 1 - fi -} - +# FUTURE OFFICIAL HELPERS #================================================= - -ynh_maintenance_mode_ON () { - # Load value of $path_url and $domain from the config if their not set - if [ -z $path_url ]; then - path_url=$(ynh_app_setting_get $app path) - fi - if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) - fi - - mkdir -p /var/www/html/ - - # Create an html to serve as maintenance notice - echo " - - - -Your app $app is currently under maintenance! - - - -Your app $app is currently under maintenance!
-This app has been put under maintenance by your administrator at $(date)
-Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.
- - -" > "/var/www/html/maintenance.$app.html" - - # Create a new nginx config file to redirect all access to the app to the maintenance notice instead. - echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice -rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect; -# Use another location, to not be in conflict with the original config file -location ${path_url}_maintenance/ { -alias /var/www/html/ ; - -try_files maintenance.$app.html =503; - -# Include SSOWAT user panel. -include conf.d/yunohost_panel.conf.inc; -}" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - - # The current config file will redirect all requests to the root of the app. - # To keep the full path, we can use the following rewrite rule: - # rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect; - # The difference will be in the $1 at the end, which keep the following queries. - # But, if it works perfectly for a html request, there's an issue with any php files. - # This files are treated as simple files, and will be downloaded by the browser. - # Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was. - - systemctl reload nginx -} - -ynh_maintenance_mode_OFF () { - # Load value of $path_url and $domain from the config if their not set - if [ -z $path_url ]; then - path_url=$(ynh_app_setting_get $app path) - fi - if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) - fi - - # Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app. - echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - systemctl reload nginx - - # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. - sleep 4 - - # Then remove the temporary files used for the maintenance. - rm "/var/www/html/maintenance.$app.html" - rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - - systemctl reload nginx -} - -#================================================= - -# Create a changelog for an app after an upgrade. -# -# The changelog is printed into the file ./changelog for the time of the upgrade. -# -# In order to create a changelog, ynh_app_changelog will get info from /etc/yunohost/apps/$app/status.json -# In order to find the current commit use by the app. -# The remote repository, and the branch. -# The changelog will be only the commits since the current revision. -# -# Because of the need of those info, ynh_app_changelog works only -# with apps that have been installed from a list. -# -# usage: ynh_app_changelog -ynh_app_changelog () { - get_value_from_settings () - { - local value="$1" - # Extract a value from the status.json file of an installed app. - - grep "$value\": \"" /etc/yunohost/apps/$app/status.json | sed "s/.*$value\": \"\([^\"]*\).*/\1/" - } - - local current_revision="$(get_value_from_settings revision)" - local repo="$(get_value_from_settings url)" - local branch="$(get_value_from_settings branch)" - # ynh_app_changelog works only with an app installed from a list. - if [ -z "$current_revision" ] || [ -z "$repo" ] || [ -z "$branch" ] - then - ynh_print_warn "Unable to build the changelog..." - touch changelog - return 0 - fi - - # Fetch the history of the repository, without cloning it - mkdir git_history - (cd git_history - ynh_exec_warn_less git init - 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. - # 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) - # Remove 'Merge pull request' commits - sed -i '/Merge pull request #[[:digit:]]* from/d' changelog - # As well as conflict resolving commits - sed -i '/Merge branch .* into/d' changelog - - # Get the value of admin_mail_html - admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) - admin_mail_html="${admin_mail_html:-0}" - - # If a html email is required. Apply html to the changelog. - if [ "$admin_mail_html" -eq 1 ] - then - sed -in-place "s@\*(\([[:alnum:]]*\)) -> \(.*\)@* __URL_TAG1__\2__URL_TAG2__${repo}/commit/\1__URL_TAG3__@g" changelog - fi -} diff --git a/scripts/actions/public_private b/scripts/actions/public_private index b3a263c..9512c4d 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -67,7 +67,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= ynh_script_progression --message="Reload nginx" -ynh_systemd_action --action=reload --service_name=nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/backup b/scripts/backup index 7e8dd97..9791d68 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -13,10 +14,10 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -# Exit if an error occurs during the execution of the script ynh_clean_setup () { ynh_clean_check_starting } +# Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= diff --git a/scripts/change_url b/scripts/change_url index e95c923..afccee8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_maintenance_mode source /usr/share/yunohost/helpers #================================================= @@ -26,6 +27,9 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Loading installation settings..." --weight=2 +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + port=$(ynh_app_setting_get --app=$app --key=port) #================================================= @@ -37,6 +41,23 @@ path_url=$old_path domain=$old_domain ynh_maintenance_mode_ON +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # 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 + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= @@ -53,18 +74,15 @@ then change_path=1 fi -#================================================= -# MANAGE FAILURE OF THE SCRIPT -#================================================= - -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + #================================================= # MODIFY URL IN NGINX CONF #================================================= @@ -77,7 +95,6 @@ if [ $change_path -eq 1 ] then # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" @@ -95,7 +112,6 @@ then # Delete file checksum for the old conf file location ynh_delete_file_checksum --file="$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi @@ -107,6 +123,8 @@ fi #================================================= ynh_script_progression --message="Updating Jenkins setup..." +ynh_backup_if_checksum_is_different --file="/etc/default/jenkins" + if [ $change_path -eq 1 ] then # Add the path, in case of sub-path installation, into jenkins' boot options @@ -126,20 +144,24 @@ then fi fi -#================================================= -# RESTART JENKINS IN BACKGROUND -#================================================= -ynh_script_progression --message="Restarting Jenkins..." --weight=30 +ynh_store_file_checksum --file="/etc/default/jenkins" -# Wait for Jenkins to be fully started -ynh_systemd_action --action=restart --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="300" +#================================================= +# GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=30 + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="300" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --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 #================================================= # DEACTIVE MAINTENANCE MODE diff --git a/scripts/install b/scripts/install index b04be8c..0c2d1ff 100644 --- a/scripts/install +++ b/scripts/install @@ -1,16 +1,17 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh +source ynh_send_readme_to_admin__2 source /usr/share/yunohost/helpers #================================================= -# MANAGE FAILURE OF THE SCRIPT +# MANAGE SCRIPT FAILURE #================================================= ynh_clean_setup () { @@ -36,7 +37,7 @@ is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME #================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THIS ARGS +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= ynh_script_progression --message="Validating installation parameters..." @@ -53,9 +54,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=3 ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=is_public --value=$is_public -ynh_app_setting_set --app=$app --key=final_path --value=$final_path - ynh_app_setting_set --app=$app --key=overwrite_nginx --value=1 ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 @@ -66,7 +64,7 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= ynh_script_progression --message="Finding an available port..." --weight=2 -# Find a free port +# Find an available port port=$(ynh_find_port --port=8080) ynh_app_setting_set --app=$app --key=port --value=$port @@ -75,7 +73,16 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." --weight=30 -ynh_install_app_dependencies $app_depencencies +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." + +ynh_app_setting_set --app=$app --key=final_path --value=$final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="../conf" #================================================= # NGINX CONFIGURATION @@ -116,13 +123,19 @@ pid_change_port=$! ynh_script_progression --message="Installing Jenkins..." --weight=30 # Download jenkins deb file and install it. -ynh_setup_source --dest_dir="../conf" dpkg --install --force-confnew ../conf/jenkins.deb #================================================= -# SETUP JENKINS +# SETUP APPLICATION #================================================= -ynh_script_progression --message="Configuring Jenkins..." +ynh_script_progression --message="Setuping application..." --weight=30 + +# Set the app as temporarily public for jenkins-cli.jar +ynh_script_progression --message="Configuring SSOwat..." +# Making the app public for curl +ynh_permission_update --permission="main" --add="visitors" +# Reload SSOwat config +yunohost app ssowatconf # Ignore Setup Wizard ynh_replace_string --match_string="\-Djava.awt.headless=true" --replace_string="& -Djenkins.install.runSetupWizard=false" --target_file=/etc/default/jenkins @@ -133,51 +146,29 @@ then sed -i "$ s@--httpPort=\$HTTP_PORT@& --prefix=$path_url@g" /etc/default/jenkins fi -#================================================= -# FORCE PUBLIC ACCESS -#================================================= -ynh_script_progression --message="Forcing public access for the installation..." --weight=5 - -# Jenkins has to be public, at least for jenkins-cli.jar -ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" - -ynh_systemd_action --action=reload --service_name=nginx -yunohost app ssowatconf - -#================================================= -# ADVERTISE SERVICE IN ADMIN PANEL -#================================================= - -yunohost service add $app --log=/var/log/$app/$app.log - -#================================================= -# CHECK JENKINS STARTING -#================================================= -ynh_script_progression --message="Starting Jenkins..." --weight=25 - config_OK=0 timeout=3600 # Add the domain to /etc/hosts, to prevent any dns delay echo "127.0.0.1 $domain #jenkins" | tee -a /etc/hosts # Wait for Jenkins to be fully started -ynh_systemd_action --action=restart --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout" +ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout" # Enable Jenkins CLI Protocol/2 for jenkins-cli # That the only protocol that allow connection without an authenticated user... -ynh_replace_string --match_string="0 " --replace_string="&\n" --target_file=/var/lib/jenkins/config.xml +ynh_replace_string --match_string=" CLI2-connect 0 " --replace_string="&\n" --target_file=$final_path/config.xml # Wait for Jenkins to be fully started -ynh_systemd_action --action=restart --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout" +ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout" ynh_script_progression --message="Installing plugins..." --weight=60 # If the log says that jenkins has started, install the plugins -wget -nv --no-check-certificate https://$domain${path_url%/}/jnlpJars/jenkins-cli.jar -O /var/lib/jenkins/jenkins-cli.jar 2>&1 +wget -nv --no-check-certificate https://$domain${path_url%/}/jnlpJars/jenkins-cli.jar -O $final_path/jenkins-cli.jar 2>&1 for i in `seq 1 $timeout` do # Wait for an update of plugin repositories - if test -e /var/lib/jenkins/updates/default.json; then + if test -e $final_path/updates/default.json; then break; else echo -n "." @@ -185,10 +176,13 @@ do fi done -ynh_replace_string --match_string=" CLI2-connect true " --replace_string="false " --target_file=/var/lib/jenkins/config.xml -ynh_systemd_action --action=restart --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout" +# Remove the public access +ynh_permission_update --permission="main" --remove="visitors" -jenkins_cli="ynh_exec_warn_less java -jar /var/lib/jenkins/jenkins-cli.jar -s http://${domain}:${port}${path_url%/}" +ynh_replace_string --match_string="true " --replace_string="false " --target_file=$final_path/config.xml +ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout" + +jenkins_cli="ynh_exec_warn_less java -jar $final_path/jenkins-cli.jar -s http://${domain}:${port}${path_url%/}" # Install plugins for http authentication and ldap. $jenkins_cli install-plugin reverse-proxy-auth-plugin @@ -217,36 +211,72 @@ $jenkins_cli install-plugin ssh-slaves # SSH Slaves plugin # Install extra comfort plugins # Handle terminal colours. Enhance the readability of the terminal. $jenkins_cli install-plugin ansicolor -# MOnitoring of the local file system. Allow to monitor a directory and trig a job if a file has been modified. +# Monitoring of the local file system. Allow to monitor a directory and trig a job if a file has been modified. $jenkins_cli install-plugin fstrigger # Set global security with ldap -cp ../conf/config.xml /var/lib/jenkins/ -chown jenkins: /var/lib/jenkins/config.xml +cp ../conf/config.xml $final_path/ +chown jenkins: $final_path/config.xml -ynh_script_progression --message="Restarting Jenkins..." --weight=20 +# Clean hosts file +sed -i '/#jenkins/d' /etc/hosts -# Wait for Jenkins to be fully started -ynh_systemd_action --action=restart --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout" +#================================================= +# STORE THE CONFIG FILE CHECKSUM +#================================================= +ynh_script_progression --message="Storing the config file checksum..." + +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum --file="/etc/default/jenkins" +ynh_store_file_checksum --file="$final_path/config.xml" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= +ynh_script_progression --message="Securing files and directories..." + +# Set permissions to app files +chown -R $app:$app $final_path + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description="Extendable continuous integration server" --log="/var/log/$app/$app.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --weight=20 + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="$timeout" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=9 +ynh_script_progression --message="Configuring permissions..." --weight=9 -if [ $is_public -eq 0 ] +# Make app public if necessary +if [ $is_public -eq 1 ] then - # Remove the public access - ynh_app_setting_delete --app=$app --key=unprotected_uris - # /path/github-webhook has to be accessible for github's webhooks - ynh_app_setting_set --app=$app --key=skipped_uris --value="/github-webhook" + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission="main" --add="visitors" fi -#================================================= -# CLEAN HOSTS FILE -#================================================= +# /path/github-webhook has to be accessible for github's webhooks +ynh_permission_create --permission="github-webhook" --url "/github-webhook" --allowed="visitors" --show_tile="false" --protected="true" -sed -i '/#jenkins/d' /etc/hosts +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." + +ynh_systemd_action --service_name=nginx --action=reload #================================================= # SEND A README FOR THE ADMIN diff --git a/scripts/remove b/scripts/remove index b903e05..4e9d00b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -17,11 +17,12 @@ ynh_script_progression --message="Loading installation settings..." --weight=4 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE #================================================= -# REMOVE SERVICE FROM ADMIN PANEL +# REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) @@ -31,24 +32,51 @@ then yunohost service remove $app fi +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped LSB" --log_path="systemd" + #================================================= # REMOVE DEPENDENCIES #================================================= ynh_script_progression --message="Removing dependencies..." --weight=20 -ynh_apt purge jenkins # Remove metapackage and its dependencies +ynh_package_autopurge $app ynh_remove_app_dependencies -ynh_secure_remove --file="/var/lib/jenkins" #================================================= -# REMOVE THE NGINX CONFIGURATION +# REMOVE APP MAIN DIR +#================================================= +ynh_script_progression --message="Removing app main directory..." + +# Remove the app directory securely +ynh_secure_remove --file="$final_path" + +#================================================= +# REMOVE NGINX CONFIGURATION #================================================= ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2 # Remove the dedicated NGINX config ynh_remove_nginx_config +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE VARIOUS FILES +#================================================= +ynh_script_progression --message="Removing various files..." + +# Remove a directory securely +ynh_secure_remove --file="/etc/default/jenkins" + +# Remove the log files +ynh_secure_remove --file="/var/log/$app" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 172e2e1..44229ee 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,10 @@ # IMPORT GENERIC HELPERS #================================================= +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh +source ../settings/scripts/ynh_maintenance_mode +source ../settings/scripts/ynh_send_readme_to_admin__2 source /usr/share/yunohost/helpers #================================================= @@ -52,21 +55,23 @@ ynh_script_progression --message="Activating maintenance mode..." --weight=2 ynh_maintenance_mode_ON #================================================= -# STANDARD RESTORE STEPS +# STANDARD RESTORATION STEPS #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# SPECIFIC RESTORE +# SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=20 -ynh_install_app_dependencies $app_depencencies +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies #================================================= # FIX THE PORT TO USE @@ -115,18 +120,18 @@ ynh_secure_remove --file="/etc/default/jenkins" ynh_restore_file --origin_path=/etc/default/$app #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add $app --log="/var/log/$app/$app.log" +yunohost service add $app --description="Extendable continuous integration server" --log="/var/log/$app/$app.log" #================================================= -# CHECK JENKINS STARTING +# START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Restarting Jenkins..." --weight=20 +ynh_script_progression --message="Starting a systemd service..." --weight=20 -# Wait for Jenkins to be fully started -ynh_systemd_action --action=restart --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600" +ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600" #================================================= # DEACTIVE MAINTENANCE MODE @@ -149,6 +154,15 @@ If you're facing an issue or want to improve this app, please open a new issue i ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=restore +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." + +ynh_systemd_action --service_name=nginx --action=reload + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index afba219..e5f8739 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,12 +1,14 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh +source ynh_maintenance_mode +source ynh_send_readme_to_admin__2 source /usr/share/yunohost/helpers #================================================= @@ -18,13 +20,14 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) overwrite_nginx=$(ynh_app_setting_get --app=$app --key=overwrite_nginx) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -59,6 +62,18 @@ then apt-get update fi +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + +# Create a permission if needed +if ! ynh_permission_exists --permission="github-webhook"; then + ynh_permission_create --permission="github-webhook" --url "/github-webhook" --allowed="visitors" --show_tile="false" --protected="true" +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -81,13 +96,25 @@ ynh_script_progression --message="Activating maintenance mode..." --weight=2 ynh_maintenance_mode_ON +ynh_backup_if_checksum_is_different --file="/etc/default/jenkins" +ynh_backup_if_checksum_is_different --file="$final_path/config.xml" + #================================================= -# UPGRADE JENKINS +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped LSB" --log_path="systemd" + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading Jenkins..." --weight=40 + ynh_script_progression --message="Upgrading source files..." --weight=40 # Download jenkins deb file and install it. ynh_setup_source --dest_dir="../conf" dpkg --install --force-confnew ../conf/jenkins.deb @@ -106,13 +133,6 @@ then fi fi -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=12 - -ynh_install_app_dependencies $app_depencencies - #================================================= # NGINX CONFIGURATION #================================================= @@ -127,23 +147,20 @@ then fi #================================================= -# SETUP SSOWAT +# UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." +ynh_script_progression --message="Upgrading dependencies..." --weight=12 -if [ $is_public -eq 1 ] -then - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -else - ynh_app_setting_delete --app=$app --key=unprotected_uris -fi +ynh_install_app_dependencies $pkg_dependencies +#================================================= +# SPECIFIC UPGRADE #================================================= # RELOAD NGINX #================================================= 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 JENKINS STARTING @@ -151,7 +168,7 @@ ynh_systemd_action --action=reload --service_name=nginx ynh_script_progression --message="Restarting Jenkins..." --weight=25 # Wait for Jenkins to be fully started -ynh_systemd_action --action=restart --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600" +ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600" #================================================= # DEACTIVE MAINTENANCE MODE @@ -161,38 +178,60 @@ ynh_script_progression --message="Disabling maintenance mode..." --weight=6 ynh_maintenance_mode_OFF #================================================= -# UPGRADE JENKINS-CLI.PHAR +# UPGRADE JENKINS-CLI.JAR #================================================= -ynh_script_progression --message="Upgrading jenkins-cli.phar..." +ynh_script_progression --message="Upgrading jenkins-cli.jar..." -wget -nv --no-check-certificate https://$domain${path_url%/}/jnlpJars/jenkins-cli.jar -O /var/lib/jenkins/jenkins-cli.jar 2>&1 +wget -nv --no-check-certificate https://127.0.0.1${path_url%/}/jnlpJars/jenkins-cli.jar -O $final_path/jenkins-cli.jar.temp 2>&1 +mv -f $final_path/jenkins-cli.jar.temp $final_path/jenkins-cli.jar #================================================= # UPGRADE PLUGINS #================================================= ynh_script_progression --message="Upgrading plugins..." --weight=40 -cp /var/lib/jenkins/config.xml /var/lib/jenkins/config.xml.bak +cp $final_path/config.xml $final_path/config.xml.bak -ynh_replace_string --match_string="true " --replace_string="false " --target_file=/var/lib/jenkins/config.xml -ynh_systemd_action --action=restart --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600" +ynh_replace_string --match_string="true " --replace_string="false " --target_file=$final_path/config.xml +ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600" -jenkins_cli="ynh_exec_warn_less java -jar /var/lib/jenkins/jenkins-cli.jar -s http://${domain}:${port}${path_url%/}" -UPDATE_LIST=$($jenkins_cli list-plugins | grep -e ')$' | awk '{ print $1 }' ) +jenkins_cli="ynh_exec_warn_less java -jar $final_path/jenkins-cli.jar -s http://127.0.0.1:${port}${path_url%/}" +UPDATE_LIST=$($jenkins_cli list-plugins | grep -oP '^(.*?) ') for plugin in ${UPDATE_LIST} do $jenkins_cli install-plugin "$plugin" || true done -mv /var/lib/jenkins/config.xml.bak /var/lib/jenkins/config.xml -ynh_systemd_action --action=restart --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" --timeout="3600" +mv $final_path/config.xml.bak $final_path/config.xml + +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum --file="/etc/default/jenkins" +ynh_store_file_checksum --file="$final_path/config.xml" #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# GENERIC FINALIZATION #================================================= +# SECURE FILES AND DIRECTORIES +#================================================= +ynh_script_progression --message="Securing files and directories..." -yunohost service add $app --log=/var/log/$app/$app.log +# Set permissions on app files +chown -R $app:$app $final_path + +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." + +yunohost service add $app --description="Extendable continuous integration server" --log="/var/log/$app/$app.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins is fully up and running" --log_path="/var/log/$app/$app.log" #================================================= # SEND A README FOR THE ADMIN @@ -201,21 +240,20 @@ yunohost service add $app --log=/var/log/$app/$app.log # Get main domain and buid the url of the admin panel of the app. admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" -# Build the changelog -ynh_app_changelog || true - echo "You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__. You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__. -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/jenkins_ynh__URL_TAG3__. - ---- - -Changelog since your last upgrade: -$(cat changelog)" > 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/jenkins_ynh__URL_TAG3__." > mail_to_send ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=upgrade +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading NGINX web server..." + +ynh_systemd_action --service_name=nginx --action=reload + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/ynh_maintenance_mode b/scripts/ynh_maintenance_mode new file mode 100644 index 0000000..501b7c1 --- /dev/null +++ b/scripts/ynh_maintenance_mode @@ -0,0 +1,80 @@ +#!/bin/bash + +ynh_maintenance_mode_ON () { + # Load value of $path_url and $domain from the config if their not set + if [ -z $path_url ]; then + path_url=$(ynh_app_setting_get $app path) + fi + if [ -z $domain ]; then + domain=$(ynh_app_setting_get $app domain) + fi + + mkdir -p /var/www/html/ + + # Create an html to serve as maintenance notice + echo " + + + +Your app $app is currently under maintenance! + + + +Your app $app is currently under maintenance!
+This app has been put under maintenance by your administrator at $(date)
+Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.
+ + +" > "/var/www/html/maintenance.$app.html" + + # Create a new nginx config file to redirect all access to the app to the maintenance notice instead. + echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice +rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect; +# Use another location, to not be in conflict with the original config file +location ${path_url}_maintenance/ { +alias /var/www/html/ ; + +try_files maintenance.$app.html =503; + +# Include SSOWAT user panel. +include conf.d/yunohost_panel.conf.inc; +}" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" + + # The current config file will redirect all requests to the root of the app. + # To keep the full path, we can use the following rewrite rule: + # rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect; + # The difference will be in the $1 at the end, which keep the following queries. + # But, if it works perfectly for a html request, there's an issue with any php files. + # This files are treated as simple files, and will be downloaded by the browser. + # Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was. + + systemctl reload nginx +} + +ynh_maintenance_mode_OFF () { + # Load value of $path_url and $domain from the config if their not set + if [ -z $path_url ]; then + path_url=$(ynh_app_setting_get $app path) + fi + if [ -z $domain ]; then + domain=$(ynh_app_setting_get $app domain) + fi + + # Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app. + echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" + systemctl reload nginx + + # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. + sleep 4 + + # Then remove the temporary files used for the maintenance. + rm "/var/www/html/maintenance.$app.html" + rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" + + systemctl reload nginx +} diff --git a/scripts/ynh_send_readme_to_admin__2 b/scripts/ynh_send_readme_to_admin__2 new file mode 100644 index 0000000..06cff8c --- /dev/null +++ b/scripts/ynh_send_readme_to_admin__2 @@ -0,0 +1,140 @@ +#!/bin/bash + +# Send an email to inform the administrator +# +# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type] +# | arg: -m --app_message= - The file with the content to send to the administrator. +# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root +# example: "root admin@domain" +# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you +# example: "root admin@domain user1 user2" +# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade' +ynh_send_readme_to_admin() { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= ) + local app_message + local recipients + local type + # Manage arguments with getopts + + ynh_handle_getopts_args "$@" + app_message="${app_message:-}" + recipients="${recipients:-root}" + type="${type:-install}" + + # Get the value of admin_mail_html + admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) + admin_mail_html="${admin_mail_html:-0}" + + # Retrieve the email of users + find_mails () { + local list_mails="$1" + local mail + local recipients=" " + # Read each mail in argument + for mail in $list_mails + do + # Keep root or a real email address as it is + if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" + then + recipients="$recipients $mail" + else + # But replace an user name without a domain after by its email + if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) + then + recipients="$recipients $mail" + fi + fi + done + echo "$recipients" + } + recipients=$(find_mails "$recipients") + + # Subject base + local mail_subject="☁️🆈🅽🅷☁️: \`$app\`" + + # Adapt the subject according to the type of mail required. + if [ "$type" = "backup" ]; then + mail_subject="$mail_subject has just been backup." + elif [ "$type" = "change_url" ]; then + mail_subject="$mail_subject has just been moved to a new URL!" + elif [ "$type" = "remove" ]; then + mail_subject="$mail_subject has just been removed!" + elif [ "$type" = "restore" ]; then + mail_subject="$mail_subject has just been restored!" + elif [ "$type" = "upgrade" ]; then + mail_subject="$mail_subject has just been upgraded!" + else # install + mail_subject="$mail_subject has just been installed!" + fi + + local mail_message="This is an automated message from your beloved YunoHost server. + +Specific information for the application $app. + +$(if [ -n "$app_message" ] +then + cat "$app_message" +else + echo "...No specific information..." +fi) + +--- +Automatic diagnosis data from YunoHost + +__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__" + + # Store the message into a file for further modifications. + echo "$mail_message" > mail_to_send + + # If a html email is required. Apply html tags to the message. + if [ "$admin_mail_html" -eq 1 ] + then + # Insert 'br' tags at each ending of lines. + ynh_replace_string "$" "
" mail_to_send + + # Insert starting HTML tags + sed --in-place '1s@^@\n\n\n\n@' mail_to_send + + # Keep tabulations + ynh_replace_string " " "\ \ " mail_to_send + ynh_replace_string "\t" "\ \ " mail_to_send + + # Insert url links tags + ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "\1" mail_to_send + + # Insert pre tags + ynh_replace_string "__PRE_TAG1__" "" mail_to_send + ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send + + # Insert finishing HTML tags + echo -e "\n\n" >> mail_to_send + + # Otherwise, remove tags to keep a plain text. + else + # Remove URL tags + ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send + ynh_replace_string "__URL_TAG2__" ": " mail_to_send + + # Remove PRE tags + ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send + fi + + # Define binary to use for mail command + if [ -e /usr/bin/bsd-mailx ] + then + local mail_bin=/usr/bin/bsd-mailx + else + local mail_bin=/usr/bin/mail.mailutils + fi + + if [ "$admin_mail_html" -eq 1 ] + then + content_type="text/html" + else + content_type="text/plain" + fi + + # Send the email to the recipients + cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients" +}