support des variables dynamiques
This commit is contained in:
parent
05bebad535
commit
421e42079c
|
@ -323,11 +323,15 @@ if [ -n "$__deploy" ]; then
|
|||
${__certsconfdir:+--certsconfdir "$__certsconfdir"}
|
||||
${__rrdir:+--rrdir "$__rrdir"}
|
||||
)
|
||||
for __name in "${DYNAMIC_VARS[@]}"; do
|
||||
array_add args -v "$__name=${!__name}"
|
||||
done
|
||||
run_as_root "${args[@]}"
|
||||
|
||||
etitle "Mise à jour du système"
|
||||
[ -d "$__templatectl_destdir" ] || die "$__templatectl_destdir: répertoire introuvable"
|
||||
args=("$__templatectl_destdir" "$__certsdir"
|
||||
args=(
|
||||
"$__templatectl_destdir" "$__certsdir"
|
||||
${__confdir:+--confdir "$__confdir"}
|
||||
${__modulesdir:+--modulesdir "$__modulesdir"}
|
||||
${__sitesdir:+--sitesdir "$__sitesdir"}
|
||||
|
@ -336,6 +340,9 @@ if [ -n "$__deploy" ]; then
|
|||
${__certsconfdir:+--certsconfdir "$__certsconfdir"}
|
||||
${__rrdir:+--rrdir "$__rrdir"}
|
||||
)
|
||||
for __name in "${DYNAMIC_VARS[@]}"; do
|
||||
array_add args "$__name=${!__name}"
|
||||
done
|
||||
apache_autoconf "${args[@]}" || die
|
||||
eend
|
||||
fi
|
||||
|
|
|
@ -155,6 +155,31 @@ OPTIONS
|
|||
return 0
|
||||
}
|
||||
|
||||
function __apache_autoconf_fillcopy() {
|
||||
# copier le fichier $1 vers le fichier $2. Si le fichier $1 contient l'une
|
||||
# des variables du tableau $FILLVARS, corriger d'abord le fichier avec le
|
||||
# script sed $FILLSCRIPT. Le fichier temporaire $FILLTEMP est utilisé pour
|
||||
# le remplacement des valeurs. $3 contient le cas échéant des commandes sed
|
||||
# supplémentaires
|
||||
local src="$1" dest="$2"
|
||||
|
||||
local var found
|
||||
for var in "${FILLVARS[@]}"; do
|
||||
if quietgrep "@@${var}@@" "$1"; then
|
||||
found=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$found" ]; then
|
||||
sed "$FILLSCRIPT
|
||||
$3" <"$src" >"$FILLTEMP"
|
||||
src="$FILLTEMP"
|
||||
fi
|
||||
|
||||
copy_update "$src" "$dest"
|
||||
}
|
||||
|
||||
function apache_autoconf() {
|
||||
eval "$(utools_local)"
|
||||
local autoconfdir certsdir confdir modulesdir sitesdir cgibindir wwwdir certsconfdir rrdir
|
||||
|
@ -177,12 +202,13 @@ function apache_autoconf() {
|
|||
urequire install
|
||||
compute_apache_prefixes
|
||||
|
||||
autoconfdir="$1"
|
||||
# Configuration
|
||||
autoconfdir="$1"; shift
|
||||
[ -n "$autoconfdir" ] || {
|
||||
eerror "Vous devez spécifier le répertoire de base de la configuration apache"
|
||||
return 1
|
||||
}
|
||||
certsdir="$2"
|
||||
certsdir="$1"; shift
|
||||
if [ -z "$confdir" -o -z "$modulesdir" -o -z "$sitesdir" \
|
||||
-o -z "$cgibindir" -o -z "$wwwdir" -o -z "$certsconfdir" \
|
||||
-o -z "$rrdir" ]; then
|
||||
|
@ -208,6 +234,21 @@ function apache_autoconf() {
|
|||
fi
|
||||
fi
|
||||
|
||||
# Faire un script sed pour remplacer les variables spécifiées par leur
|
||||
# valeur dans les fichiers
|
||||
local -a FILLVARS; local FILLSCRIPT FILLTEMP
|
||||
local var name value first=1
|
||||
for var in "$@"; do
|
||||
splitvar "$var" name value
|
||||
array_addu FILLVARS "$name"
|
||||
[ -n "$first" ] || FILLSCRIPT="$FILLSCRIPT"$'\n'
|
||||
FILLSCRIPT="${FILLSCRIPT}s/@@${name}@@/$(qseds "${value}")/g"
|
||||
first=
|
||||
done
|
||||
# Il faut un fichier temporaire pour les remplacement de fichiers
|
||||
ac_set_tmpfile FILLTEMP
|
||||
|
||||
# Copie des certificats
|
||||
local modified conf
|
||||
if [ -d "$certsconfdir" ]; then
|
||||
local -a certsconfs
|
||||
|
@ -222,6 +263,7 @@ function apache_autoconf() {
|
|||
eend
|
||||
fi
|
||||
|
||||
# Configuration des modules
|
||||
if [ -d "$modulesdir" ]; then
|
||||
local -a confs
|
||||
local conf
|
||||
|
@ -229,11 +271,14 @@ function apache_autoconf() {
|
|||
array_from_lines confs "$(list_files "$modulesdir" "*.conf")"
|
||||
for conf in "${confs[@]}"; do
|
||||
estep "$conf"
|
||||
copy_update "$modulesdir/$conf" "$APACHECONFDIR/mods-available/$conf" && modified=1
|
||||
__apache_autoconf_fillcopy \
|
||||
"$modulesdir/$conf" \
|
||||
"$APACHECONFDIR/mods-available/$conf" && modified=1
|
||||
done
|
||||
eend
|
||||
fi
|
||||
|
||||
# Règles de réécriture
|
||||
if [ -d "$rrdir" ]; then
|
||||
local -a confs
|
||||
local conf
|
||||
|
@ -241,15 +286,18 @@ function apache_autoconf() {
|
|||
array_from_lines confs "$(list_files "$rrdir" "RewriteRules*.conf")"
|
||||
for conf in "${confs[@]}"; do
|
||||
estep "$conf"
|
||||
copy_update "$rrdir/$conf" "$APACHECONFDIR/$conf" && modified=1
|
||||
__apache_autoconf_fillcopy \
|
||||
"$rrdir/$conf" \
|
||||
"$APACHECONFDIR/$conf" && modified=1
|
||||
done
|
||||
eend
|
||||
fi
|
||||
|
||||
# Sites
|
||||
local -a enablesites disablesites
|
||||
if [ -d "$sitesdir" ]; then
|
||||
local -a confs
|
||||
local conf confname destconf certsconf tmpconf
|
||||
local conf confname destconf certsconf
|
||||
etitle "Installation des sites"
|
||||
array_lsfiles confs "$sitesdir" "*.conf"
|
||||
for conf in "${confs[@]}"; do
|
||||
|
@ -272,24 +320,28 @@ function apache_autoconf() {
|
|||
certsconf="$certsconfdir/$certsconf"
|
||||
if [ -f "$certsconf" ]; then
|
||||
apache_resolvecert "$certsconf" "$certsdir" cert key ca || return 1
|
||||
ac_set_tmpfile tmpconf
|
||||
sed "\
|
||||
__apache_autoconf_fillcopy \
|
||||
"$conf" \
|
||||
"$APACHEAVSITESDIR/$destconf" "\
|
||||
s#@@cert@@#$APACHESSLCERTSDIR/$(basename "$cert")#g
|
||||
s#@@key@@#$APACHESSLKEYSDIR/$(basename "$key")#g
|
||||
s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
||||
" <"$conf" >"$tmpconf"
|
||||
copy_update "$tmpconf" "$APACHEAVSITESDIR/$destconf"
|
||||
"
|
||||
else
|
||||
eerror "$(ppath "$certsconf"): fichier introuvable. Il a été ignoré"
|
||||
fi
|
||||
else
|
||||
copy_update "$conf" "$APACHEAVSITESDIR/$destconf"
|
||||
__apache_autoconf_fillcopy \
|
||||
"$conf" \
|
||||
"$APACHEAVSITESDIR/$destconf"
|
||||
fi
|
||||
enablesites=("${enablesites[@]}" "$destconf")
|
||||
modified=1
|
||||
done
|
||||
eend
|
||||
fi
|
||||
|
||||
# Fichiers de configuration
|
||||
if [ -d "$confdir" ]; then
|
||||
local -a confs
|
||||
local conf
|
||||
|
@ -300,7 +352,9 @@ s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
|||
modules.conf|sites.conf) continue;;
|
||||
esac
|
||||
estep "$conf"
|
||||
copy_update "$confdir/$conf" "$APACHECONFDIR/$conf" && modified=1
|
||||
__apache_autoconf_fillcopy \
|
||||
"$confdir/$conf" \
|
||||
"$APACHECONFDIR/$conf" && modified=1
|
||||
done
|
||||
if [ -f "$confdir/modules.conf" ]; then
|
||||
local -a modules
|
||||
|
@ -346,17 +400,24 @@ s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
|||
fi
|
||||
eend
|
||||
fi
|
||||
|
||||
# Scripts CGI
|
||||
if [ -d "$cgibindir" ]; then
|
||||
etitle "Installation des scripts CGI"
|
||||
cpdirnovcs "$cgibindir" "$CGIBINDIR"
|
||||
eend
|
||||
fi
|
||||
|
||||
# Contenu web
|
||||
if [ -d "$wwwdir" ]; then
|
||||
etitle "Installation des fichiers du serveur web"
|
||||
cpdirnovcs "$wwwdir" "$HTDOCSDIR"
|
||||
eend
|
||||
fi
|
||||
|
||||
# Nettoyer le fichier temporaire
|
||||
ac_clean "$FILLTEMP"
|
||||
|
||||
if [ -n "${enablesites[*]}" -o -n "${disablesites[*]}" ]; then
|
||||
etitle "(dés)Activation des sites"
|
||||
local site
|
||||
|
|
Loading…
Reference in New Issue