Intégration de la branche release-5.1.0
This commit is contained in:
commit
350c234ef5
|
@ -1,3 +1,9 @@
|
|||
## Version 5.1.0 du 25/08/2016-15:36
|
||||
|
||||
8a33418 ulib/ldif: support de l'opération modrdn
|
||||
+ b710461 Intégration de la branche apacheconfig
|
||||
| e52d6c6 déplacer la logique de apacheconfig dans le module apache.tools
|
||||
|
||||
## Version 5.0.0 du 09/08/2016-09:42
|
||||
|
||||
c00d9e4 cgilsxml.py: prévoir le cas où le fichier disparait pendant que la liste est construite
|
||||
|
|
|
@ -1 +1 @@
|
|||
5.0.0
|
||||
5.1.0
|
||||
|
|
135
apacheconfig
135
apacheconfig
|
@ -2,6 +2,7 @@
|
|||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
|
||||
urequire DEFAULTS template apache.tools
|
||||
apacheconfig_initvars
|
||||
|
||||
function display_help() {
|
||||
uecho "$scriptname: Gérer la configuration d'un serveur web apache
|
||||
|
@ -65,95 +66,6 @@ OPTIONS
|
|||
tests."
|
||||
}
|
||||
|
||||
# toujours placer une variable dépendante AVANT la variable maitre
|
||||
TEMPLATE_STATIC_VARS=(
|
||||
hostname aliases host
|
||||
certsdir caname
|
||||
)
|
||||
TEMPLATE_DYNAMIC_VARS=(
|
||||
ips_namevirtualhosts ips_listens ips
|
||||
dhostname daliases dhost
|
||||
admin configdir
|
||||
)
|
||||
TEMPLATE_NOWRITE_VARS=(hostname aliases dhostname daliases configdir)
|
||||
|
||||
__TEMPLATE_DEFAULTF_host=__template_defaultf_host
|
||||
__TEMPLATE_UPDATEF_host=__template_updatef_host
|
||||
function __template_defaultf_host() {
|
||||
myhost
|
||||
}
|
||||
function __template_updatef_host() {
|
||||
if [ "$host" == "@@dhost@@" ]; then
|
||||
__template_set_var hostname @@dhostname@@
|
||||
__template_set_var aliases @@daliases@@
|
||||
else
|
||||
local update_aliases
|
||||
[ "$aliases" == "$hostname" ] && update_aliases=1
|
||||
__template_set_var hostname "${host%%.*}"
|
||||
[ -n "$update_aliases" ] && __template_set_var aliases "$hostname"
|
||||
[ -n "$ips" ] || __template_set_var ips ""
|
||||
fi
|
||||
}
|
||||
|
||||
__TEMPLATE_DEFAULTF_ips=__template_defaultf_ips
|
||||
__TEMPLATE_UPDATEF_ips=__template_updatef_ips
|
||||
function __template_defaultf_ips() {
|
||||
local -a ips
|
||||
if [ "$host" != "@@dhost@@" ]; then
|
||||
resolv_ips ips "$host"
|
||||
else
|
||||
resolv_ips ips "$dhost"
|
||||
fi
|
||||
echo "${ips[*]}"
|
||||
}
|
||||
function __template_updatef_ips() {
|
||||
local -a ipports; local ipport ip port
|
||||
local nvhs ls
|
||||
nvhs=
|
||||
ls=
|
||||
array_split ipports "$ips" " "
|
||||
for ipport in "${ipports[@]}"; do
|
||||
splitpair "$ipport" ip port
|
||||
[ -n "$port" ] || port=443
|
||||
[ -n "$nvhs" ] || nvhs="#ips_namevirtualhosts"
|
||||
nvhs="$nvhs
|
||||
NameVirtualHost $ip:$port"
|
||||
[ -n "$ls" ] || ls="#ips_listens"
|
||||
ls="$ls
|
||||
Listen $ip:$port"
|
||||
done
|
||||
[ -n "$nvhs" ] && __template_set_var ips_namevirtualhosts "$nvhs"
|
||||
[ -n "$ls" ] && __template_set_var ips_listens "$ls"
|
||||
}
|
||||
|
||||
__TEMPLATE_DEFAULTF_dhost=__template_defaultf_dhost
|
||||
__TEMPLATE_UPDATEF_dhost=__template_updatef_dhost
|
||||
function __template_defaultf_dhost() {
|
||||
myhost
|
||||
}
|
||||
function __template_updatef_dhost() {
|
||||
local update_daliases
|
||||
[ "$daliases" == "$dhostname" ] && update_daliases=1
|
||||
__template_set_var dhostname "${dhost%%.*}"
|
||||
[ -n "$update_daliases" ] && __template_set_var daliases "$dhostname"
|
||||
[ -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="$DEFAULT_ADMIN"
|
||||
certsdir="$DEFAULT_CERTSDIR"
|
||||
caname="$DEFAULT_CANAME"
|
||||
)
|
||||
TEMPLATECTL_VARS=()
|
||||
|
||||
action=
|
||||
destdir=
|
||||
nohideconfig=
|
||||
|
@ -192,25 +104,8 @@ args=(
|
|||
)
|
||||
parse_args "$@"; set -- "${args[@]}"
|
||||
|
||||
__template_set_destdir destdir autocreate "$TEMPLATECTL_NAME" || die
|
||||
setx config=templatectl_config "$destdir" ${nohideconfig:+nohideconfig}
|
||||
modified=
|
||||
templatectl_loadvars "$config" && modified=1
|
||||
|
||||
if [ -n "$sysname" -o -n "$sysdist" -o -n "$sysver" ]; then
|
||||
ensure_sysinfos sysname sysdist sysver
|
||||
custom_sysinfos=1
|
||||
else
|
||||
sysname="$MYSYSNAME"
|
||||
sysdist="$MYSYSDIST"
|
||||
sysver="$MYSYSVER"
|
||||
bits="$MYBITS"
|
||||
custom_sysinfos=
|
||||
fi
|
||||
__template_set_var sysname "$sysname"
|
||||
__template_set_var sysdist "$sysdist"
|
||||
__template_set_var sysver "$sysver"
|
||||
#check_sysinfos --vars sysname sysdist sysver bits "${templatectl_suffix[@]}
|
||||
apacheconfig_loadconf "$destdir" || die
|
||||
apacheconfig_sysinfos "$sysname" "$sysdist" "$sysver" "$bits"
|
||||
|
||||
################################################################################
|
||||
if [ "$action" == create ]; then
|
||||
|
@ -262,24 +157,14 @@ elif [ "$action" == deploy -o "$action" == localhosts ]; then
|
|||
|
||||
if [ "$action" == deploy ]; then
|
||||
etitle "Mise à jour du système"
|
||||
args=(apache_autoconf
|
||||
--ignore "$(basename -- "$config")"
|
||||
${oneconf:+--one-conf "$(basename -- "$oneconf")"}
|
||||
${onemodule:+--one-module "$(basename -- "$onemodule")"}
|
||||
)
|
||||
# sur une ligne séparée parce que $bits peut être vide
|
||||
[ -n "$custom_sysinfos" ] && array_add args --sysname "$sysname" --sysdist "$sysdist" --sysver "$sysver" --bits "$bits"
|
||||
apacheconfig_deploy \
|
||||
"$destdir" "$aac_certsdir" \
|
||||
"$config" "$oneconf" "$onemodule" "$onesite" \
|
||||
"$custom_sysinfos" "$sysname" "$sysdist" "$sysver" "$bits" || die
|
||||
eend
|
||||
elif [ "$action" == localhosts ]; then
|
||||
etitle "Mise à jour de /etc/hosts"
|
||||
args=(apache_autoconf_localhosts)
|
||||
apacheconfig_deploy_localhosts "$destdir" "$aac_certsdir" "$onesite" || die
|
||||
eend
|
||||
fi
|
||||
args=("${args[@]}"
|
||||
"$destdir" "$aac_certsdir"
|
||||
${onesite:+--one-site "$(basename -- "$onesite")"}
|
||||
)
|
||||
for __name in "${TEMPLATE_DYNAMIC_VARS[@]}"; do
|
||||
array_add args "$__name=${!__name}"
|
||||
done
|
||||
"${args[@]}" "$@" || die
|
||||
eend
|
||||
fi
|
||||
|
|
|
@ -1 +1 @@
|
|||
013000000
|
||||
013001000
|
||||
|
|
|
@ -652,3 +652,163 @@ $1 == "ServerAlias" { for (i = 2; i <= NF; i++) { if ($i ~ /\.local$/) print $i
|
|||
echo "$ip $host" >>/etc/hosts
|
||||
done
|
||||
}
|
||||
|
||||
function __template_defaultf_host() {
|
||||
myhost
|
||||
}
|
||||
function __template_updatef_host() {
|
||||
if [ "$host" == "@@dhost@@" ]; then
|
||||
__template_set_var hostname @@dhostname@@
|
||||
__template_set_var aliases @@daliases@@
|
||||
else
|
||||
local update_aliases
|
||||
[ "$aliases" == "$hostname" ] && update_aliases=1
|
||||
__template_set_var hostname "${host%%.*}"
|
||||
[ -n "$update_aliases" ] && __template_set_var aliases "$hostname"
|
||||
[ -n "$ips" ] || __template_set_var ips ""
|
||||
fi
|
||||
}
|
||||
|
||||
function __template_defaultf_ips() {
|
||||
local -a ips
|
||||
if [ "$host" != "@@dhost@@" ]; then
|
||||
resolv_ips ips "$host"
|
||||
else
|
||||
resolv_ips ips "$dhost"
|
||||
fi
|
||||
echo "${ips[*]}"
|
||||
}
|
||||
function __template_updatef_ips() {
|
||||
local -a ipports; local ipport ip port
|
||||
local nvhs ls
|
||||
nvhs=
|
||||
ls=
|
||||
array_split ipports "$ips" " "
|
||||
for ipport in "${ipports[@]}"; do
|
||||
splitpair "$ipport" ip port
|
||||
[ -n "$port" ] || port=443
|
||||
[ -n "$nvhs" ] || nvhs="#ips_namevirtualhosts"
|
||||
nvhs="$nvhs
|
||||
NameVirtualHost $ip:$port"
|
||||
[ -n "$ls" ] || ls="#ips_listens"
|
||||
ls="$ls
|
||||
Listen $ip:$port"
|
||||
done
|
||||
[ -n "$nvhs" ] && __template_set_var ips_namevirtualhosts "$nvhs"
|
||||
[ -n "$ls" ] && __template_set_var ips_listens "$ls"
|
||||
}
|
||||
|
||||
function __template_defaultf_dhost() {
|
||||
myhost
|
||||
}
|
||||
function __template_updatef_dhost() {
|
||||
local update_daliases
|
||||
[ "$daliases" == "$dhostname" ] && update_daliases=1
|
||||
__template_set_var dhostname "${dhost%%.*}"
|
||||
[ -n "$update_daliases" ] && __template_set_var daliases "$dhostname"
|
||||
[ -n "$ips" ] || __template_set_var ips ""
|
||||
}
|
||||
|
||||
# toujours placer une variable dépendante AVANT la variable maitre
|
||||
APACHECONFIG_TEMPLATE_STATIC_VARS=(
|
||||
hostname aliases host
|
||||
certsdir caname
|
||||
)
|
||||
APACHECONFIG_TEMPLATE_DYNAMIC_VARS=(
|
||||
ips_namevirtualhosts ips_listens ips
|
||||
dhostname daliases dhost
|
||||
admin configdir
|
||||
)
|
||||
APACHECONFIG_TEMPLATE_NOWRITE_VARS=(hostname aliases dhostname daliases configdir)
|
||||
|
||||
function apacheconfig_initvars() {
|
||||
DEFAULT_ADMIN=supervision-gdrsi@listes.univ-reunion.fr
|
||||
DEFAULT_CERTSDIR=1507-renater
|
||||
DEFAULT_CANAME=1507-DigiCertCA.crt
|
||||
set_defaults apacheconfig
|
||||
|
||||
TEMPLATE_STATIC_VARS=("${APACHECONFIG_TEMPLATE_STATIC_VARS[@]}")
|
||||
TEMPLATE_DYNAMIC_VARS=("${APACHECONFIG_TEMPLATE_DYNAMIC_VARS[@]}")
|
||||
TEMPLATE_NOWRITE_VARS=("${APACHECONFIG_TEMPLATE_NOWRITE_VARS[@]}")
|
||||
__TEMPLATE_DEFAULTF_host=__template_defaultf_host
|
||||
__TEMPLATE_UPDATEF_host=__template_updatef_host
|
||||
__TEMPLATE_DEFAULTF_ips=__template_defaultf_ips
|
||||
__TEMPLATE_UPDATEF_ips=__template_updatef_ips
|
||||
__TEMPLATE_DEFAULTF_dhost=__template_defaultf_dhost
|
||||
__TEMPLATE_UPDATEF_dhost=__template_updatef_dhost
|
||||
|
||||
TEMPLATECTL_NAME=apacheconfig
|
||||
TEMPLATECTL_SRCDIRS=(apacheconfig)
|
||||
TEMPLATECTL_CONFIG="$TEMPLATECTL_NAME"
|
||||
TEMPLATECTL_DEFAULTS=(
|
||||
admin="$DEFAULT_ADMIN"
|
||||
certsdir="$DEFAULT_CERTSDIR"
|
||||
caname="$DEFAULT_CANAME"
|
||||
)
|
||||
TEMPLATECTL_VARS=()
|
||||
}
|
||||
|
||||
function apacheconfig_loadconf() {
|
||||
local config modified
|
||||
local destdir="$1"
|
||||
|
||||
__template_set_destdir destdir autocreate "$TEMPLATECTL_NAME" || return 1
|
||||
setx config=templatectl_config "$destdir"
|
||||
modified=
|
||||
templatectl_loadvars "$config" && modified=1
|
||||
|
||||
upvar config "$config"
|
||||
}
|
||||
|
||||
function apacheconfig_sysinfos() {
|
||||
local sysname="$1" sysdist="$2" sysver="$3" bits="$4" custom_sysinfos
|
||||
|
||||
if [ -n "$sysname" -o -n "$sysdist" -o -n "$sysver" ]; then
|
||||
ensure_sysinfos sysname sysdist sysver
|
||||
custom_sysinfos=1
|
||||
else
|
||||
sysname="$MYSYSNAME"
|
||||
sysdist="$MYSYSDIST"
|
||||
sysver="$MYSYSVER"
|
||||
bits="$MYBITS"
|
||||
custom_sysinfos=
|
||||
fi
|
||||
__template_set_var sysname "$sysname"
|
||||
__template_set_var sysdist "$sysdist"
|
||||
__template_set_var sysver "$sysver"
|
||||
#check_sysinfos --vars sysname sysdist sysver bits "${templatectl_suffix[@]}
|
||||
|
||||
upvars sysname "$sysname" sysdist "$sysdist" sysver "$sysver" bits "$bits" \
|
||||
custom_sysinfos "$custom_sysinfos"
|
||||
}
|
||||
|
||||
function apacheconfig_deploy() {
|
||||
local destdir="$1" certsdir="$2"; shift; shift
|
||||
local config="$1" oneconf="$2" onemodule="$3"; onesite="$4"; shift; shift; shift; shift
|
||||
local custom_sysinfos="$1" sysname="$2" sysdist="$3" sysver="$4" bits="$5"; shift; shift; shift; shift; shift
|
||||
|
||||
local -a args
|
||||
args=(--ignore "$(basename -- "$config")")
|
||||
[ -n "$oneconf" ] && array_add args --one-conf "$(basename -- "$oneconf")"
|
||||
[ -n "$onemodule" ] && array_add args --one-module "$(basename -- "$onemodule")"
|
||||
[ -n "$onesite" ] && array_add args --one-site "$(basename -- "$onesite")"
|
||||
[ -n "$custom_sysinfos" ] && array_add args --sysname "$sysname" --sysdist "$sysdist" --sysver "$sysver" --bits "$bits"
|
||||
array_add args "$destdir" "$certsdir"
|
||||
for __name in "${TEMPLATE_DYNAMIC_VARS[@]}"; do
|
||||
array_add args "$__name=${!__name}"
|
||||
done
|
||||
apache_autoconf "${args[@]}" "$@"
|
||||
}
|
||||
|
||||
function apacheconfig_localhosts() {
|
||||
local destdir="$1" certsdir="$2"; shift; shift
|
||||
local onesite="$1"; shift
|
||||
|
||||
local -a args
|
||||
[ -n "$onesite" ] && array_add args --one-site "$(basename -- "$onesite")"
|
||||
array_add args "$destdir" "$certsdir"
|
||||
for __name in "${TEMPLATE_DYNAMIC_VARS[@]}"; do
|
||||
array_add args "$__name=${!__name}"
|
||||
done
|
||||
apache_autoconf_localhosts "${args[@]}" "$@"
|
||||
}
|
||||
|
|
|
@ -272,6 +272,27 @@ function tl_deleteentry() {
|
|||
'
|
||||
}
|
||||
|
||||
function tl_modrdn() {
|
||||
local newrdn newsup keep
|
||||
splitfsep "$1" , newrdn newsup
|
||||
case "$2" in
|
||||
k|keep|keepold|keepoldrdn) keep=1;;
|
||||
esac
|
||||
awkrun newrdn:str="$newrdn" newsup:str="$newsup" keep:int="$keep" '
|
||||
/^dn:/ {
|
||||
dn = $0
|
||||
print dn
|
||||
print "changetype: modrdn"
|
||||
print "newrdn: " newrdn
|
||||
if (keep) print "deleteoldrdn: 0"
|
||||
else print "deleteoldrdn: 1"
|
||||
if (newsup != "") print "newsuperior: " newsup
|
||||
print ""
|
||||
next
|
||||
}
|
||||
'
|
||||
}
|
||||
|
||||
function tl_touchentry() {
|
||||
awk '
|
||||
/^dn:/ {
|
||||
|
@ -1253,6 +1274,9 @@ D, moddelattr
|
|||
Supprimer l'attribut
|
||||
delentry
|
||||
Supprimer l'objet
|
||||
rename, modrdn NEWRDN[,NEWSUPERIOR] [keep[oldrdn]]
|
||||
Déplacer/renommer l'objet. L'ancienne valeur est supprimée, à moins que
|
||||
l'argument keep ne soit spécifié.
|
||||
touchentry
|
||||
Forcer la réplication de l'objet en simulant une modification"
|
||||
|
||||
|
@ -1371,8 +1395,9 @@ function get_transform_cmd() {
|
|||
d|md|moddel|moddelval) cmdparts=(tl_modifyattr delete);;
|
||||
D|moddelattr) cmdparts=(tl_deleteattr);;
|
||||
delentry|moddelentry) cmdparts=(tl_deleteentry);;
|
||||
rename|modrdn|modrename|modmodrdn) cmdparts=(tl_modrdn "$@");;
|
||||
touch|touchentry|modtouchentry) cmdparts=(tl_touchentry);;
|
||||
litteral) cmdpars=("$@");;
|
||||
litteral) cmdparts=("$@");;
|
||||
*)
|
||||
eerror "$cmd: commande inconnue. elle sera ignorée"
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue