From 7ffedc7ddb4e7f13115da384acc88d04c7df48e1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 25 Feb 2021 23:05:04 +0100 Subject: [PATCH 01/11] Apply last example_ynh --- README.md | 23 +- README_fr.md | 28 +- check_process | 6 +- conf/nginx.conf | 38 +-- manifest.json | 122 ++++----- scripts/_common.sh | 401 +--------------------------- scripts/backup | 3 +- scripts/change_url | 62 +++-- scripts/install | 132 +++++---- scripts/remove | 23 +- scripts/restore | 39 ++- scripts/upgrade | 88 ++++-- scripts/ynh_app_changelog__2 | 137 ++++++++++ scripts/ynh_maintenance_mode | 80 ++++++ scripts/ynh_send_readme_to_admin__2 | 140 ++++++++++ 15 files changed, 710 insertions(+), 612 deletions(-) create mode 100644 scripts/ynh_app_changelog__2 create mode 100644 scripts/ynh_maintenance_mode create mode 100644 scripts/ynh_send_readme_to_admin__2 diff --git a/README.md b/README.md index 9dbba40..e10b738 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ *[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. @@ -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..1158163 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.1 ## 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/check_process b/check_process index ff22049..14a2ff8 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 @@ -24,3 +26,5 @@ Notification=down ; commit=29141b702f2954e0f72925121aea82a7fa3fc118 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/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\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"
-}
-
 #=================================================
-
-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/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..0be9fd4 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,28 +146,6 @@ 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 @@ -185,6 +176,9 @@ do fi done +# Remove the public access +ynh_permission_update --permission="main" --remove="visitors" + 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="$timeout" @@ -217,36 +211,80 @@ $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 -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="/var/lib/jenkins/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 + +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Configuring log rotation..." + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate + +#================================================= +# 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..667be17 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,7 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -21,7 +21,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # 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`) @@ -39,16 +39,31 @@ ynh_script_progression --message="Removing dependencies..." --weight=20 ynh_apt purge jenkins # Remove metapackage and its dependencies 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 +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." + +# Remove the app-specific logrotate config +ynh_remove_logrotate + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 172e2e1..9bf6d2f 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,22 @@ 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 +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + +#================================================= +# 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..2d93d7b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,12 +1,15 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh +source ynh_app_changelog__2 +source ynh_maintenance_mode +source ynh_send_readme_to_admin__2 source /usr/share/yunohost/helpers #================================================= @@ -18,13 +21,13 @@ 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) 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,16 @@ 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="/var/lib/jenkins/config.xml" + #================================================= -# UPGRADE JENKINS +# 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 +124,6 @@ then fi fi -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=12 - -ynh_install_app_dependencies $app_depencencies - #================================================= # NGINX CONFIGURATION #================================================= @@ -127,17 +138,14 @@ 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 #================================================= @@ -186,13 +194,42 @@ do 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" + +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum --file="/etc/default/jenkins" +ynh_store_file_checksum --file="/var/lib/jenkins/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 + +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + +#================================================= +# 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 @@ -216,6 +253,13 @@ $(cat changelog)" > 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_app_changelog__2 b/scripts/ynh_app_changelog__2 new file mode 100644 index 0000000..12b1815 --- /dev/null +++ b/scripts/ynh_app_changelog__2 @@ -0,0 +1,137 @@ +#!/bin/bash + +# Create a changelog for an app after an upgrade from the file CHANGELOG.md. +# +# 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) +# +# The changelog is printed into the file ./changelog and ./changelog_lite +ynh_app_changelog () { + # Declare an array to define the options of this helper. + local legacy_args=foc + declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= ) + local format + local output + local changelog + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + format=${format:-markdown} + output=${output:-changelog} + changelog=${changelog:-../CHANGELOG.md} + + local original_changelog="$changelog" + local temp_changelog="changelog_temp" + local final_changelog="$output" + + if [ ! -n "$original_changelog" ] + then + echo "No changelog available..." > "$final_changelog" + echo "No changelog available..." > "${final_changelog}_lite" + return 0 + fi + + local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version") + local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version") + + # Get the line of the version to update to into the changelog + 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 + + # Get the length of the complete changelog. + 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="\1)" --target_file="$final_changelog" + ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="\1" --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 +} 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"
+}

From 380cfdef948be7383cbb889ccbc26d37b9502776 Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Fri, 26 Feb 2021 21:20:24 +0100
Subject: [PATCH 02/11] removing logrotate stuff

---
 scripts/install | 8 --------
 scripts/remove  | 8 --------
 scripts/restore | 7 -------
 scripts/upgrade | 8 --------
 4 files changed, 31 deletions(-)

diff --git a/scripts/install b/scripts/install
index 0be9fd4..d9c3bf3 100644
--- a/scripts/install
+++ b/scripts/install
@@ -240,14 +240,6 @@ ynh_script_progression --message="Securing files and directories..."
 # Set permissions to app files
 chown -R $app:$app $final_path
 
-#=================================================
-# SETUP LOGROTATE
-#=================================================
-ynh_script_progression --message="Configuring log rotation..."
-
-# Use logrotate to manage application logfile(s)
-ynh_use_logrotate
-
 #=================================================
 # INTEGRATE SERVICE IN YUNOHOST
 #=================================================
diff --git a/scripts/remove b/scripts/remove
index 667be17..bf6e657 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -56,14 +56,6 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
 # Remove the dedicated NGINX config
 ynh_remove_nginx_config
 
-#=================================================
-# REMOVE LOGROTATE CONFIGURATION
-#=================================================
-ynh_script_progression --message="Removing logrotate configuration..."
-
-# Remove the app-specific logrotate config
-ynh_remove_logrotate
-
 #=================================================
 # END OF SCRIPT
 #=================================================
diff --git a/scripts/restore b/scripts/restore
index 9bf6d2f..44229ee 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -154,13 +154,6 @@ 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
 
-#=================================================
-# RESTORE THE LOGROTATE CONFIGURATION
-#=================================================
-ynh_script_progression --message="Restoring the logrotate configuration..."
-
-ynh_restore_file --origin_path="/etc/logrotate.d/$app"
-
 #=================================================
 # GENERIC FINALIZATION
 #=================================================
diff --git a/scripts/upgrade b/scripts/upgrade
index 2d93d7b..6bac693 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -209,14 +209,6 @@ ynh_script_progression --message="Securing files and directories..."
 # Set permissions on app files
 chown -R $app:$app $final_path
 
-#=================================================
-# SETUP LOGROTATE
-#=================================================
-ynh_script_progression --message="Upgrading logrotate configuration..."
-
-# Use logrotate to manage app-specific logfile(s)
-ynh_use_logrotate --non-append
-
 #=================================================
 # INTEGRATE SERVICE IN YUNOHOST
 #=================================================

From 45f9dbdb8ffb0fcf16d449cbe7c45ba8b3e0ab8b Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Sun, 28 Feb 2021 23:28:38 +0100
Subject: [PATCH 03/11] Fix upgrade

---
 scripts/upgrade | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/upgrade b/scripts/upgrade
index afba219..6e514c4 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -177,7 +177,7 @@ cp /var/lib/jenkins/config.xml /var/lib/jenkins/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"
 
-jenkins_cli="ynh_exec_warn_less java -jar /var/lib/jenkins/jenkins-cli.jar -s http://${domain}:${port}${path_url%/}"
+jenkins_cli="ynh_exec_warn_less java -jar /var/lib/jenkins/jenkins-cli.jar -s http://127.0.0.1:${port}${path_url%/}"
 UPDATE_LIST=$($jenkins_cli list-plugins | grep -e ')$' | awk '{ print $1 }' )
 
 for plugin in ${UPDATE_LIST}

From a1c6dbc249e944dba70aef513914f55ed01fb191 Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Mon, 1 Mar 2021 21:50:33 +0100
Subject: [PATCH 04/11] Fixing ynh_systemd_action

---
 scripts/actions/public_private | 2 +-
 scripts/install                | 6 +++---
 scripts/upgrade                | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

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/install b/scripts/install
index d9c3bf3..b1233d4 100644
--- a/scripts/install
+++ b/scripts/install
@@ -152,14 +152,14 @@ timeout=3600
 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="&\nCLI2-connect" --target_file=/var/lib/jenkins/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
 
@@ -180,7 +180,7 @@ done
 ynh_permission_update --permission="main" --remove="visitors"
 
 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="$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"
 
 jenkins_cli="ynh_exec_warn_less java -jar /var/lib/jenkins/jenkins-cli.jar -s http://${domain}:${port}${path_url%/}"
 
diff --git a/scripts/upgrade b/scripts/upgrade
index 6bac693..c71e9ca 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -151,7 +151,7 @@ ynh_install_app_dependencies $pkg_dependencies
 #=================================================
 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
