From fe618c5c7091c7207d06446ff92eec8d82272edd Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 20 May 2018 22:19:05 +0200 Subject: [PATCH] Upgrade to 3.3.1 --- README.md | 10 +- README_fr.md | 10 +- conf/app.src | 4 +- manifest.json | 4 +- scripts/_common.sh | 343 +++++++++++++++++++-------------------------- scripts/_sed | 51 ------- scripts/backup | 13 ++ scripts/change_url | 17 ++- scripts/install | 12 ++ scripts/restore | 12 ++ scripts/upgrade | 12 ++ 11 files changed, 228 insertions(+), 260 deletions(-) delete mode 100644 scripts/_sed diff --git a/README.md b/README.md index 2596583..4987545 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Pi-hole for YunoHost -[![Integration level](https://dash.yunohost.org/integration/pihole.svg)](https://ci-apps.yunohost.org/jenkins/job/pihole%20%28Community%29/lastBuild/consoleFull) +[![Integration level](https://dash.yunohost.org/integration/pihole.svg)](https://dash.yunohost.org/appci/app/pihole) [![Install Pi-hole with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=pihole) *[Lire ce readme en français.](./README_fr.md)* @@ -11,12 +11,16 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview Network-wide ad blocking via your own Linux hardware -**Shipped version:** 3.3 +**Shipped version:** 3.3.1 ## Screenshots ![](https://i0.wp.com/pi-hole.net/wp-content/uploads/2016/12/dashboard212.png) +## Demo + +No demo available. + ## Configuration Use the admin panel of your Pi-hole to configure this app. @@ -36,7 +40,7 @@ Use the admin panel of your Pi-hole to configure this app. #### Supported architectures * x86-64b - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/pihole%20(Community)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/pihole%20(Community)/) -* ARMv8-A - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/pihole%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/pihole%20(Community)%20(%7EARM%7E)/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/jenkins/job/pihole%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/pihole%20(Community)%20(%7EARM%7E)/) ## Limitations diff --git a/README_fr.md b/README_fr.md index e0806e1..fd2222c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,6 +1,6 @@ # Pi-hole pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/pihole.svg)](https://ci-apps.yunohost.org/jenkins/job/pihole%20%28Community%29/lastBuild/consoleFull) +[![Niveau d'intégration](https://dash.yunohost.org/integration/pihole.svg)](https://dash.yunohost.org/appci/app/pihole) [![Installer Pi-hole avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=pihole) *[Read this readme in english.](./README.md)* @@ -11,12 +11,16 @@ Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/inst ## Résumé Blocage des publicités sur l'ensemble du réseau via votre propre matériel Linux -**Version embarquée:** 3.3 +**Version embarquée:** 3.3.1 ## Captures d'écran ![](https://i0.wp.com/pi-hole.net/wp-content/uploads/2016/12/dashboard212.png) +## Démo + +Aucune démo pour cette application. + ## Configuration Utiliser le panneau d'administration de votre Pi-hole pour configurer cette application. @@ -36,7 +40,7 @@ Utiliser le panneau d'administration de votre Pi-hole pour configurer cette appl #### Architectures supportées. * x86-64b - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/pihole%20(Community)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/pihole%20(Community)/) -* ARMv8-A - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/pihole%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/pihole%20(Community)%20(%7EARM%7E)/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/jenkins/job/pihole%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps-arm.yunohost.org/jenkins/job/pihole%20(Community)%20(%7EARM%7E)/) ## Limitations diff --git a/conf/app.src b/conf/app.src index bc029e6..74230e9 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/pi-hole/pi-hole/archive/v3.3.tar.gz -SOURCE_SUM=6d4eb0905cf5eb03f16cd8080a66c6f4 +SOURCE_URL=https://github.com/pi-hole/pi-hole/archive/v3.3.1.tar.gz +SOURCE_SUM=ea4f64bdf88620f59a1b01c19253e4e3 SOURCE_SUM_PRG=md5sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 77611d7..0630a90 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Network-wide ad blocking via your own DNS server.", "fr": "Filtrage publicitaire sur l'ensemble du réseau via votre propre serveur DNS." }, - "version": "3.3~ynh2", + "version": "3.3.1~ynh1", "url": "https://pi-hole.net/", "license": "EUPL-1.2", "maintainer": { @@ -14,7 +14,7 @@ "email": "maniackc_dev@crudelis.fr" }, "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": ">= 2.7.12" }, "multi_instance": false, "services": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 22b21c9..c6fec0c 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -34,216 +34,41 @@ IS_PACKAGE_CHECK () { # Détermine une exécution en conteneur (Non testé) # EXPERIMENTAL HELPERS #================================================= -# INFOS -# n (Node version management) utilise la variable PATH pour stocker le path de la version de node à utiliser. -# C'est ainsi qu'il change de version -# ynh_install_nodejs installe la version de nodejs demandée en argument, avec n -# ynh_use_nodejs active une version de nodejs dans le script courant -# 3 variables sont mises à disposition, et 2 sont stockées dans la config de l'app -# - nodejs_path: Le chemin absolu de cette version de node -# Utilisé pour des appels directs à node. -# - nodejs_version: Simplement le numéro de version de nodejs pour cette application -# - nodejs_use_version: Un alias pour charger une version de node dans le shell courant. -# Utilisé pour démarrer un service ou un script qui utilise node ou npm -# Dans ce cas, c'est $PATH qui contient le chemin de la version de node. Il doit être propagé sur les autres shell si nécessaire. - -n_install_dir="/opt/node_n" -node_version_path="/opt/node_n/n/versions/node" -# N_PREFIX est le dossier de n, il doit être chargé dans les variables d'environnement pour n. -export N_PREFIX="$n_install_dir" - -ynh_install_n () { - echo "Installation of N - Node.js version management" >&2 - # Build an app.src for n - mkdir -p "../conf" - echo "SOURCE_URL=https://github.com/tj/n/archive/v2.1.7.tar.gz -SOURCE_SUM=2ba3c9d4dd3c7e38885b37e02337906a1ee91febe6d5c9159d89a9050f2eea8f" > "../conf/n.src" - # Download and extract n - ynh_setup_source "$n_install_dir/git" n - # Install n - (cd "$n_install_dir/git" - PREFIX=$N_PREFIX make install 2>&1) -} - -ynh_use_nodejs () { - nodejs_version=$(ynh_app_setting_get $app nodejs_version) - - load_n_path="[[ :$PATH: == *\":$n_install_dir/bin:\"* ]] || PATH=\"$n_install_dir/bin:$PATH\"; N_PREFIX="$n_install_dir"" - - nodejs_use_version="$n_install_dir/bin/n -q $nodejs_version" - - # "Load" a version of node - eval $load_n_path; $nodejs_use_version - - # Get the absolute path of this version of node - nodejs_path="$(n bin $nodejs_version)" - - # Make an alias for node use - ynh_node_exec="eval $load_n_path; n use $nodejs_version" -} - -ynh_install_nodejs () { - # Use n, https://github.com/tj/n to manage the nodejs versions - nodejs_version="$1" - local n_install_script="https://git.io/n-install" - - # Create $n_install_dir - mkdir -p "$n_install_dir" - - # Load n path in PATH - CLEAR_PATH="$n_install_dir/bin:$PATH" - # Remove /usr/local/bin in PATH in case of node has already setup. - PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') - - # Move an existing node binary, to avoid to block n. - test -x /usr/bin/node && mv /usr/bin/node /usr/bin/node_n - test -x /usr/bin/npm && mv /usr/bin/npm /usr/bin/npm_n - - # If n is not previously setup, install it - if ! test n --version > /dev/null 2>&1 - then - ynh_install_n - fi - - # Modify the default N_PREFIX in n script - ynh_replace_string "^N_PREFIX=\${N_PREFIX-.*}$" "N_PREFIX=\${N_PREFIX-$N_PREFIX}" "$n_install_dir/bin/n" - - # Restore /usr/local/bin in PATH - PATH=$CLEAR_PATH - - # And replace the old node binary. - test -x /usr/bin/node_n && mv /usr/bin/node_n /usr/bin/node - test -x /usr/bin/npm_n && mv /usr/bin/npm_n /usr/bin/npm - - # Install the requested version of nodejs - n $nodejs_version - - # Find the last "real" version for this major version of node. - real_nodejs_version=$(find $node_version_path/$nodejs_version* -maxdepth 0 | sort --version-sort | tail --lines=1) - real_nodejs_version=$(basename $real_nodejs_version) - - # Create a symbolic link for this major version. If the file doesn't already exist - if [ ! -e "$node_version_path/$nodejs_version" ] - then - ln --symbolic --force --no-target-directory $node_version_path/$real_nodejs_version $node_version_path/$nodejs_version - fi - - # Store the ID of this app and the version of node requested for it - echo "$YNH_APP_ID:$nodejs_version" | tee --append "$n_install_dir/ynh_app_version" - - # Store nodejs_version into the config of this app - ynh_app_setting_set $app nodejs_version $nodejs_version - - # Build the update script and set the cronjob - ynh_cron_upgrade_node - - ynh_use_nodejs -} - -ynh_remove_nodejs () { - ynh_use_nodejs - - # Remove the line for this app - sed --in-place "/$YNH_APP_ID:$nodejs_version/d" "$n_install_dir/ynh_app_version" - - # If none another app uses this version of nodejs, remove it. - if ! grep --quiet "$nodejs_version" "$n_install_dir/ynh_app_version" - then - n rm $nodejs_version - fi - - # If none another app uses n, remove n - if [ ! -s "$n_install_dir/ynh_app_version" ] - then - ynh_secure_remove "$n_install_dir" - ynh_secure_remove "/usr/local/n" - sed --in-place "/N_PREFIX/d" /root/.bashrc - fi -} - -ynh_cron_upgrade_node () { - # Build the update script - cat > "$n_install_dir/node_update.sh" << EOF -#!/bin/bash - -version_path="$node_version_path" -n_install_dir="$n_install_dir" - -# Log the date -date - -# List all real installed version of node -all_real_version="\$(find \$version_path/* -maxdepth 0 -type d | sed "s@\$version_path/@@g")" - -# Keep only the major version number of each line -all_real_version=\$(echo "\$all_real_version" | sed 's/\..*\$//') - -# Remove double entries -all_real_version=\$(echo "\$all_real_version" | sort --unique) - -# Read each major version -while read version -do - echo "Update of the version \$version" - sudo \$n_install_dir/bin/n \$version - - # Find the last "real" version for this major version of node. - real_nodejs_version=\$(find \$version_path/\$version* -maxdepth 0 | sort --version-sort | tail --lines=1) - real_nodejs_version=\$(basename \$real_nodejs_version) - - # Update the symbolic link for this version - sudo ln --symbolic --force --no-target-directory \$version_path/\$real_nodejs_version \$version_path/\$version -done <<< "\$(echo "\$all_real_version")" -EOF - - chmod +x "$n_install_dir/node_update.sh" - - # Build the cronjob - cat > "/etc/cron.daily/node_update" << EOF -#!/bin/bash - -$n_install_dir/node_update.sh >> $n_install_dir/node_update.log -EOF - - chmod +x "/etc/cron.daily/node_update" -} - -#================================================= - # Start or restart a service and follow its booting # # usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name] # # | arg: Line to match - The line to find in the log to attest the service have finished to boot. -# | arg: Log file - The log file to watch -# | arg: Service name -# /var/log/$app/$app.log will be used if no other log is defined. +# | arg: Log file - The log file to watch; specify "systemd" to read systemd journal for specified service +# /var/log/$app/$app.log will be used if no other log is defined. # | arg: Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds. +# | arg: Service name + ynh_check_starting () { local line_to_match="$1" - local service_name="${4:-$app}" local app_log="${2:-/var/log/$service_name/$service_name.log}" local timeout=${3:-300} - - ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 - } + local service_name="${4:-$app}" echo "Starting of $service_name" >&2 systemctl stop $service_name local templog="$(mktemp)" # Following the starting of the app in its log - tail -F -n0 "$app_log" > "$templog" & - # Get the PID of the tail command + if [ "$app_log" == "systemd" ] ; then + # Read the systemd journal + journalctl -u $service_name -f --since=-45 > "$templog" & + else + # Read the specified log file + tail -F -n0 "$app_log" > "$templog" & + fi + # Get the PID of the last command local pid_tail=$! systemctl start $service_name local i=0 for i in `seq 1 $timeout` do - # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout + # Read the log until the sentence is found, which means the app finished starting. Or run until the timeout. if grep --quiet "$line_to_match" "$templog" then echo "The service $service_name has correctly started." >&2 @@ -254,12 +79,22 @@ ynh_check_starting () { done if [ $i -eq $timeout ] then - echo "The service $service_name didn't fully started before the timeout." >&2 + echo "The service $service_name didn't fully start before the timeout." >&2 fi echo "" ynh_clean_check_starting } +# Clean temporary process and file used by ynh_check_starting +# (usually used in ynh_clean_setup scripts) +# +# usage: ynh_clean_check_starting + +ynh_clean_check_starting () { + # Stop the execution of tail. + kill -s 15 $pid_tail 2>&1 + ynh_secure_remove "$templog" 2>&1 +} #================================================= @@ -369,9 +204,20 @@ ynh_print_ON () { # # usage: ynh_multimedia_build_main_dir ynh_multimedia_build_main_dir () { - wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/master.zip 2>&1 - unzip -q master.zip - ./yunohost.multimedia-master/script/ynh_media_build.sh + local ynh_media_release="v1.0" + local checksum="4852c8607db820ad51f348da0dcf0c88" + + # Download yunohost.multimedia scripts + wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz + + # Check the control sum + echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ + || ynh_die "Corrupt source" + + # 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 @@ -456,7 +302,7 @@ EOF ynh_store_file_checksum "$finalfail2banjailconf" ynh_store_file_checksum "$finalfail2banfilterconf" - systemctl restart fail2ban + systemctl reload fail2ban local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")" if [ -n "$fail2ban_error" ] then @@ -471,7 +317,7 @@ EOF ynh_remove_fail2ban_config () { ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf" ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf" - sudo systemctl restart fail2ban + systemctl reload fail2ban } #================================================= @@ -487,6 +333,38 @@ ynh_read_manifest () { python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])" } +# Read the upstream version from the manifest +# The version number in the manifest is defined by ~ynh +# For example : 4.3-2~ynh3 +# This include the number before ~ynh +# In the last example it return 4.3-2 +# +# usage: ynh_app_upstream_version +ynh_app_upstream_version () { + manifest_path="../manifest.json" + if [ ! -e "$manifest_path" ]; then + manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place + fi + version_key=$(ynh_read_manifest "$manifest_path" "version") + echo "${version_key/~ynh*/}" +} + +# Read package version from the manifest +# The version number in the manifest is defined by ~ynh +# For example : 4.3-2~ynh3 +# This include the number after ~ynh +# In the last example it return 3 +# +# usage: ynh_app_package_version +ynh_app_package_version () { + manifest_path="../manifest.json" + if [ ! -e "$manifest_path" ]; then + manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place + fi + version_key=$(ynh_read_manifest "$manifest_path" "version") + echo "${version_key/*~ynh/}" +} + # Exit without error if the package is up to date # # This helper should be used to avoid an upgrade of a package @@ -569,8 +447,16 @@ Automatic diagnosis data from YunoHost $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" + # 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 + # Send the email to the recipients - echo "$mail_message" | mail -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" + echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" } #================================================= @@ -612,8 +498,6 @@ is_jessie () { fi } -#================================================= -#============= FUTURE YUNOHOST HELPER ============ #================================================= # Delete a file checksum from the app settings @@ -626,3 +510,66 @@ ynh_delete_file_checksum () { local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' ynh_app_setting_delete $app $checksum_setting_name } + +#================================================= + +ynh_maintenance_mode_ON () { + # 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 () { + # 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/_sed b/scripts/_sed deleted file mode 100644 index cc76ab9..0000000 --- a/scripts/_sed +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -# https://github.com/YunoHost/yunohost/pull/394 - -# Substitute/replace a string (or expression) by another in a file -# -# usage: ynh_replace_string match_string replace_string target_file -# | arg: match_string - String to be searched and replaced in the file -# | arg: replace_string - String that will replace matches -# | arg: target_file - File in which the string will be replaced. -# -# As this helper is based on sed command, regular expressions and -# references to sub-expressions can be used -# (see sed manual page for more information) -ynh_replace_string () { - local delimit=@ - local match_string=$1 - local replace_string=$2 - local workfile=$3 - - # Escape the delimiter if it's in the string. - match_string=${match_string//${delimit}/"\\${delimit}"} - replace_string=${replace_string//${delimit}/"\\${delimit}"} - - sudo sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$workfile" -} - -# Substitute/replace a password by another in a file -# -# usage: ynh_replace_password_string match_string replace_string target_file -# | arg: match_string - String to be searched and replaced in the file -# | arg: replace_string - String that will replace matches -# | arg: target_file - File in which the string will be replaced. -# -# This helper will use ynh_replace_string, but as you can use special -# characters, you can't use some regular expressions and sub-expressions. -ynh_replace_password_string () { - local match_string=$1 - local replace_string=$2 - local workfile=$3 - - # Escape any backslash to preserve them as simple backslash. - match_string=${match_string//\\/"\\\\"} - replace_string=${replace_string//\\/"\\\\"} - - # Escape the & character, who has a special function in sed. - match_string=${match_string//&/"\&"} - replace_string=${replace_string//&/"\&"} - - ynh_replace_string "$match_string" "$replace_string" "$workfile" -} diff --git a/scripts/backup b/scripts/backup index 3b51a77..66a6884 100644 --- a/scripts/backup +++ b/scripts/backup @@ -28,8 +28,15 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get $app final_path) +path_url=$(ynh_app_setting_get $app path) domain=$(ynh_app_setting_get $app domain) +#================================================= +# ACTIVATE MAINTENANCE MODE +#================================================= + +ynh_maintenance_mode_ON + #================================================= # STANDARD BACKUP STEPS #================================================= @@ -93,3 +100,9 @@ if test -e "/etc/dnsmasq.d/04-pihole-static-dhcp.conf"; then fi ynh_backup "/usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app" + +#================================================= +# DEACTIVE MAINTENANCE MODE +#================================================= + +ynh_maintenance_mode_OFF diff --git a/scripts/change_url b/scripts/change_url index 9d82110..7a37627 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -8,7 +8,6 @@ source _common.sh source /usr/share/yunohost/helpers -source _sed #================================================= # RETRIEVE ARGUMENTS @@ -31,6 +30,14 @@ test -n "$new_path" || new_path="/" new_path=$(ynh_normalize_url_path $new_path) old_path=$(ynh_normalize_url_path $old_path) +#================================================= +# ACTIVATE MAINTENANCE MODE +#================================================= + +path_url=$old_path +domain=$old_domain +ynh_maintenance_mode_ON + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= @@ -94,3 +101,11 @@ fi #================================================= ynh_system_reload nginx + +#================================================= +# DEACTIVE MAINTENANCE MODE +#================================================= + +path_url=$old_path +domain=$old_domain +ynh_maintenance_mode_OFF diff --git a/scripts/install b/scripts/install index e194bb7..eb046fd 100644 --- a/scripts/install +++ b/scripts/install @@ -54,6 +54,12 @@ ynh_app_setting_set $app admin $admin ynh_app_setting_set $app query_logging $query_logging ynh_app_setting_set $app enable_dhcp $enable_dhcp +#================================================= +# ACTIVATE MAINTENANCE MODE +#================================================= + +ynh_maintenance_mode_ON + #================================================= # STANDARD MODIFICATIONS #================================================= @@ -344,6 +350,12 @@ yunohost app addaccess --users=$admin $app ynh_system_reload nginx +#================================================= +# DEACTIVE MAINTENANCE MODE +#================================================= + +ynh_maintenance_mode_OFF + #================================================= # SEND A README FOR THE ADMIN #================================================= diff --git a/scripts/restore b/scripts/restore index 9ec1978..430494f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -44,6 +44,12 @@ ynh_webpath_available $domain $path_url \ test ! -d $final_path \ || ynh_die "There is already a directory: $final_path " +#================================================= +# ACTIVATE MAINTENANCE MODE +#================================================= + +ynh_maintenance_mode_ON + #================================================= # STANDARD RESTORE STEPS #================================================= @@ -198,6 +204,12 @@ ynh_system_reload pihole-FTL restart ynh_system_reload php5-fpm ynh_system_reload nginx +#================================================= +# DEACTIVE MAINTENANCE MODE +#================================================= + +ynh_maintenance_mode_OFF + #================================================= # SEND A README FOR THE ADMIN #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 907a538..91b98a2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,6 +49,12 @@ ynh_abort_if_errors path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path. +#================================================= +# ACTIVATE MAINTENANCE MODE +#================================================= + +ynh_maintenance_mode_ON + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -198,3 +204,9 @@ cp ../conf/dnsmasq_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-dnsmas #================================================= ynh_system_reload nginx + +#================================================= +# DEACTIVE MAINTENANCE MODE +#================================================= + +ynh_maintenance_mode_OFF