From a2e863e2160ed1d45f3f321de1dfb74fd71aac86 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Wed, 9 Dec 2015 22:25:24 +0400 Subject: [PATCH] =?UTF-8?q?chercher=20aussi=20les=20scripts=20dans=20le=20?= =?UTF-8?q?sous-r=C3=A9pertoire=20runs=20dans=20les=20r=C3=A9pertoires=20d?= =?UTF-8?q?'h=C3=B4te?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ulib/runs | 28 ++++++++++++++++++++++------ runs | 2 ++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/ulib/runs b/lib/ulib/runs index 69f7f4e..672bcf6 100644 --- a/lib/ulib/runs +++ b/lib/ulib/runs @@ -99,7 +99,7 @@ function runs_initdir() { # d'abord chercher si le répertoire existe déjà for runshostdir in "${RUNSHOSTSDIRS[@]}"; do found= - for dir in "$runshostdir/$domain/$hostname" "$runshostdir/$host"; do + for dir in "$runshostdir/$host/runs" "$runshostdir/$domain/$hostname/runs" "$runshostdir/$host" "$runshostdir/$domain/$hostname"; do if [ -d "$dir" ]; then found=1 break @@ -121,18 +121,18 @@ function runs_initdir() { found= for dir in "$runshostdir/$host" "$runshostdir/$domain/$hostname"; do if [ -d "$dir" ]; then - runshostdir="$dir" + runshostdir="$dir/runs" found=1 break fi done - [ -n "$found" ] || runshostdir="$runshostdir/$host" + [ -n "$found" ] || runshostdir="$runshostdir/$host/runs" else - runshostdir="${RUNSHOSTSDIRS[0]}/$host" + runshostdir="${RUNSHOSTSDIRS[0]}/$host/runs" fi else host="$hostname" - runshostdir="${RUNSHOSTSDIRS[0]}/$host" + runshostdir="${RUNSHOSTSDIRS[0]}/$host/runs" fi local rscriptt runsconft sysinfost defaultt configt servicest @@ -241,7 +241,7 @@ function runs_create_rscript() { splithost "$host" hostname domain for runsdir in "${RUNSHOSTSDIRS[@]}"; do found= - for dir in "$runsdir/$host" "$runsdir/$domain/$hostname"; do + for dir in "$runsdir/$host/runs" "$runsdir/$domain/$hostname/runs" "$runsdir/$host" "$runsdir/$domain/$hostname"; do if [ -d "$dir" ]; then runsdir="$dir" found=1 @@ -370,6 +370,8 @@ function runs_find_hostfile() { splithost "$__runshost" __hostname __domain for __runsdir in "${!__runshostsdirs}"; do for __runsfile in \ + "$__runsdir/$__runshost/runs/$__hostfile" \ + "$__runsdir/$__domain/$__hostname/runs/$__hostfile"\ "$__runsdir/$__runshost/$__hostfile" \ "$__runsdir/$__domain/$__hostname/$__hostfile"; do if [ -e "$__runsfile" ]; then @@ -417,6 +419,8 @@ function runs_find_datafile() { splithost "$__runshost" __hostname __domain for __runsdir in "${!__runshostsdirs}"; do for __runsfile in \ + "$__runsdir/$__runshost/runs/$__datafile" \ + "$__runsdir/$__domain/$__hostname/runs/$__datafile"\ "$__runsdir/$__runshost/$__datafile" \ "$__runsdir/$__domain/$__hostname/$__datafile"; do if [ -e "$__runsfile" ]; then @@ -497,6 +501,8 @@ function runs_find_scriptfile() { splithost "$__runshost" __hostname __domain for __runsdir in "${!__runshostsdirs}"; do for __runsfile in \ + "$__runsdir/$__runshost/runs/$__scriptfile" \ + "$__runsdir/$__domain/$__hostname/runs/$__scriptfile" \ "$__runsdir/$__runshost/$__scriptfile" \ "$__runsdir/$__domain/$__hostname/$__scriptfile"; do if [ ! -f "$__runsfile" -a -f "$__runsfile.rs" ]; then @@ -541,6 +547,16 @@ function runs_find_scriptfile_reverse() { if [ -n "$__runshost" ]; then splithost "$__runshost" __hostname __domain for __runsdir in "${!__runshostsdirs}"; do + __prefix="$__runsdir/$__runshost/runs/" + if [ "${__runsscript#$__prefix}" != "$__runsscript" ]; then + runs_initvars "$__runsscript" "$__runsdir" "$__prefix" "${__runsscript#$__prefix/}" + return 0 + fi + __prefix="$__runsdir/$__domain/$__hostname/runs/" + if [ "${__runsscript#$__prefix}" != "$__runsscript" ]; then + runs_initvars "$__runsscript" "$__runsdir" "$__prefix" "${__runsscript#$__prefix/}" + return 0 + fi __prefix="$__runsdir/$__runshost/" if [ "${__runsscript#$__prefix}" != "$__runsscript" ]; then runs_initvars "$__runsscript" "$__runsdir" "$__prefix" "${__runsscript#$__prefix/}" diff --git a/runs b/runs index 9fdea23..329c09c 100755 --- a/runs +++ b/runs @@ -277,6 +277,8 @@ elif [ "$action" == "list" ]; then rscriptpaths=() if [ -n "$runshost" ]; then for runsdir in "${RUNSHOSTSDIRS[@]}"; do + find_items rscriptpaths "$runsdir/$runshost/runs" + find_items rscriptpaths "$runsdir/$domain/$hostname/runs" find_items rscriptpaths "$runsdir/$runshost" find_items rscriptpaths "$runsdir/$domain/$hostname" done