From 1b922757c07d09844cd57c1d78e6aa05c5c57114 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Tue, 18 Jul 2017 10:49:45 +0400 Subject: [PATCH] apacheconfig: support d'un script post-update.sh --- apacheconfig | 9 ++++++++- lib/ulib/apache.tools | 19 ++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/apacheconfig b/apacheconfig index 7472a61..09d903d 100755 --- a/apacheconfig +++ b/apacheconfig @@ -68,6 +68,10 @@ OPTIONS configuration. -N, --network-config Mettre aussi à jour la configuration réseau. + --no-post-update + Ne pas lancer le script post-update.sh après le déploiement s'il existe. + Le script est lancé avec les mêmes arguments que apacheconfig_deploy() + la fonction définie dans le module apache.tools -r, --certsdir CERTSDIR Spécifier le cas échéant le répertoire contenant les certificats à déployer. Cet argument est requis si le répertoire certsconf/ existe, @@ -111,6 +115,7 @@ FULLCONF= pull= fixip= netconf= +no_post_update= aac_certsdir= bits= oneconf= @@ -145,6 +150,7 @@ args=( -p,--pull pull=1 -F,--fix-ip fixip=1 -N,--network-config netconf=1 + --no-post-update no_post_update=1 -r:,--certsdir: aac_certsdir= --localhosts action=localhosts -C:,--one-conf: oneconf= @@ -211,6 +217,7 @@ elif [ "$action" == deploy -o "$action" == localhosts ]; then -d "$destdir" --$action ${fixip:+--fix-ip} ${netconf:+--network-config} + ${no_post_update:+--no-post-update} ${aac_certsdir:+-r "$aac_certsdir"} ${oneconf:+--one-conf "$oneconf"} ${onemodule:+--one-module "$onemodule"} @@ -230,7 +237,7 @@ elif [ "$action" == deploy -o "$action" == localhosts ]; then "$destdir" "$aac_certsdir" \ "$config" "$oneconf" "$onemodule" "$onesite" \ "$custom_sysinfos" "$sysname" "$sysdist" "$sysver" "$bits" \ - "$netconf" "$fixip" || die + "$netconf" "$fixip" "$no_post_update" || die eend elif [ "$action" == localhosts ]; then etitle "Mise à jour de /etc/hosts" diff --git a/lib/ulib/apache.tools b/lib/ulib/apache.tools index 68bdbdd..85d470f 100644 --- a/lib/ulib/apache.tools +++ b/lib/ulib/apache.tools @@ -566,7 +566,7 @@ Le fichier de configuration $confname a été ignoré" local conf etitle "Configuration de base" - array_add ignores syspkgs.conf confs.conf modules.conf sites.conf network.conf + array_add ignores syspkgs.conf confs.conf modules.conf sites.conf network.conf post-update.sh array_from_lines confs "$(list_files "$confdir")" for conf in "${confs[@]}"; do array_contains ignores "$conf" && continue @@ -960,10 +960,11 @@ function apacheconfig_deploy() { local destdir="$1" certsdir="$2"; shift; shift local config="$1" oneconf="$2" onemodule="$3"; onesite="$4"; shift; shift; shift; shift local custom_sysinfos="$1" sysname="$2" sysdist="$3" sysver="$4" bits="$5"; shift; shift; shift; shift; shift - local netconf="$1" fixip="$2"; shift; shift + local netconf="$1" fixip="$2" no_post_update="$3"; shift; shift; shift + local configdir="$(basename -- "$config")" local -a args - args=(--ignore "$(basename -- "$config")") + args=(--ignore "$configdir") [ -n "$oneconf" ] && array_add args --one-conf "$(basename -- "$oneconf")" [ -n "$onemodule" ] && array_add args --one-module "$(basename -- "$onemodule")" [ -n "$onesite" ] && array_add args --one-site "$(basename -- "$onesite")" @@ -974,7 +975,15 @@ function apacheconfig_deploy() { for __name in "${TEMPLATE_DYNAMIC_VARS[@]}"; do array_add args "$__name=${!__name}" done - apache_autoconf "${args[@]}" "$@" + apache_autoconf "${args[@]}" "$@" || return 1 + if [ -x "$configdir/post-update.sh" ]; then + "$configdir/post-update.sh" \ + "$destdir" "$certsdir" \ + "$config" "$oneconf" "$onemodule" "$onesite" \ + "$custom_sysinfos" "$sysname" "$sysdist" "$sysver" "$bits" \ + "$netconf" "$fixip" || return 2 + fi + return 0 } function apacheconfig_qs() { @@ -988,7 +997,7 @@ function apacheconfig_qs() { "$destdir" "$2" \ "$config" "" "" "" \ "" "" "" "" "" \ - "$3" "$4" + "$3" "$4" "" } function apacheconfig_localhosts() {