@@ -159,7 +159,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
@@ -183,7 +183,7 @@ ynh_script_progression --message="Upgrading plugins..." --weight=40
 cp /var/lib/jenkins/config.xml /var/lib/jenkins/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_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 }' )

From 92e27cac55a8c73e5f9de38552217ed4f2016fa8 Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Mon, 1 Mar 2021 22:09:37 +0100
Subject: [PATCH 05/11] fix service stop

---
 scripts/remove  | 7 +++++++
 scripts/upgrade | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/scripts/remove b/scripts/remove
index bf6e657..2a7695b 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -31,6 +31,13 @@ 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
 #=================================================
diff --git a/scripts/upgrade b/scripts/upgrade
index c71e9ca..bf75020 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -99,6 +99,15 @@ ynh_maintenance_mode_ON
 ynh_backup_if_checksum_is_different --file="/etc/default/jenkins"
 ynh_backup_if_checksum_is_different --file="/var/lib/jenkins/config.xml"
 
+#=================================================
+# 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
 #=================================================

From 2018a4f761672d90a26005d586724a93f0cbfdf9 Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Wed, 3 Mar 2021 20:50:33 +0100
Subject: [PATCH 06/11] fix remove

---
 scripts/remove | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/remove b/scripts/remove
index 2a7695b..aaa3603 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -17,6 +17,7 @@ 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
@@ -43,7 +44,7 @@ ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped LSB
 #=================================================
 ynh_script_progression --message="Removing dependencies..." --weight=20
 
-ynh_apt purge jenkins
+ynh_package_autopurge $app
 # Remove metapackage and its dependencies
 ynh_remove_app_dependencies
 

From 6b01348b0d49138162650634568490c1e2d0dcb5 Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Thu, 4 Mar 2021 00:33:28 +0100
Subject: [PATCH 07/11] Fix upgrade

---
 scripts/upgrade              |  14 +---
 scripts/ynh_app_changelog__2 | 137 -----------------------------------
 2 files changed, 3 insertions(+), 148 deletions(-)
 delete mode 100644 scripts/ynh_app_changelog__2

diff --git a/scripts/upgrade b/scripts/upgrade
index e5361a0..91bf8c5 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -7,7 +7,6 @@
 #=================================================
 
 source _common.sh
-source ynh_app_changelog__2
 source ynh_maintenance_mode
 source ynh_send_readme_to_admin__2
 source /usr/share/yunohost/helpers
@@ -21,6 +20,7 @@ app=$YNH_APP_INSTANCE_NAME
 
 domain=$(ynh_app_setting_get --app=$app --key=domain)
 path_url=$(ynh_app_setting_get --app=$app --key=path)
+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)
 
@@ -195,7 +195,7 @@ ynh_replace_string --match_string="true" --replace_st
 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://127.0.0.1:${port}${path_url%/}"
-UPDATE_LIST=$($jenkins_cli list-plugins | grep -e ')$' | awk '{ print $1 }' )
+UPDATE_LIST=$($jenkins_cli list-plugins | grep -oP '^(.*?) ')
 
 for plugin in ${UPDATE_LIST}
 do
@@ -239,18 +239,10 @@ ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins
 # 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
 
diff --git a/scripts/ynh_app_changelog__2 b/scripts/ynh_app_changelog__2
deleted file mode 100644
index 12b1815..0000000
--- a/scripts/ynh_app_changelog__2
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/bin/bash
-
-# Create a changelog for an app after an upgrade from the file CHANGELOG.md.
-#
-# 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)
-#
-# The changelog is printed into the file ./changelog and ./changelog_lite
-ynh_app_changelog () {
-    # Declare an array to define the options of this helper.
-    local legacy_args=foc
-    declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= )
-    local format
-    local output
-    local changelog
-    # Manage arguments with getopts
-    ynh_handle_getopts_args "$@"
-    format=${format:-markdown}
-    output=${output:-changelog}
-    changelog=${changelog:-../CHANGELOG.md}
-
-    local original_changelog="$changelog"
-    local temp_changelog="changelog_temp"
-    local final_changelog="$output"
-
-    if [ ! -n "$original_changelog" ]
-    then
-        echo "No changelog available..." > "$final_changelog"
-        echo "No changelog available..." > "${final_changelog}_lite"
-        return 0
-    fi
-
-    local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
-    local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version")
-
-    # Get the line of the version to update to into the changelog
-    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
-
-    # Get the length of the complete changelog.
-    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="\1)" --target_file="$final_changelog"
-        ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="\1" --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
-}

