From 809e43191439d3bccd68c644f1a3387955408eb4 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 00:27:48 +0200 Subject: [PATCH 1/3] Apply example_ynh --- README.md | 4 ++-- README_fr.md | 4 ++-- manifest.json | 6 +----- scripts/change_url | 2 +- scripts/restore | 4 ++-- scripts/upgrade | 4 ++-- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e768edc..9236203 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,8 @@ Supported, with LDAP and SSO. #### Supported architectures -* 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/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/jenkins.svg)](https://ci-apps.yunohost.org/ci/apps/jenkins/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jenkins.svg)](https://ci-apps-arm.yunohost.org/ci/apps/jenkins/) ## Links diff --git a/README_fr.md b/README_fr.md index e9213b5..9a5dbed 100644 --- a/README_fr.md +++ b/README_fr.md @@ -38,8 +38,8 @@ Supportée, avec LDAP et SSO. #### Architectures supportées -* 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/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/jenkins.svg)](https://ci-apps.yunohost.org/ci/apps/jenkins/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/jenkins.svg)](https://ci-apps-arm.yunohost.org/ci/apps/jenkins/) ## Liens diff --git a/manifest.json b/manifest.json index 4150d5a..2dfe768 100644 --- a/manifest.json +++ b/manifest.json @@ -40,11 +40,7 @@ { "name": "is_public", "type": "boolean", - "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." - } + "default": true } ] } diff --git a/scripts/change_url b/scripts/change_url index afccee8..a5f2762 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -42,7 +42,7 @@ domain=$old_domain ynh_maintenance_mode_ON #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." diff --git a/scripts/restore b/scripts/restore index 44229ee..f3e1c69 100644 --- a/scripts/restore +++ b/scripts/restore @@ -28,7 +28,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=2 +ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME @@ -59,7 +59,7 @@ ynh_maintenance_mode_ON #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the nginx configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" diff --git a/scripts/upgrade b/scripts/upgrade index 902553d..a8405e0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -66,7 +66,7 @@ if ! ynh_permission_exists --permission="github-webhook"; then fi #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=40 @@ -74,7 +74,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take ynh_backup_before_upgrade ynh_clean_setup () { ynh_clean_check_starting - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script From 753f658fc718790b879acb36c2547d67ffae75f9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 00:35:11 +0200 Subject: [PATCH 2/3] Apply example_ynh --- manifest.json | 2 +- scripts/install | 8 -------- scripts/upgrade | 10 +--------- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/manifest.json b/manifest.json index fccf770..a42dced 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Extendable continuous integration server", "fr": "Serveur d'intégration continue extensible" }, - "version": "2.277.2~ynh1", + "version": "2.277.2~ynh2", "url": "https://jenkins.io/index.html", "license": "MIT", "maintainer": { diff --git a/scripts/install b/scripts/install index 0c2d1ff..aed0713 100644 --- a/scripts/install +++ b/scripts/install @@ -232,14 +232,6 @@ ynh_store_file_checksum --file="$final_path/config.xml" #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions to app files -chown -R $app:$app $final_path - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index a8405e0..a9ca8d1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -66,7 +66,7 @@ if ! ynh_permission_exists --permission="github-webhook"; then fi #================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=40 @@ -202,14 +202,6 @@ ynh_store_file_checksum --file="$final_path/config.xml" #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions on app files -chown -R $app:$app $final_path - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= From fd40a51bcac6bec98588a455736bb34191834d86 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 20:50:48 +0200 Subject: [PATCH 3/3] Apply example_ynh --- check_process | 4 +- scripts/actions/public_private | 4 +- scripts/change_url | 31 ++----------- scripts/install | 24 +++++----- scripts/remove | 10 ++--- scripts/restore | 27 +++--------- scripts/upgrade | 35 +++++---------- scripts/ynh_maintenance_mode | 80 ---------------------------------- 8 files changed, 41 insertions(+), 174 deletions(-) delete mode 100644 scripts/ynh_maintenance_mode diff --git a/check_process b/check_process index 919dfd3..5433158 100644 --- a/check_process +++ b/check_process @@ -12,7 +12,7 @@ setup_public=1 upgrade=1 # 2.150.2~ynh2 - # upgrade=1 from_commit=29141b702f2954e0f72925121aea82a7fa3fc118 + #upgrade=1 from_commit=29141b702f2954e0f72925121aea82a7fa3fc118 # 2.263.1~ynh1 upgrade=1 from_commit=0e1aae7be82034650e2c1f6c1ad6d68a41b80176 # 2.263.4~ynh1 @@ -23,7 +23,7 @@ change_url=1 ;;; Options Email= -Notification=down +Notification=none ;;; Upgrade options ; commit=29141b702f2954e0f72925121aea82a7fa3fc118 name=Fix for getopts 13 Apr 2019 diff --git a/scripts/actions/public_private b/scripts/actions/public_private index 9512c4d..16b1201 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -43,7 +43,7 @@ if [ $is_public -eq 0 ]; then else public_private="public" fi -ynh_script_progression --message="Moving the application to $public_private..." --weight=3 +ynh_script_progression --message="Moving the application to $public_private..." if [ $is_public -eq 0 ] then @@ -73,4 +73,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Execution completed" --last +ynh_script_progression --message="Execution completed" diff --git a/scripts/change_url b/scripts/change_url index a5f2762..7fdab5e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_maintenance_mode source /usr/share/yunohost/helpers #================================================= @@ -25,22 +24,13 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +ynh_script_progression --message="Loading installation settings..." # 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) -#================================================= -# ACTIVATE MAINTENANCE MODE -#================================================= -ynh_script_progression --message="Activating maintenance mode..." --weight=2 - -path_url=$old_path -domain=$old_domain -ynh_maintenance_mode_ON - #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= @@ -86,7 +76,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=5 +ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -98,10 +88,6 @@ then # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - - # Store path_url setting - ynh_app_setting_set --app=$app --key=path_url --value="$path_url" - # Create a dedicated NGINX config ynh_add_nginx_config fi @@ -151,7 +137,7 @@ ynh_store_file_checksum --file="/etc/default/jenkins" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=30 +ynh_script_progression --message="Starting a systemd service..." # 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" @@ -163,17 +149,8 @@ ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload -#================================================= -# DEACTIVE MAINTENANCE MODE -#================================================= -ynh_script_progression --message="Disabling maintenance mode..." --weight=5 - -path_url=$old_path -domain=$old_domain -ynh_maintenance_mode_OFF - #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index aed0713..46cdb9b 100644 --- a/scripts/install +++ b/scripts/install @@ -50,7 +50,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=3 +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url @@ -62,7 +62,7 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." --weight=2 +ynh_script_progression --message="Finding an available port..." # Find an available port port=$(ynh_find_port --port=8080) @@ -71,7 +71,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=30 +ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies @@ -87,7 +87,7 @@ ynh_setup_source --dest_dir="../conf" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=2 +ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config @@ -97,7 +97,7 @@ ynh_add_nginx_config #================================================= # FIX THE PORT TO USE #================================================= -ynh_script_progression --message="Fixing the port in Jenkins config..." --weight=2 +ynh_script_progression --message="Fixing the port in Jenkins config..." change_port() { # Wait for the creation of the jenkins service file @@ -120,7 +120,7 @@ pid_change_port=$! #================================================= # INSTALL JENKINS #================================================= -ynh_script_progression --message="Installing Jenkins..." --weight=30 +ynh_script_progression --message="Installing Jenkins..." # Download jenkins deb file and install it. dpkg --install --force-confnew ../conf/jenkins.deb @@ -128,7 +128,7 @@ dpkg --install --force-confnew ../conf/jenkins.deb #================================================= # SETUP APPLICATION #================================================= -ynh_script_progression --message="Setuping application..." --weight=30 +ynh_script_progression --message="Setuping application..." # Set the app as temporarily public for jenkins-cli.jar ynh_script_progression --message="Configuring SSOwat..." @@ -161,7 +161,7 @@ ynh_replace_string --match_string="0" --replace # 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" -ynh_script_progression --message="Installing plugins..." --weight=60 +ynh_script_progression --message="Installing plugins..." # 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 $final_path/jenkins-cli.jar 2>&1 @@ -242,7 +242,7 @@ yunohost service add $app --description="Extendable continuous integration serve #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=20 +ynh_script_progression --message="Starting a systemd service..." # 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" @@ -250,7 +250,7 @@ ynh_systemd_action --service_name=$app --action="restart" --line_match="Jenkins #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=9 +ynh_script_progression --message="Configuring permissions..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -261,7 +261,7 @@ then fi # /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" +ynh_permission_create --permission="github-webhook" --url="/github-webhook" --allowed="visitors" --show_tile="false" --protected="true" #================================================= # RELOAD NGINX @@ -288,4 +288,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 4e9d00b..f247c70 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=4 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -28,7 +28,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service integration..." --weight=1 + ynh_script_progression --message="Removing $app service integration..." yunohost service remove $app fi @@ -42,7 +42,7 @@ ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped LSB #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=20 +ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_package_autopurge $app @@ -59,7 +59,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2 +ynh_script_progression --message="Removing NGINX web server configuration..." # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -81,4 +81,4 @@ ynh_secure_remove --file="/var/log/$app" # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index f3e1c69..b283384 100644 --- a/scripts/restore +++ b/scripts/restore @@ -8,7 +8,6 @@ # 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 @@ -28,7 +27,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -47,13 +46,6 @@ ynh_webpath_available --domain=$domain --path_url=$path_url \ test ! -d $final_path \ || ynh_die --message="There is already a directory: $final_path " -#================================================= -# ACTIVATE MAINTENANCE MODE -#================================================= -ynh_script_progression --message="Activating maintenance mode..." --weight=2 - -ynh_maintenance_mode_ON - #================================================= # STANDARD RESTORATION STEPS #================================================= @@ -68,7 +60,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=20 +ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies @@ -99,7 +91,7 @@ pid_change_port=$! #================================================= # INSTALL JENKINS #================================================= -ynh_script_progression --message="Installing Jenkins..." --weight=25 +ynh_script_progression --message="Installing Jenkins..." # Download jenkins deb file and install it. ynh_setup_source --dest_dir="../conf" @@ -108,7 +100,7 @@ dpkg --install --force-confnew ../conf/jenkins.deb #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=4 +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" @@ -129,17 +121,10 @@ yunohost service add $app --description="Extendable continuous integration serve #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=20 +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" --timeout="3600" -#================================================= -# DEACTIVE MAINTENANCE MODE -#================================================= -ynh_script_progression --message="Disabling maintenance mode..." - -ynh_maintenance_mode_OFF - #================================================= # SEND A README FOR THE ADMIN #================================================= @@ -167,4 +152,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index a9ca8d1..90405df 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,14 +7,13 @@ #================================================= source _common.sh -source ynh_maintenance_mode source ynh_send_readme_to_admin__2 source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=4 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -34,7 +33,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=2 +ynh_script_progression --message="Ensuring downward compatibility..." # If overwrite_nginx doesn't exist, create it if [ -z "$overwrite_nginx" ]; then @@ -68,7 +67,7 @@ fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=40 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -80,13 +79,6 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# ACTIVATE MAINTENANCE MODE -#================================================= -ynh_script_progression --message="Activating maintenance mode..." --weight=2 - -ynh_maintenance_mode_ON - ynh_backup_if_checksum_is_different --file="/etc/default/jenkins" ynh_backup_if_checksum_is_different --file="$final_path/config.xml" @@ -105,7 +97,7 @@ ynh_systemd_action --service_name=$app --action="stop" --line_match="Stopped LSB if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=40 + ynh_script_progression --message="Upgrading source files..." # Download jenkins deb file and install it. ynh_setup_source --dest_dir="../conf" dpkg --install --force-confnew ../conf/jenkins.deb @@ -131,7 +123,7 @@ fi # Overwrite the nginx configuration only if it's allowed if [ $overwrite_nginx -eq 1 ] then - ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=4 + ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_add_nginx_config @@ -140,7 +132,7 @@ fi #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=12 +ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies @@ -149,25 +141,18 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload #================================================= # CHECK JENKINS STARTING #================================================= -ynh_script_progression --message="Restarting Jenkins..." --weight=25 +ynh_script_progression --message="Restarting Jenkins..." # 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="3600" -#================================================= -# DEACTIVE MAINTENANCE MODE -#================================================= -ynh_script_progression --message="Disabling maintenance mode..." --weight=6 - -ynh_maintenance_mode_OFF - #================================================= # UPGRADE JENKINS-CLI.JAR #================================================= @@ -179,7 +164,7 @@ mv -f $final_path/jenkins-cli.jar.temp $final_path/jenkins-cli.jar #================================================= # UPGRADE PLUGINS #================================================= -ynh_script_progression --message="Upgrading plugins..." --weight=40 +ynh_script_progression --message="Upgrading plugins..." cp $final_path/config.xml $final_path/config.xml.bak @@ -241,4 +226,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of $app completed" diff --git a/scripts/ynh_maintenance_mode b/scripts/ynh_maintenance_mode deleted file mode 100644 index 501b7c1..0000000 --- a/scripts/ynh_maintenance_mode +++ /dev/null @@ -1,80 +0,0 @@ -#!/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 -}