valeur par défaut de host
This commit is contained in:
parent
16f5486157
commit
9fdb0d1d4c
22
apacheconfig
22
apacheconfig
|
@ -127,12 +127,9 @@ OPTIONS AVANCEES
|
||||||
function __templatectl_display_help() { display_help; }
|
function __templatectl_display_help() { display_help; }
|
||||||
|
|
||||||
# Valeurs par défaut des variables de template
|
# Valeurs par défaut des variables de template
|
||||||
setx host=myhost
|
|
||||||
hostname="${host%%.*}"
|
|
||||||
DEFAULT_TEMPLATE_VARS=(
|
DEFAULT_TEMPLATE_VARS=(
|
||||||
host="$host"
|
hostname= aliases= # mettre ces variables AVANT host
|
||||||
hostname="$hostname"
|
host=
|
||||||
aliases="$hostname"
|
|
||||||
admin=supervision-gdrsi@listes.univ-reunion.fr
|
admin=supervision-gdrsi@listes.univ-reunion.fr
|
||||||
certsdir=renater
|
certsdir=renater
|
||||||
caname=terena.crt
|
caname=terena.crt
|
||||||
|
@ -170,14 +167,23 @@ function update_var() {
|
||||||
# hostname.
|
# hostname.
|
||||||
local __orig_value="${!1}"
|
local __orig_value="${!1}"
|
||||||
array_contains DYNAMIC_VARS "$1" || array_addu TEMPLATE_VARS "$1"
|
array_contains DYNAMIC_VARS "$1" || array_addu TEMPLATE_VARS "$1"
|
||||||
|
|
||||||
|
# Valeurs par défaut
|
||||||
|
case "$1" in
|
||||||
|
host) [ -n "$2" ] || set -- "$1" "$(myhost)";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Mettre à jour la variable
|
||||||
setv "$1" "$2"
|
setv "$1" "$2"
|
||||||
|
|
||||||
|
# Mettre à jour des variables dépendantes
|
||||||
local __update_aliases
|
local __update_aliases
|
||||||
case "$1" in
|
case "$1" in
|
||||||
host)
|
host)
|
||||||
|
# attention à ne pas créer de boucle infinies :-)
|
||||||
[ "$aliases" == "$hostname" ] && __update_aliases=1
|
[ "$aliases" == "$hostname" ] && __update_aliases=1
|
||||||
hostname="${host%%.*}"
|
update_var hostname "${host%%.*}"
|
||||||
[ -n "$__update_aliases" ] && aliases="$hostname"
|
[ -n "$__update_aliases" ] && update_var aliases "$hostname"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -268,7 +274,7 @@ if [ -n "$__write_vars" ]; then
|
||||||
[ -f "$__apacheconfig_vars" ] &&
|
[ -f "$__apacheconfig_vars" ] &&
|
||||||
die "Refus d'écraser le fichier existant $(ppath "$__apacheconfig_vars")"
|
die "Refus d'écraser le fichier existant $(ppath "$__apacheconfig_vars")"
|
||||||
|
|
||||||
>"$__apacheconfig_vars"
|
echo "# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8" >"$__apacheconfig_vars"
|
||||||
echo "__template_vars=(" >>"$__apacheconfig_vars"
|
echo "__template_vars=(" >>"$__apacheconfig_vars"
|
||||||
for __var in "${TEMPLATE_VARS[@]}"; do
|
for __var in "${TEMPLATE_VARS[@]}"; do
|
||||||
echo_setv "$__var=${!__var}" >>"$__apacheconfig_vars"
|
echo_setv "$__var=${!__var}" >>"$__apacheconfig_vars"
|
||||||
|
|
37
runsconfig
37
runsconfig
|
@ -50,34 +50,33 @@ function __templatectl_display_help() { display_help; }
|
||||||
set_defaults runs
|
set_defaults runs
|
||||||
|
|
||||||
# essayer de déterminer l'hôte à partir du répertoire courant
|
# essayer de déterminer l'hôte à partir du répertoire courant
|
||||||
host=
|
DEFAULT_HOST=
|
||||||
array_split __hostsdirs "$RUNSHOSTSPATH" :
|
array_split __hostsdirs "$RUNSHOSTSPATH" :
|
||||||
setx __cwd=pwd
|
setx __cwd=pwd
|
||||||
for __hostsdir in "${__hostsdirs[@]}"; do
|
for __hostsdir in "${__hostsdirs[@]}"; do
|
||||||
setx __hostsdir=abspath "$__hostsdir"
|
setx __hostsdir=abspath "$__hostsdir"
|
||||||
if [ "${__cwd#$__hostsdir/}" != "$__cwd" ]; then
|
if [ "${__cwd#$__hostsdir/}" != "$__cwd" ]; then
|
||||||
host="${__cwd#$__hostsdir/}"
|
DEFAULT_HOST="${__cwd#$__hostsdir/}"
|
||||||
host="${host%%/*}"
|
DEFAULT_HOST="${DEFAULT_HOST%%/*}"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# sinon lire l'environnement
|
# sinon lire l'environnement
|
||||||
if [ -z "$host" ]; then
|
if [ -z "$DEFAULT_HOST" ]; then
|
||||||
runs_initdomains
|
runs_initdomains
|
||||||
setx host=myhost
|
setx DEFAULT_HOST=myhost
|
||||||
splithost "$host" hostname domain
|
splithost "$DEFAULT_HOST" __hostname __domain
|
||||||
if [ -z "$domain" ]; then
|
if [ -z "$__domain" ]; then
|
||||||
host="$(runs_find_host "$host")"
|
DEFAULT_HOST="$(runs_find_host "$DEFAULT_HOST")"
|
||||||
splithost "$host" hostname domain
|
splithost "$DEFAULT_HOST" __hostname __domain
|
||||||
fi
|
fi
|
||||||
[ -n "$domain" ] || host="$(runs_add_domain "$host")"
|
[ -n "$__domain" ] || DEFAULT_HOST="$(runs_add_domain "$DEFAULT_HOST")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
hostname="${host%%.*}"
|
|
||||||
DEFAULT_TEMPLATE_VARS=(
|
DEFAULT_TEMPLATE_VARS=(
|
||||||
host="$host"
|
hostname= # mettre cette variables AVANT host
|
||||||
hostname="$hostname"
|
host=
|
||||||
)
|
)
|
||||||
|
|
||||||
TEMPLATE_VARS=()
|
TEMPLATE_VARS=()
|
||||||
|
@ -87,10 +86,18 @@ function update_var() {
|
||||||
# hostname.
|
# hostname.
|
||||||
local __orig_value="${!1}"
|
local __orig_value="${!1}"
|
||||||
array_addu TEMPLATE_VARS "$1"
|
array_addu TEMPLATE_VARS "$1"
|
||||||
|
|
||||||
|
# Valeurs par défaut
|
||||||
|
case "$1" in
|
||||||
|
host) [ -n "$2" ] || set -- "$1" "$(myhost)";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Mettre à jour la variable
|
||||||
setv "$1" "$2"
|
setv "$1" "$2"
|
||||||
|
|
||||||
|
# Mettre à jour des variables dépendantes
|
||||||
case "$1" in
|
case "$1" in
|
||||||
host) hostname="${host%%.*}";;
|
host) update_var hostname "${host%%.*}";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[ "$2" != "$__orig_value" ]
|
[ "$2" != "$__orig_value" ]
|
||||||
|
@ -137,7 +144,7 @@ if [ -n "$__write_vars" ]; then
|
||||||
[ -f "$__runsconfig_vars" ] &&
|
[ -f "$__runsconfig_vars" ] &&
|
||||||
die "Refus d'écraser le fichier existant $(ppath "$__runsconfig_vars")"
|
die "Refus d'écraser le fichier existant $(ppath "$__runsconfig_vars")"
|
||||||
|
|
||||||
>"$__runsconfig_vars"
|
echo "# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8" >"$__runsconfig_vars"
|
||||||
echo "__template_vars=(" >>"$__runsconfig_vars"
|
echo "__template_vars=(" >>"$__runsconfig_vars"
|
||||||
for __var in "${TEMPLATE_VARS[@]}"; do
|
for __var in "${TEMPLATE_VARS[@]}"; do
|
||||||
echo_setv "$__var=${!__var}" >>"$__runsconfig_vars"
|
echo_setv "$__var=${!__var}" >>"$__runsconfig_vars"
|
||||||
|
|
Loading…
Reference in New Issue