runs et rruns: améliorer le calcul des chemins
This commit is contained in:
parent
55c57551eb
commit
30e5ddabbb
|
@ -2,12 +2,15 @@
|
|||
|
||||
# Liste des répertoires à considérer pour la recherche de scripts runs
|
||||
#RUNSSCRIPTSPATH=
|
||||
#RUNSSCRIPTSDIRS=()
|
||||
|
||||
# Liste des répertoires à considérer pour la recherche de modules installables
|
||||
#RUNSMODULESPATH=
|
||||
#RUNSMODULESDIRS=()
|
||||
|
||||
# Liste des répertoires à considérer pour la recherche de répertoires d'hôtes
|
||||
#RUNSHOSTSPATH=
|
||||
#RUNSHOSTSDIRS=()
|
||||
|
||||
# Liste des domaines à rechercher, si un hôte déjà configuré est donné sans
|
||||
# domaine. Si cette liste est vide, le fichier /etc/resolv.conf est consulté
|
||||
|
|
|
@ -900,6 +900,7 @@ exit 0
|
|||
set_var "$runspath" "$(array_join runsdirs :)"
|
||||
done
|
||||
# XXX quelles autres variables doivent être corrigées?
|
||||
# XXX ==> il faut rajouter rscripts et recipes
|
||||
fi
|
||||
elif [ -n "$runsworkdir" ]; then
|
||||
RUNSWORKDIR="$runsworkdir"
|
||||
|
|
51
rruns
51
rruns
|
@ -74,7 +74,21 @@ OPTIONS
|
|||
argument (hors options)."
|
||||
}
|
||||
|
||||
RUNSSCRIPTSPATH=
|
||||
RUNSSCRIPTSDIRS=()
|
||||
RUNSMODULESPATH=
|
||||
RUNSMODULESDIRS=()
|
||||
RUNSHOSTSPATH=
|
||||
RUNSHOSTSDIRS=()
|
||||
RUNSDOMAINS=()
|
||||
RUNSDOMAIN=
|
||||
set_defaults runs
|
||||
[ -n "$RUNSSCRIPTSPATH" ] && RUNSSCRIPTSDIRS=("$RUNSSCRIPTSPATH" "${RUNSSCRIPTSDIRS[@]}")
|
||||
array_fix_paths RUNSSCRIPTSDIRS; setx RUNSSCRIPTSPATH=array_to_path RUNSSCRIPTSDIRS
|
||||
[ -n "$RUNSMODULESPATH" ] && RUNSMODULESDIRS=("$RUNSMODULESPATH" "${RUNSMODULESDIRS[@]}")
|
||||
array_fix_paths RUNSMODULESDIRS; setx RUNSMODULESPATH=array_to_path RUNSMODULESDIRS
|
||||
[ -n "$RUNSHOSTSPATH" ] && RUNSHOSTSDIRS=("$RUNSHOSTSPATH" "${RUNSHOSTSDIRS[@]}")
|
||||
array_fix_paths RUNSHOSTSDIRS; setx RUNSHOSTSPATH=array_to_path RUNSHOSTSDIRS
|
||||
|
||||
action=deploy
|
||||
confuser=
|
||||
|
@ -89,8 +103,11 @@ init=auto
|
|||
init_sysinfos=
|
||||
sysinfos_data=
|
||||
runsscriptspath=
|
||||
runsscriptsdirs=()
|
||||
runsmodulespath=
|
||||
runsmodulesdirs=()
|
||||
runshostspath=
|
||||
runshostsdirs=()
|
||||
parse_opts "${PRETTYOPTS[@]}" \
|
||||
--help '$exit_with display_help' \
|
||||
-C action=configure \
|
||||
|
@ -107,13 +124,25 @@ parse_opts "${PRETTYOPTS[@]}" \
|
|||
--no-init init= \
|
||||
--sysinfos init_sysinfos=1 \
|
||||
--runsscriptspath: runsscriptspath= \
|
||||
--runsscriptsdir: runsscriptsdirs \
|
||||
--runsmodulespath: runsmodulespath= \
|
||||
--runsmodulesdir: runsmodulesdirs \
|
||||
--runshostspath: runshostspath= \
|
||||
--runshostsdir: runshostsdirs \
|
||||
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
||||
|
||||
[ -n "$runsscriptspath" ] && runsscriptsdirs=("$runsscriptspath" "${runsscriptsdirs[@]}")
|
||||
array_fix_paths runsscriptsdirs; setx runsscriptspath=array_to_path runsscriptsdirs
|
||||
[ -n "$runsscriptspath" ] && RUNSSCRIPTSPATH="$runsscriptspath"
|
||||
[ -n "$runsmodulespath" ] && runsmodulesdirs=("$runsmodulespath" "${runsmodulesdirs[@]}")
|
||||
array_fix_paths runsmodulesdirs; setx runsmodulespath=array_to_path runsmodulesdirs
|
||||
[ -n "$runsmodulespath" ] && RUNSMODULESPATH="$runsmodulespath"
|
||||
[ -n "$runshostspath" ] && runshostsdirs=("$runshostspath" "${runshostsdirs[@]}")
|
||||
array_fix_paths runshostsdirs; setx runshostspath=array_to_path runshostsdirs
|
||||
[ -n "$runshostspath" ] && RUNSHOSTSPATH="$runshostspath"
|
||||
[ -n "$RUNSSCRIPTSPATH" ] || RUNSSCRIPTSPATH=:
|
||||
[ -n "$RUNSMODULESPATH" ] || RUNSMODULESPATH=:
|
||||
[ -n "$RUNSHOSTSPATH" ] || RUNSHOSTSPATH=:
|
||||
|
||||
__PARSED_HOSTS=()
|
||||
__PARSED_FILES=()
|
||||
|
@ -204,11 +233,12 @@ if [ "$action" == "configure" ]; then
|
|||
${tmproot:+--tmproot "$tmproot"} ${SSH:+-S "$SSH"} \
|
||||
${force_make_archive:+--force-make-archive} \
|
||||
-h "$user@$host" || continue
|
||||
|
||||
etitle "Configuration initiale pour runs" \
|
||||
"$scriptdir/runs" \
|
||||
${runsscriptspath:+--runsscriptspath "$runsscriptspath"} \
|
||||
${runsmodulespath:+--runsmodulespath "$runsmodulespath"} \
|
||||
${runshostspath:+--runshostspath "$runshostspath"} \
|
||||
--runsscriptspath "$RUNSSCRIPTSPATH" \
|
||||
--runsmodulespath "$RUNSMODULESPATH" \
|
||||
--runshostspath "$RUNSHOSTSPATH" \
|
||||
--init -h "$host"
|
||||
done
|
||||
exit 0
|
||||
|
@ -299,9 +329,9 @@ for userhost in "${hosts[@]}"; do
|
|||
|
||||
estep "Vérification de la configuration de l'hôte pour runs"
|
||||
"$scriptdir/runs" \
|
||||
${runsscriptspath:+--runsscriptspath "$runsscriptspath"} \
|
||||
${runsmodulespath:+--runsmodulespath "$runsmodulespath"} \
|
||||
${runshostspath:+--runshostspath "$runshostspath"} \
|
||||
--runsscriptspath "$RUNSSCRIPTSPATH" \
|
||||
--runsmodulespath "$RUNSMODULESPATH" \
|
||||
--runshostspath "$RUNSHOSTSPATH" \
|
||||
$action -h "$host" || { eend; continue; }
|
||||
fi
|
||||
|
||||
|
@ -317,10 +347,11 @@ for userhost in "${hosts[@]}"; do
|
|||
|
||||
# Création de l'export
|
||||
etitle "Préparation de l'export"
|
||||
args=(--export --runsexportdir "$exportdir"
|
||||
${runsscriptspath:+--runsscriptspath "$runsscriptspath"}
|
||||
${runsmodulespath:+--runsmodulespath "$runsmodulespath"}
|
||||
${runshostspath:+--runshostspath "$runshostspath"}
|
||||
args=(
|
||||
--export --runsexportdir "$exportdir"
|
||||
--runsscriptspath "$RUNSSCRIPTSPATH"
|
||||
--runsmodulespath "$RUNSMODULESPATH"
|
||||
--runshostspath "$RUNSHOSTSPATH"
|
||||
)
|
||||
[ "$host" != "localhost" ] && args=("${args[@]}" -h "$host")
|
||||
[ -n "$runsreset" ] && args=("${args[@]}" -z)
|
||||
|
|
67
runs
67
runs
|
@ -58,11 +58,28 @@ Gestion des scripts
|
|||
-z Forcer la réinstallation des scripts qui se basent sur shouldrun/setdone"
|
||||
}
|
||||
|
||||
RUNSSCRIPTSPATH=
|
||||
RUNSSCRIPTSDIRS=()
|
||||
RUNSMODULESPATH=
|
||||
RUNSMODULESDIRS=()
|
||||
RUNSHOSTSPATH=
|
||||
RUNSHOSTSDIRS=()
|
||||
RUNSDOMAINS=()
|
||||
RUNSDOMAIN=
|
||||
set_defaults runs
|
||||
[ -n "$RUNSSCRIPTSPATH" ] && RUNSSCRIPTSDIRS=("$RUNSSCRIPTSPATH" "${RUNSSCRIPTSDIRS[@]}")
|
||||
array_fix_paths RUNSSCRIPTSDIRS; setx RUNSSCRIPTSPATH=array_to_path RUNSSCRIPTSDIRS
|
||||
[ -n "$RUNSMODULESPATH" ] && RUNSMODULESDIRS=("$RUNSMODULESPATH" "${RUNSMODULESDIRS[@]}")
|
||||
array_fix_paths RUNSMODULESDIRS; setx RUNSMODULESPATH=array_to_path RUNSMODULESDIRS
|
||||
[ -n "$RUNSHOSTSPATH" ] && RUNSHOSTSDIRS=("$RUNSHOSTSPATH" "${RUNSHOSTSDIRS[@]}")
|
||||
array_fix_paths RUNSHOSTSDIRS; setx RUNSHOSTSPATH=array_to_path RUNSHOSTSDIRS
|
||||
|
||||
function runs_path_required() {
|
||||
die "Vous devez définir $1 dans ~/etc/default/runs"
|
||||
}
|
||||
function runs_path_undefined() {
|
||||
ewarn "La variable $1 n'est pas définie dans ~/etc/default/runs"
|
||||
}
|
||||
|
||||
action=runs
|
||||
create_verbose=
|
||||
|
@ -77,8 +94,11 @@ runssysdist=
|
|||
runssysver=
|
||||
runsbits=
|
||||
runsscriptspath=
|
||||
runsscriptsdirs=()
|
||||
runsmodulespath=
|
||||
runsmodulesdirs=()
|
||||
runshostspath=
|
||||
runshostsdirs=()
|
||||
runsexportdir= # répertoire dans lequel exporter les fichiers
|
||||
runsworkdir= # si runsexportdir n'est pas spécifié, répertoire de travail
|
||||
runsvarsfile= # fichier contenant des définitions à charger
|
||||
|
@ -106,16 +126,25 @@ parse_opts "${PRETTYOPTS[@]}" \
|
|||
--sysver: runssysver= \
|
||||
--bits: runsbits= \
|
||||
--runsscriptspath: runsscriptspath= \
|
||||
--runsscriptsdir: runsscriptsdirs \
|
||||
--runsmodulespath: runsmodulespath= \
|
||||
--runsmodulesdir: runsmodulesdirs \
|
||||
--runshostspath: runshostspath= \
|
||||
--runshostsdir: runshostsdirs \
|
||||
--runsexportdir: runsexportdir= \
|
||||
--runsworkdir: runsworkdir= \
|
||||
--runsvarsfile: runsvarsfile= \
|
||||
-z RUNSRESET=1 \
|
||||
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
||||
|
||||
[ -n "$runsscriptspath" ] && runsscriptsdirs=("$runsscriptspath" "${runsscriptsdirs[@]}")
|
||||
array_fix_paths runsscriptsdirs; setx runsscriptspath=array_to_path runsscriptsdirs
|
||||
[ -n "$runsscriptspath" ] && RUNSSCRIPTSPATH="$runsscriptspath"
|
||||
[ -n "$runsmodulespath" ] && runsmodulesdirs=("$runsmodulespath" "${runsmodulesdirs[@]}")
|
||||
array_fix_paths runsmodulesdirs; setx runsmodulespath=array_to_path runsmodulesdirs
|
||||
[ -n "$runsmodulespath" ] && RUNSMODULESPATH="$runsmodulespath"
|
||||
[ -n "$runshostspath" ] && runshostsdirs=("$runshostspath" "${runshostsdirs[@]}")
|
||||
array_fix_paths runshostsdirs; setx runshostspath=array_to_path runshostsdirs
|
||||
[ -n "$runshostspath" ] && RUNSHOSTSPATH="$runshostspath"
|
||||
|
||||
if [ "$action" == runs \
|
||||
|
@ -171,6 +200,9 @@ if ! is_root && [ -n "$run_as_root" ]; then
|
|||
for recipe in "${recipes[@]}"; do
|
||||
args=("${args[@]}" -r "$recipe")
|
||||
done
|
||||
[ -n "$RUNSSCRIPTSPATH" ] || RUNSSCRIPTSPATH=:
|
||||
[ -n "$RUNSMODULESPATH" ] || RUNSMODULESPATH=:
|
||||
[ -n "$RUNSHOSTSPATH" ] || RUNSHOSTSPATH=:
|
||||
args=("${args[@]}" ${runshost:+-h "$runshost"}
|
||||
${runssysname:+--sysname "$runssysname"} ${runssysdist:+--sysdist "$runssysdist"} ${runssysver:+--sysver "$runssysver"} ${runsbits:+--bits "$runsbits"}
|
||||
${RUNSSCRIPTSPATH:+--runsscriptspath "$RUNSSCRIPTSPATH"}
|
||||
|
@ -220,8 +252,8 @@ bits=$MYBITS"
|
|||
|
||||
################################################################################
|
||||
elif [ "$action" == "create" ]; then
|
||||
__runs_setpath
|
||||
if [ -n "$runshost" ]; then
|
||||
__runs_setpath
|
||||
[ -n "${RUNSHOSTSDIRS[*]}" ] || runs_path_required RUNSHOSTSPATH
|
||||
etitle "$runshost" runs_initdir "$runshost" "$create_verbose"
|
||||
fi
|
||||
|
@ -267,9 +299,9 @@ elif [ "$action" == "list" ]; then
|
|||
}
|
||||
|
||||
__runs_setpath
|
||||
[ -n "${RUNSSCRIPTSDIRS[*]}" ] || runs_path_required RUNSSCRIPTSPATH
|
||||
[ -n "${RUNSMODULESDIRS[*]}" ] || runs_path_required RUNSMODULESPATH
|
||||
[ -z "$runshost" -o -n "${RUNSHOSTSDIRS[*]}" ] || runs_path_required RUNSHOSTSPATH
|
||||
[ -n "${RUNSSCRIPTSDIRS[*]}" ] || runs_path_undefined RUNSSCRIPTSPATH
|
||||
[ -n "${RUNSMODULESDIRS[*]}" ] || runs_path_undefined RUNSMODULESPATH
|
||||
[ -z "$runshost" -o -n "${RUNSHOSTSDIRS[*]}" ] || runs_path_undefined RUNSHOSTSPATH
|
||||
|
||||
splithost "$runshost" hostname domain
|
||||
|
||||
|
@ -310,12 +342,27 @@ elif [ "$action" == "list" ]; then
|
|||
|
||||
################################################################################
|
||||
elif [ "$action" == "runs" ]; then
|
||||
if [ -n "${rscripts[*]}" ]; then
|
||||
# sans l'option -f, il faut définir RUNS*PATH
|
||||
__runs_setpath
|
||||
[ -n "${RUNSSCRIPTSDIRS[*]}" ] || runs_path_required RUNSSCRIPTSPATH
|
||||
[ -n "${RUNSMODULESDIRS[*]}" ] || runs_path_required RUNSMODULESPATH
|
||||
[ -z "$runshost" -o -n "${RUNSHOSTSDIRS[*]}" ] || runs_path_required RUNSHOSTSPATH
|
||||
__runs_setpath
|
||||
if [ -z "${rscripts[*]}" -a -z "${recipes[*]}" ]; then
|
||||
# sans les options -f et -r, prendre par défaut le répertoire courant
|
||||
# comme répertoire de script, de module et d'hôtes
|
||||
refix=
|
||||
[ -n "${RUNSSCRIPTSDIRS[*]}" ] || {
|
||||
runs_path_undefined RUNSSCRIPTSPATH
|
||||
setx RUNSSCRIPTSPATH=pwd
|
||||
refix=1
|
||||
}
|
||||
[ -n "${RUNSMODULESDIRS[*]}" ] || {
|
||||
runs_path_undefined RUNSMODULESPATH
|
||||
setx RUNSMODULESPATH=pwd
|
||||
refix=1
|
||||
}
|
||||
[ -z "$runshost" -o -n "${RUNSHOSTSDIRS[*]}" ] || {
|
||||
runs_path_undefined RUNSHOSTSPATH
|
||||
setx RUNSHOSTSPATH=pwd
|
||||
refix=1
|
||||
}
|
||||
[ -n "$refix" ] && __runs_setpath
|
||||
fi
|
||||
|
||||
# initialisation
|
||||
|
|
Loading…
Reference in New Issue