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 ""
|
||||
}
|
||||
|
||||
DEFAULT_ADMIN=supervision-gdrsi@listes.univ-reunion.fr
|
||||
DEFAULT_CERTSDIR=1507-renater
|
||||
DEFAULT_CANAME=1507-DigiCertCA.crt
|
||||
set_defaults apacheconfig
|
||||
|
||||
TEMPLATECTL_NAME=apacheconfig
|
||||
TEMPLATECTL_SRCDIRS=(apacheconfig)
|
||||
TEMPLATECTL_CONFIG="$TEMPLATECTL_NAME"
|
||||
TEMPLATECTL_DEFAULTS=(
|
||||
admin=supervision-gdrsi@listes.univ-reunion.fr
|
||||
certsdir=1507-renater
|
||||
caname=1507-DigiCertCA.crt
|
||||
admin="$DEFAULT_ADMIN"
|
||||
certsdir="$DEFAULT_CERTSDIR"
|
||||
caname="$DEFAULT_CANAME"
|
||||
)
|
||||
TEMPLATECTL_VARS=()
|
||||
|
||||
|
@ -205,13 +210,7 @@ fi
|
|||
__template_set_var sysname "$sysname"
|
||||
__template_set_var sysdist "$sysdist"
|
||||
__template_set_var sysver "$sysver"
|
||||
if check_sysinfos --vars sysname sysdist sysver bits -d debian -v jessie+; then
|
||||
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
|
||||
#check_sysinfos --vars sysname sysdist sysver bits "${templatectl_suffix[@]}
|
||||
|
||||
################################################################################
|
||||
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
|
||||
}
|
||||
|
||||
__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() {
|
||||
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"
|
||||
|
@ -182,17 +193,33 @@ function __apache_autoconf_fillcopy() {
|
|||
# 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
|
||||
# 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 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
|
||||
if quietgrep "@@${var}@@" "$1"; then
|
||||
found=1
|
||||
if quietgrep "@@${var}@@" "$src"; then
|
||||
found_var=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$found" ]; then
|
||||
if [ "$found_var" ]; then
|
||||
sed "$FILLSCRIPT
|
||||
$sedscript" <"$src" >"$FILLTEMP"
|
||||
src="$FILLTEMP"
|
||||
|
@ -272,10 +299,14 @@ function apache_autoconf() {
|
|||
bits="$MYBITS"
|
||||
fi
|
||||
__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"
|
||||
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"
|
||||
fi
|
||||
|
||||
|
@ -347,7 +378,7 @@ function apache_autoconf() {
|
|||
local -a confs
|
||||
local conf
|
||||
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
|
||||
[ -z "$oneconf" -o "$conf" == "$oneconf" ] || continue
|
||||
|
||||
|
@ -364,7 +395,7 @@ function apache_autoconf() {
|
|||
local -a confs
|
||||
local conf
|
||||
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
|
||||
[ -z "$onemodule" -o "$conf" == "$onemodule" ] || continue
|
||||
|
||||
|
@ -397,9 +428,9 @@ function apache_autoconf() {
|
|||
local -a confs
|
||||
local conf confname destconf certsconf
|
||||
etitle "Installation des sites"
|
||||
array_lsfiles confs "$sitesdir" "*.conf"
|
||||
for conf in "${confs[@]}"; do
|
||||
confname="$(basename "$conf")"
|
||||
array_from_lines confs "$(list_files "$sitesdir" "*.conf" | __apache_autoconf_filter_suffix_files)"
|
||||
for confname in "${confs[@]}"; do
|
||||
conf="$sitesdir/$confname"
|
||||
[ -z "$onesite" -o "$confname" == "$onesite" ] || continue
|
||||
|
||||
certsconf=
|
||||
|
@ -411,8 +442,8 @@ function apache_autoconf() {
|
|||
fi
|
||||
fi
|
||||
case "$confname" in
|
||||
default.conf) destconf=default;;
|
||||
default.ssl.conf) destconf=default-ssl;;
|
||||
default.conf) destconf="$confdefault";;
|
||||
default.ssl.conf) destconf="$confdefaultssl";;
|
||||
*) destconf="$confname";;
|
||||
esac
|
||||
|
||||
|
@ -446,12 +477,10 @@ s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
|||
local -a confs
|
||||
local conf
|
||||
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
|
||||
array_contains ignores "$conf" && continue
|
||||
case "$conf" in
|
||||
confs.conf|modules.conf|sites.conf) continue;;
|
||||
esac
|
||||
estep "$conf"
|
||||
__apache_autoconf_fillcopy \
|
||||
"$confdir/$conf" \
|
||||
|
@ -490,7 +519,7 @@ s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
|||
done
|
||||
fi
|
||||
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)"
|
||||
if [ ${#sitesconfs[*]} -gt 0 ]; then
|
||||
# si une configuration existe, ignorer la configuration
|
||||
|
@ -499,14 +528,25 @@ s#@@ca@@#$APACHESSLCERTSDIR/$(basename "$ca")#g
|
|||
disablesites=()
|
||||
for sitesconf in "${sitesconfs[@]}"; do
|
||||
if [ "${sitesconf#+}" != "$sitesconf" ]; then
|
||||
array_del disablesites "${sitesconf#+}"
|
||||
array_add enablesites "${sitesconf#+}"
|
||||
enable=1
|
||||
sitesconf="${sitesconf#+}"
|
||||
elif [ "${sitesconf#-}" != "$sitesconf" ]; then
|
||||
array_del enablesites "${sitesconf#-}"
|
||||
array_add disablesites "${sitesconf#-}"
|
||||
enable=
|
||||
sitesconf="${sitesconf#-}"
|
||||
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_add enablesites "$sitesconf"
|
||||
else
|
||||
array_del enablesites "$sitesconf"
|
||||
array_add disablesites "$sitesconf"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue