support des variables dynamiques
This commit is contained in:
parent
05bebad535
commit
421e42079c
|
@ -323,11 +323,15 @@ if [ -n "$__deploy" ]; then
|
||||||
${__certsconfdir:+--certsconfdir "$__certsconfdir"}
|
${__certsconfdir:+--certsconfdir "$__certsconfdir"}
|
||||||
${__rrdir:+--rrdir "$__rrdir"}
|
${__rrdir:+--rrdir "$__rrdir"}
|
||||||
)
|
)
|
||||||
|
for __name in "${DYNAMIC_VARS[@]}"; do
|
||||||
|
array_add args -v "$__name=${!__name}"
|
||||||
|
done
|
||||||
run_as_root "${args[@]}"
|
run_as_root "${args[@]}"
|
||||||
|
|
||||||
etitle "Mise à jour du système"
|
etitle "Mise à jour du système"
|
||||||
[ -d "$__templatectl_destdir" ] || die "$__templatectl_destdir: répertoire introuvable"
|
[ -d "$__templatectl_destdir" ] || die "$__templatectl_destdir: répertoire introuvable"
|
||||||
args=("$__templatectl_destdir" "$__certsdir"
|
args=(
|
||||||
|
"$__templatectl_destdir" "$__certsdir"
|
||||||
${__confdir:+--confdir "$__confdir"}
|
${__confdir:+--confdir "$__confdir"}
|
||||||
${__modulesdir:+--modulesdir "$__modulesdir"}
|
${__modulesdir:+--modulesdir "$__modulesdir"}
|
||||||
${__sitesdir:+--sitesdir "$__sitesdir"}
|
${__sitesdir:+--sitesdir "$__sitesdir"}
|
||||||
|
@ -336,6 +340,9 @@ if [ -n "$__deploy" ]; then
|
||||||
${__certsconfdir:+--certsconfdir "$__certsconfdir"}
|
${__certsconfdir:+--certsconfdir "$__certsconfdir"}
|
||||||
${__rrdir:+--rrdir "$__rrdir"}
|
${__rrdir:+--rrdir "$__rrdir"}
|
||||||
)
|
)
|
||||||
|
for __name in "${DYNAMIC_VARS[@]}"; do
|
||||||
|
array_add args "$__name=${!__name}"
|
||||||
|
done
|
||||||
apache_autoconf "${args[@]}" || die
|
apache_autoconf "${args[@]}" || die
|
||||||
eend
|
eend
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -155,6 +155,31 @@ OPTIONS
|
||||||
return 0
|
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() {
|
function apache_autoconf() {
|
||||||
eval "$(utools_local)"
|
eval "$(utools_local)"
|
||||||
local autoconfdir certsdir confdir modulesdir sitesdir cgibindir wwwdir certsconfdir rrdir
|
local autoconfdir certsdir confdir modulesdir sitesdir cgibindir wwwdir certsconfdir rrdir
|
||||||
|
@ -177,12 +202,13 @@ function apache_autoconf() {
|
||||||
urequire install
|
urequire install
|
||||||
compute_apache_prefixes
|
compute_apache_prefixes
|
||||||
|
|
||||||
autoconfdir="$1"
|
# Configuration
|
||||||
|
autoconfdir="$1"; shift
|
||||||
[ -n "$autoconfdir" ] || {
|
[ -n "$autoconfdir" ] || {
|
||||||
eerror "Vous devez spécifier le répertoire de base de la configuration apache"
|
eerror "Vous devez spécifier le répertoire de base de la configuration apache"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
certsdir="$2"
|
certsdir="$1"; shift
|
||||||
if [ -z "$confdir" -o -z "$modulesdir" -o -z "$sitesdir" \
|
if [ -z "$confdir" -o -z "$modulesdir" -o -z "$sitesdir" \
|
||||||
-o -z "$cgibindir" -o -z "$wwwdir" -o -z "$certsconfdir" \
|
-o -z "$cgibindir" -o -z "$wwwdir" -o -z "$certsconfdir" \
|
||||||
-o -z "$rrdir" ]; then
|
-o -z "$rrdir" ]; then
|
||||||
|
@ -208,6 +234,21 @@ function apache_autoconf() {
|
||||||
fi
|
fi
|
||||||
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
|
local modified conf
|
||||||
if [ -d "$certsconfdir" ]; then
|
if [ -d "$certsconfdir" ]; then
|
||||||
local -a certsconfs
|
local -a certsconfs
|
||||||
|
@ -222,6 +263,7 @@ function apache_autoconf() {
|
||||||
eend
|
eend
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Configuration des modules
|
||||||
if [ -d "$modulesdir" ]; then
|
if [ -d "$modulesdir" ]; then
|
||||||
local -a confs
|
local -a confs
|
||||||
local conf
|
local conf
|
||||||
|
@ -229,11 +271,14 @@ function apache_autoconf() {
|
||||||
array_from_lines confs "$(list_files "$modulesdir" "*.conf")"
|
array_from_lines confs "$(list_files "$modulesdir" "*.conf")"
|
||||||
for conf in "${confs[@]}"; do
|
for conf in "${confs[@]}"; do
|
||||||
estep "$conf"
|
estep "$conf"
|
||||||
copy_update "$modulesdir/$conf" "$APACHECONFDIR/mods-available/$conf" && modified=1
|
__apache_autoconf_fillcopy \
|
||||||
|
"$modulesdir/$conf" \
|
||||||
|
"$APACHECONFDIR/mods-available/$conf" && modified=1
|
||||||
done
|
done
|
||||||
eend
|
eend
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Règles de réécriture
|
||||||
if [ -d "$rrdir" ]; then
|
if [ -d "$rrdir" ]; then
|
||||||
local -a confs
|
local -a confs
|
||||||
local conf
|
local conf
|
||||||
|
@ -241,15 +286,18 @@ function apache_autoconf() {
|
||||||
array_from_lines confs "$(list_files "$rrdir" "RewriteRules*.conf")"
|
array_from_lines confs "$(list_files "$rrdir" "RewriteRules*.conf")"
|
||||||
for conf in "${confs[@]}"; do
|
for conf in "${confs[@]}"; do
|
||||||
estep "$conf"
|
estep "$conf"
|
||||||
copy_update "$rrdir/$conf" "$APACHECONFDIR/$conf" && modified=1
|
__apache_autoconf_fillcopy \
|
||||||
|
"$rrdir/$conf" \
|
||||||
|
"$APACHECONFDIR/$conf" && modified=1
|
||||||
done
|
done
|
||||||
eend
|
eend
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Sites
|
||||||
local -a enablesites disablesites
|
local -a enablesites disablesites
|
||||||
if [ -d "$sitesdir" ]; then
|
if [ -d "$sitesdir" ]; then
|
||||||
local -a confs
|
local -a confs
|
||||||
local conf confname destconf certsconf tmpconf
|
local conf confname destconf certsconf
|
||||||
etitle "Installation des sites"
|
etitle "Installation des sites"
|
||||||
array_lsfiles confs "$sitesdir" "*.conf"
|
array_lsfiles confs "$sitesdir" "*.conf"
|
||||||
for conf in "${confs[@]}"; do
|
for conf in "${confs[@]}"; do
|
||||||
|
@ -272,24 +320,28 @@ function apache_autoconf() {
|
||||||
certsconf="$certsconfdir/$certsconf"
|
certsconf="$certsconfdir/$certsconf"
|
||||||
if [ -f "$certsconf" ]; then
|
if [ -f "$certsconf" ]; then
|
||||||
apache_resolvecert "$certsconf" "$certsdir" cert key ca || return 1
|
apache_resolvecert "$certsconf" "$certsdir" cert key ca || return 1
|
||||||
ac_set_tmpfile tmpconf
|
__apache_autoconf_fillcopy \
|
||||||
sed "\
|
"$conf" \
|
||||||
|
"$APACHEAVSITESDIR/$destconf" "\
|
||||||
s#@@cert@@#$APACHESSLCERTSDIR/$(basename "$cert")#g
|
s#@@cert@@#$APACHESSLCERTSDIR/$(basename "$cert")#g
|
||||||
s#@@key@@#$APACHESSLKEYSDIR/$(basename "$key")#g
|
s#@@key@@#$APACHESSLKEYSDIR/$(basename "$key")#g
|
||||||
s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
||||||
" <"$conf" >"$tmpconf"
|
"
|
||||||
copy_update "$tmpconf" "$APACHEAVSITESDIR/$destconf"
|
|
||||||
else
|
else
|
||||||
eerror "$(ppath "$certsconf"): fichier introuvable. Il a été ignoré"
|
eerror "$(ppath "$certsconf"): fichier introuvable. Il a été ignoré"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
copy_update "$conf" "$APACHEAVSITESDIR/$destconf"
|
__apache_autoconf_fillcopy \
|
||||||
|
"$conf" \
|
||||||
|
"$APACHEAVSITESDIR/$destconf"
|
||||||
fi
|
fi
|
||||||
enablesites=("${enablesites[@]}" "$destconf")
|
enablesites=("${enablesites[@]}" "$destconf")
|
||||||
modified=1
|
modified=1
|
||||||
done
|
done
|
||||||
eend
|
eend
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Fichiers de configuration
|
||||||
if [ -d "$confdir" ]; then
|
if [ -d "$confdir" ]; then
|
||||||
local -a confs
|
local -a confs
|
||||||
local conf
|
local conf
|
||||||
|
@ -300,7 +352,9 @@ s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
||||||
modules.conf|sites.conf) continue;;
|
modules.conf|sites.conf) continue;;
|
||||||
esac
|
esac
|
||||||
estep "$conf"
|
estep "$conf"
|
||||||
copy_update "$confdir/$conf" "$APACHECONFDIR/$conf" && modified=1
|
__apache_autoconf_fillcopy \
|
||||||
|
"$confdir/$conf" \
|
||||||
|
"$APACHECONFDIR/$conf" && modified=1
|
||||||
done
|
done
|
||||||
if [ -f "$confdir/modules.conf" ]; then
|
if [ -f "$confdir/modules.conf" ]; then
|
||||||
local -a modules
|
local -a modules
|
||||||
|
@ -346,17 +400,24 @@ s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
||||||
fi
|
fi
|
||||||
eend
|
eend
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Scripts CGI
|
||||||
if [ -d "$cgibindir" ]; then
|
if [ -d "$cgibindir" ]; then
|
||||||
etitle "Installation des scripts CGI"
|
etitle "Installation des scripts CGI"
|
||||||
cpdirnovcs "$cgibindir" "$CGIBINDIR"
|
cpdirnovcs "$cgibindir" "$CGIBINDIR"
|
||||||
eend
|
eend
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Contenu web
|
||||||
if [ -d "$wwwdir" ]; then
|
if [ -d "$wwwdir" ]; then
|
||||||
etitle "Installation des fichiers du serveur web"
|
etitle "Installation des fichiers du serveur web"
|
||||||
cpdirnovcs "$wwwdir" "$HTDOCSDIR"
|
cpdirnovcs "$wwwdir" "$HTDOCSDIR"
|
||||||
eend
|
eend
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Nettoyer le fichier temporaire
|
||||||
|
ac_clean "$FILLTEMP"
|
||||||
|
|
||||||
if [ -n "${enablesites[*]}" -o -n "${disablesites[*]}" ]; then
|
if [ -n "${enablesites[*]}" -o -n "${disablesites[*]}" ]; then
|
||||||
etitle "(dés)Activation des sites"
|
etitle "(dés)Activation des sites"
|
||||||
local site
|
local site
|
||||||
|
|
Loading…
Reference in New Issue