Intégration de la branche runs
This commit is contained in:
commit
ebe45998ab
|
@ -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
|
||||
|
@ -158,24 +158,24 @@ function runs_initdir() {
|
|||
echo "$sysinfost" >"$runshostdir/sysinfos.conf"
|
||||
fi
|
||||
if [ ! -f "$runshostdir/default" ]; then
|
||||
estep "Création de $(ppath "$runshostdir/default")"
|
||||
echo "$defaultt" >"$runshostdir/default"
|
||||
estep "Création de $(ppath "$runshostdir/default.rr")"
|
||||
echo "$defaultt" >"$runshostdir/default.rr"
|
||||
edit_default=1
|
||||
fi
|
||||
if [ ! -f "$runshostdir/config" ]; then
|
||||
estep "Création de $(ppath "$runshostdir/config")"
|
||||
echo "$configt" >"$runshostdir/config"
|
||||
estep "Création de $(ppath "$runshostdir/config.rr")"
|
||||
echo "$configt" >"$runshostdir/config.rr"
|
||||
fi
|
||||
if [ ! -f "$runshostdir/services" ]; then
|
||||
estep "Création de $(ppath "$runshostdir/services")"
|
||||
echo "$servicest" >"$runshostdir/services"
|
||||
estep "Création de $(ppath "$runshostdir/services.rr")"
|
||||
echo "$servicest" >"$runshostdir/services.rr"
|
||||
fi
|
||||
if [ ! -f "$runshostdir/userdefault" ]; then
|
||||
estep "Création de $(ppath "$runshostdir/userdefault")"
|
||||
echo "$userdefaultt" >"$runshostdir/userdefault"
|
||||
estep "Création de $(ppath "$runshostdir/userdefault.rr")"
|
||||
echo "$userdefaultt" >"$runshostdir/userdefault.rr"
|
||||
fi
|
||||
|
||||
[ -n "$edit_default" ] && "${EDITOR:-vi}" "$runshostdir/default"
|
||||
[ -n "$edit_default" ] && "${EDITOR:-vi}" "$runshostdir/default.rr"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
@ -189,9 +189,9 @@ function __runs_create_rscript() {
|
|||
template="$runsconft"
|
||||
elif [ "$rscriptname" == "sysinfos.conf" ]; then
|
||||
template="$sysinfost"
|
||||
elif [ "$rscriptname" == "default" ]; then
|
||||
elif [ "$rscriptname" == "default" -o "$rscriptname" == "default.rr" ]; then
|
||||
template="$defaultt"
|
||||
elif [ "$rscriptname" == "userdefault" ]; then
|
||||
elif [ "$rscriptname" == "userdefault" -o "$rscriptname" == "userdefault.rr" ]; then
|
||||
template="$userdefaultt"
|
||||
else
|
||||
withext "$rscript" || rscript="$rscript.rs"
|
||||
|
@ -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
|
||||
|
@ -475,6 +479,8 @@ function runs_find_scriptfile() {
|
|||
# initialiser les variables RUNSDIR, RUNSSCRIPT, RUNSSCRIPTDIR,
|
||||
# RUNSSCRIPTNAME, RUNSDIRPATH et RUNSSCRIPTPATH. Retourner 0 en cas de
|
||||
# succès, 1 en cas d'échec.
|
||||
# $6 vaut ".rs" par défaut est c'est une extension à rajouter au nom
|
||||
# spécifié si le fichier sans l'extension n'existe pas
|
||||
# RUNSDIR est le répertoire dans lequel a été trouvé le script (parmi les
|
||||
# valeurs fournies dans les tableaux RUNSSCRIPTSDIRS, RUNSMODULESDIRS,
|
||||
# RUNSHOSTSDIRS), RUNSDIRPATH est le répertoire à partir duquel est exprimé
|
||||
|
@ -489,6 +495,7 @@ function runs_find_scriptfile() {
|
|||
local __runsscriptsdirs="${3:-RUNSSCRIPTSDIRS}[@]"
|
||||
local __runsmodulesdirs="${4:-RUNSMODULESDIRS}[@]"
|
||||
local __runshostsdirs="${5:-RUNSHOSTSDIRS}[@]"
|
||||
local __runsext="${6:-.rs}"
|
||||
local __domain __hostname
|
||||
local __runsdir __runsfile
|
||||
|
||||
|
@ -497,10 +504,12 @@ 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
|
||||
__runsfile="$__runsfile.rs"
|
||||
if [ "${__runsfile%$__runsext}" == "$__runsfile" ]; then
|
||||
[ ! -f "$__runsfile" -a -f "$__runsfile$__runsext" ] && __runsfile="$__runsfile$__runsext"
|
||||
fi
|
||||
if [ -e "$__runsfile" ]; then
|
||||
runs_initvars "$__runsfile" "$__runsdir" "$__runsdirpath" "$__scriptfile"
|
||||
|
@ -512,8 +521,8 @@ function runs_find_scriptfile() {
|
|||
# puis chercher dans les répertoires des scripts et des modules
|
||||
for __runsdir in "${!__runsscriptsdirs}" "${!__runsmodulesdirs}"; do
|
||||
__runsfile="$__runsdir/$__scriptfile"
|
||||
if [ ! -f "$__runsfile" -a -f "$__runsfile.rs" ]; then
|
||||
__runsfile="$__runsfile.rs"
|
||||
if [ "${__runsfile%$__runsext}" == "$__runsfile" ]; then
|
||||
[ ! -f "$__runsfile" -a -f "$__runsfile$__runsext" ] && __runsfile="$__runsfile$__runsext"
|
||||
fi
|
||||
if [ -e "$__runsfile" ]; then
|
||||
runs_initvars "$__runsfile" "$__runsdir" "$__runsdir" "$__scriptfile"
|
||||
|
@ -541,6 +550,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/}"
|
||||
|
@ -613,11 +632,26 @@ function runs_recipe() {
|
|||
recipe="$(abspath "$1")"
|
||||
if [ -d "$recipe" ]; then
|
||||
if is_root; then
|
||||
recipe="$recipe/default"
|
||||
if [ -f "$recipe/default.rr" ]; then
|
||||
recipe="$recipe/default.rr"
|
||||
elif [ -f "$recipe/default" ]; then
|
||||
recipe="$recipe/default"
|
||||
else
|
||||
recipe="$recipe/default.rr"
|
||||
fi
|
||||
else
|
||||
recipe="$recipe/userdefault"
|
||||
if [ -f "$recipe/userdefault.rr" ]; then
|
||||
recipe="$recipe/userdefault.rr"
|
||||
elif [ -f "$recipe/userdefault" ]; then
|
||||
recipe="$recipe/userdefault"
|
||||
else
|
||||
recipe="$recipe/userdefault.rr"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ "${recipe%.rr}" == "$recipe" ]; then
|
||||
[ ! -f "$recipe" -a -f "$recipe.rr" ] && recipe="$recipe.rr"
|
||||
fi
|
||||
if [ ! -f "$recipe" ]; then
|
||||
eerror "$(ppath "$recipe"): fichier introuvable"
|
||||
return 1
|
||||
|
@ -708,7 +742,7 @@ function runs_recipepath() {
|
|||
# pas été trouvé, sinon retourner la valeur de retour de runs_recipe()
|
||||
local RUNSDIR RUNSSCRIPT RUNSSCRIPTDIR RUNSSCRIPTNAME RUNSDIRPATH RUNSSCRIPTPATH
|
||||
local RUNSSCRIPTSDIRS RUNSMODULESDIRS RUNSHOSTSDIRS; __runs_setpath
|
||||
if ! runs_find_scriptfile "$1"; then
|
||||
if ! runs_find_scriptfile "$1" "" "" "" "" ".rr"; then
|
||||
eerror "$1: fichier introuvable. Vérifiez les valeurs suivantes:
|
||||
RUNSSCRIPTSPATH=$RUNSSCRIPTSPATH
|
||||
RUNSMODULESPATH=$RUNSMODULESPATH
|
||||
|
|
2
runs
2
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
|
||||
|
|
Loading…
Reference in New Issue