chercher aussi les scripts dans le sous-répertoire runs dans les répertoires d'hôte

This commit is contained in:
Jephté Clain 2015-12-09 22:25:24 +04:00
parent a5f6893e2b
commit a2e863e216
2 changed files with 24 additions and 6 deletions

View File

@ -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/}"

2
runs
View File

@ -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