From b014e08e4f2c9a585ea07606d2a1498394070668 Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Thu, 4 Mar 2021 00:37:08 +0100
Subject: [PATCH 08/11] Fix removal

---
 scripts/remove | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/scripts/remove b/scripts/remove
index aaa3603..4e9d00b 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -44,8 +44,8 @@ ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped LSB
 #=================================================
 ynh_script_progression --message="Removing dependencies..." --weight=20
 
-ynh_package_autopurge $app
 # Remove metapackage and its dependencies
+ynh_package_autopurge $app
 ynh_remove_app_dependencies
 
 #=================================================
@@ -64,6 +64,19 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
 # 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
 #=================================================

From 886fd97748cb44a4fce626884829b0c680c8c062 Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Thu, 4 Mar 2021 01:07:55 +0100
Subject: [PATCH 09/11] switch /var/lib/jenkin

---
 scripts/install | 16 ++++++++--------
 scripts/upgrade | 14 +++++++-------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/scripts/install b/scripts/install
index b1233d4..0c2d1ff 100644
--- a/scripts/install
+++ b/scripts/install
@@ -156,7 +156,7 @@ ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins
 
 # 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="&\nCLI2-connect" --target_file=/var/lib/jenkins/config.xml
+ynh_replace_string --match_string="0" --replace_string="&\nCLI2-connect" --target_file=$final_path/config.xml
 
 # Wait for Jenkins to be fully started
 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"
@@ -164,11 +164,11 @@ ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins
 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 "."
@@ -179,10 +179,10 @@ done
 # Remove the public access
 ynh_permission_update --permission="main" --remove="visitors"
 
-ynh_replace_string --match_string="true" --replace_string="false" --target_file=/var/lib/jenkins/config.xml
+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 /var/lib/jenkins/jenkins-cli.jar -s http://${domain}:${port}${path_url%/}"
+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
@@ -215,8 +215,8 @@ $jenkins_cli install-plugin ansicolor
 $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
 
 # Clean hosts file
 sed -i '/#jenkins/d' /etc/hosts
@@ -228,7 +228,7 @@ 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="/var/lib/jenkins/config.xml"
+ynh_store_file_checksum --file="$final_path/config.xml"
 
 #=================================================
 # GENERIC FINALIZATION
diff --git a/scripts/upgrade b/scripts/upgrade
index 91bf8c5..f9e52a8 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -97,7 +97,7 @@ 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="/var/lib/jenkins/config.xml"
+ynh_backup_if_checksum_is_different --file="$final_path/config.xml"
 
 #=================================================
 # STANDARD UPGRADE STEPS
@@ -182,19 +182,19 @@ ynh_maintenance_mode_OFF
 #=================================================
 ynh_script_progression --message="Upgrading jenkins-cli.phar..."
 
-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
 
 #=================================================
 # 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_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://127.0.0.1:${port}${path_url%/}"
+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}
@@ -202,11 +202,11 @@ do
 	$jenkins_cli install-plugin "$plugin" || true
 done
 
-mv /var/lib/jenkins/config.xml.bak /var/lib/jenkins/config.xml
+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="/var/lib/jenkins/config.xml"
+ynh_store_file_checksum --file="$final_path/config.xml"
 
 #=================================================
 # GENERIC FINALIZATION

From a84cfec269a39bc3b26a8cd751165252a96f14e8 Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Thu, 4 Mar 2021 01:08:00 +0100
Subject: [PATCH 10/11] Delete YEP.md

---
 YEP.md | 117 ---------------------------------------------------------
 1 file changed, 117 deletions(-)
 delete mode 100644 YEP.md

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`.

From bd0be1c290705dea1a8e0b79012e3330eb697d0d Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Thu, 4 Mar 2021 15:15:48 +0100
Subject: [PATCH 11/11] Update upgrade

---
 scripts/upgrade | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/upgrade b/scripts/upgrade
index f9e52a8..e712271 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -182,7 +182,7 @@ ynh_maintenance_mode_OFF
 #=================================================
 ynh_script_progression --message="Upgrading jenkins-cli.phar..."
 
-wget -nv --no-check-certificate https://$domain${path_url%/}/jnlpJars/jenkins-cli.jar -O $final_path/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 2>&1
 
 #=================================================
 # UPGRADE PLUGINS