apacheconfig: déploiement pour plusieurs systèmes à partir des mêmes sources
This commit is contained in:
parent
2d45f23bc9
commit
eb4362dd5a
19
apacheconfig
19
apacheconfig
|
@ -139,13 +139,18 @@ function __template_updatef_dhost() {
|
||||||
[ -n "$ips" ] || __template_set_var ips ""
|
[ -n "$ips" ] || __template_set_var ips ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFAULT_ADMIN=supervision-gdrsi@listes.univ-reunion.fr
|
||||||
|
DEFAULT_CERTSDIR=1507-renater
|
||||||
|
DEFAULT_CANAME=1507-DigiCertCA.crt
|
||||||
|
set_defaults apacheconfig
|
||||||
|
|
||||||
TEMPLATECTL_NAME=apacheconfig
|
TEMPLATECTL_NAME=apacheconfig
|
||||||
TEMPLATECTL_SRCDIRS=(apacheconfig)
|
TEMPLATECTL_SRCDIRS=(apacheconfig)
|
||||||
TEMPLATECTL_CONFIG="$TEMPLATECTL_NAME"
|
TEMPLATECTL_CONFIG="$TEMPLATECTL_NAME"
|
||||||
TEMPLATECTL_DEFAULTS=(
|
TEMPLATECTL_DEFAULTS=(
|
||||||
admin=supervision-gdrsi@listes.univ-reunion.fr
|
admin="$DEFAULT_ADMIN"
|
||||||
certsdir=1507-renater
|
certsdir="$DEFAULT_CERTSDIR"
|
||||||
caname=1507-DigiCertCA.crt
|
caname="$DEFAULT_CANAME"
|
||||||
)
|
)
|
||||||
TEMPLATECTL_VARS=()
|
TEMPLATECTL_VARS=()
|
||||||
|
|
||||||
|
@ -205,13 +210,7 @@ fi
|
||||||
__template_set_var sysname "$sysname"
|
__template_set_var sysname "$sysname"
|
||||||
__template_set_var sysdist "$sysdist"
|
__template_set_var sysdist "$sysdist"
|
||||||
__template_set_var sysver "$sysver"
|
__template_set_var sysver "$sysver"
|
||||||
if check_sysinfos --vars sysname sysdist sysver bits -d debian -v jessie+; then
|
#check_sysinfos --vars sysname sysdist sysver bits "${templatectl_suffix[@]}
|
||||||
array_add TEMPLATECTL_SRCDIRS apacheconfig8
|
|
||||||
elif check_sysinfos --vars sysname sysdist sysver bits -d debian; then
|
|
||||||
array_add TEMPLATECTL_SRCDIRS apacheconfig7
|
|
||||||
else
|
|
||||||
ewarn "$(get_sysinfos_desc sysname sysdist sysver): système non supporté pour le déploiement"
|
|
||||||
fi
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
if [ "$action" == create ]; then
|
if [ "$action" == create ]; then
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||||
|
# Valeurs par défaut du template apacheconfig
|
||||||
|
|
||||||
|
#DEFAULT_ADMIN=supervision-gdrsi@listes.univ-reunion.fr
|
||||||
|
#DEFAULT_CERTSDIR=1507-renater
|
||||||
|
#DEFAULT_CANAME=1507-DigiCertCA.crt
|
|
@ -155,6 +155,17 @@ OPTIONS
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__APACHE_AUTOCONF_SUFFIXES=(d8 d)
|
||||||
|
__APACHE_AUTOCONF_SUFFIX_d8=(-d debian -v jessie+)
|
||||||
|
__APACHE_AUTOCONF_SUFFIX_d=(-d debian)
|
||||||
|
function __apache_autoconf_check_suffix() {
|
||||||
|
array_contains __APACHE_AUTOCONF_SUFFIXES "$1" || return 1
|
||||||
|
local sysinfos="__APACHE_AUTOCONF_SUFFIX_${1}[@]"
|
||||||
|
check_sysinfos --vars sysname sysdist sysver bits "${!sysinfos}"
|
||||||
|
}
|
||||||
|
function __apache_autoconf_filter_suffix_files() {
|
||||||
|
grep -vF ..
|
||||||
|
}
|
||||||
function __apache_autoconf_setup() {
|
function __apache_autoconf_setup() {
|
||||||
if ! check_sysinfos --vars sysname sysdist sysver bits -s linux64 linux32 linux -d debian; then
|
if ! check_sysinfos --vars sysname sysdist sysver bits -s linux64 linux32 linux -d debian; then
|
||||||
eerror "apache_autoconf n'est supporté que sur Debian linux"
|
eerror "apache_autoconf n'est supporté que sur Debian linux"
|
||||||
|
@ -182,17 +193,33 @@ function __apache_autoconf_fillcopy() {
|
||||||
# script sed $FILLSCRIPT. Le fichier temporaire $FILLTEMP est utilisé pour
|
# script sed $FILLSCRIPT. Le fichier temporaire $FILLTEMP est utilisé pour
|
||||||
# le remplacement des valeurs. $3 contient le cas échéant des commandes sed
|
# le remplacement des valeurs. $3 contient le cas échéant des commandes sed
|
||||||
# supplémentaires
|
# supplémentaires
|
||||||
|
# Si des fichiers suffixes existent, ne faire la copie que si un fichier
|
||||||
|
# approprié correspondant au système courant est trouvé
|
||||||
local src="$1" dest="$2" sedscript="$3" perms="${4:-go+rX}"
|
local src="$1" dest="$2" sedscript="$3" perms="${4:-go+rX}"
|
||||||
|
|
||||||
local var found
|
# vérifier les fichiers suffixe
|
||||||
|
local suffix have_suffix found_suffix
|
||||||
|
for suffix in "${__APACHE_AUTOCONF_SUFFIXES[@]}"; do
|
||||||
|
if [ -f "$src..$suffix" ]; then
|
||||||
|
have_suffix=1
|
||||||
|
if __apache_autoconf_check_suffix "$suffix"; then
|
||||||
|
found_suffix=1
|
||||||
|
src="$src..$suffix"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[ -n "$have_suffix" -a -z "$found_suffix" ] && return 1
|
||||||
|
|
||||||
|
# valeurs à remplacer dans le fichier
|
||||||
|
local var found_var
|
||||||
for var in "${FILLVARS[@]}"; do
|
for var in "${FILLVARS[@]}"; do
|
||||||
if quietgrep "@@${var}@@" "$1"; then
|
if quietgrep "@@${var}@@" "$src"; then
|
||||||
found=1
|
found_var=1
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [ "$found_var" ]; then
|
||||||
if [ "$found" ]; then
|
|
||||||
sed "$FILLSCRIPT
|
sed "$FILLSCRIPT
|
||||||
$sedscript" <"$src" >"$FILLTEMP"
|
$sedscript" <"$src" >"$FILLTEMP"
|
||||||
src="$FILLTEMP"
|
src="$FILLTEMP"
|
||||||
|
@ -272,10 +299,14 @@ function apache_autoconf() {
|
||||||
bits="$MYBITS"
|
bits="$MYBITS"
|
||||||
fi
|
fi
|
||||||
__apache_autoconf_setup || return 1
|
__apache_autoconf_setup || return 1
|
||||||
if check_sysinfos --vars sysname sysdist sysver bits -d debian -v jessie+; then
|
if __apache_autoconf_check_suffix d8; then
|
||||||
|
confdefault=000-default.conf
|
||||||
|
confdefaultssl=default-ssl.conf
|
||||||
destconfsdir="$APACHECONFDIR/conf-available"
|
destconfsdir="$APACHECONFDIR/conf-available"
|
||||||
a2xconf=1
|
a2xconf=1
|
||||||
elif check_sysinfos --vars sysname sysdist sysver bits -d debian; then
|
elif __apache_autoconf_check_suffix d; then
|
||||||
|
confdefault=default
|
||||||
|
confdefaultssl=default-ssl
|
||||||
destconfsdir="$APACHECONFDIR/conf.d"
|
destconfsdir="$APACHECONFDIR/conf.d"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -347,7 +378,7 @@ function apache_autoconf() {
|
||||||
local -a confs
|
local -a confs
|
||||||
local conf
|
local conf
|
||||||
etitle "Installation des configurations"
|
etitle "Installation des configurations"
|
||||||
array_from_lines confs "$(list_files "$confsdir" "*.conf")"
|
array_from_lines confs "$(list_files "$confsdir" "*.conf" | __apache_autoconf_filter_suffix_files)"
|
||||||
for conf in "${confs[@]}"; do
|
for conf in "${confs[@]}"; do
|
||||||
[ -z "$oneconf" -o "$conf" == "$oneconf" ] || continue
|
[ -z "$oneconf" -o "$conf" == "$oneconf" ] || continue
|
||||||
|
|
||||||
|
@ -364,7 +395,7 @@ function apache_autoconf() {
|
||||||
local -a confs
|
local -a confs
|
||||||
local conf
|
local conf
|
||||||
etitle "Installation des configurations des modules"
|
etitle "Installation des configurations des modules"
|
||||||
array_from_lines confs "$(list_files "$modulesdir" "*.conf")"
|
array_from_lines confs "$(list_files "$modulesdir" "*.conf" | __apache_autoconf_filter_suffix_files)"
|
||||||
for conf in "${confs[@]}"; do
|
for conf in "${confs[@]}"; do
|
||||||
[ -z "$onemodule" -o "$conf" == "$onemodule" ] || continue
|
[ -z "$onemodule" -o "$conf" == "$onemodule" ] || continue
|
||||||
|
|
||||||
|
@ -397,9 +428,9 @@ function apache_autoconf() {
|
||||||
local -a confs
|
local -a confs
|
||||||
local conf confname destconf certsconf
|
local conf confname destconf certsconf
|
||||||
etitle "Installation des sites"
|
etitle "Installation des sites"
|
||||||
array_lsfiles confs "$sitesdir" "*.conf"
|
array_from_lines confs "$(list_files "$sitesdir" "*.conf" | __apache_autoconf_filter_suffix_files)"
|
||||||
for conf in "${confs[@]}"; do
|
for confname in "${confs[@]}"; do
|
||||||
confname="$(basename "$conf")"
|
conf="$sitesdir/$confname"
|
||||||
[ -z "$onesite" -o "$confname" == "$onesite" ] || continue
|
[ -z "$onesite" -o "$confname" == "$onesite" ] || continue
|
||||||
|
|
||||||
certsconf=
|
certsconf=
|
||||||
|
@ -411,8 +442,8 @@ function apache_autoconf() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
case "$confname" in
|
case "$confname" in
|
||||||
default.conf) destconf=default;;
|
default.conf) destconf="$confdefault";;
|
||||||
default.ssl.conf) destconf=default-ssl;;
|
default.ssl.conf) destconf="$confdefaultssl";;
|
||||||
*) destconf="$confname";;
|
*) destconf="$confname";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -446,12 +477,10 @@ s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
||||||
local -a confs
|
local -a confs
|
||||||
local conf
|
local conf
|
||||||
etitle "Configuration de base"
|
etitle "Configuration de base"
|
||||||
array_from_lines confs "$(list_files "$confdir")"
|
array_add ignores confs.conf modules.conf sites.conf
|
||||||
|
array_from_lines confs "$(list_files "$confdir" | __apache_autoconf_filter_suffix_files)"
|
||||||
for conf in "${confs[@]}"; do
|
for conf in "${confs[@]}"; do
|
||||||
array_contains ignores "$conf" && continue
|
array_contains ignores "$conf" && continue
|
||||||
case "$conf" in
|
|
||||||
confs.conf|modules.conf|sites.conf) continue;;
|
|
||||||
esac
|
|
||||||
estep "$conf"
|
estep "$conf"
|
||||||
__apache_autoconf_fillcopy \
|
__apache_autoconf_fillcopy \
|
||||||
"$confdir/$conf" \
|
"$confdir/$conf" \
|
||||||
|
@ -490,7 +519,7 @@ s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [ -f "$confdir/sites.conf" ]; then
|
if [ -f "$confdir/sites.conf" ]; then
|
||||||
local -a sitesconfs; local sitesconf
|
local -a sitesconfs; local sitesconf enable
|
||||||
array_from_lines sitesconfs "$(<"$confdir/sites.conf" filter_conf)"
|
array_from_lines sitesconfs "$(<"$confdir/sites.conf" filter_conf)"
|
||||||
if [ ${#sitesconfs[*]} -gt 0 ]; then
|
if [ ${#sitesconfs[*]} -gt 0 ]; then
|
||||||
# si une configuration existe, ignorer la configuration
|
# si une configuration existe, ignorer la configuration
|
||||||
|
@ -499,14 +528,25 @@ s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
||||||
disablesites=()
|
disablesites=()
|
||||||
for sitesconf in "${sitesconfs[@]}"; do
|
for sitesconf in "${sitesconfs[@]}"; do
|
||||||
if [ "${sitesconf#+}" != "$sitesconf" ]; then
|
if [ "${sitesconf#+}" != "$sitesconf" ]; then
|
||||||
array_del disablesites "${sitesconf#+}"
|
enable=1
|
||||||
array_add enablesites "${sitesconf#+}"
|
sitesconf="${sitesconf#+}"
|
||||||
elif [ "${sitesconf#-}" != "$sitesconf" ]; then
|
elif [ "${sitesconf#-}" != "$sitesconf" ]; then
|
||||||
array_del enablesites "${sitesconf#-}"
|
enable=
|
||||||
array_add disablesites "${sitesconf#-}"
|
sitesconf="${sitesconf#-}"
|
||||||
else
|
else
|
||||||
|
enable=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$sitesconf" in
|
||||||
|
default.conf) sitesconf="$confdefault";;
|
||||||
|
default.ssl.conf) sitesconf="$confdefaultssl";;
|
||||||
|
esac
|
||||||
|
if [ -n "$enable" ]; then
|
||||||
array_del disablesites "$sitesconf"
|
array_del disablesites "$sitesconf"
|
||||||
array_add enablesites "$sitesconf"
|
array_add enablesites "$sitesconf"
|
||||||
|
else
|
||||||
|
array_del enablesites "$sitesconf"
|
||||||
|
array_add disablesites "$sitesconf"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue