Changement de "ou" le dns se fait reloader/reconfigurer.
Plus propre et mieux scindé. Quand le DNS ou l'apache se fait reloader/reconfigurer, appel en "hooks" des scripts qui sont dans /usr/lib/alternc/reload.d/
This commit is contained in:
parent
bc763fce61
commit
29dac33896
|
@ -14,6 +14,7 @@ usr/bin
|
||||||
usr/share/alternc/panel
|
usr/share/alternc/panel
|
||||||
usr/lib/alternc
|
usr/lib/alternc
|
||||||
usr/lib/alternc/install.d
|
usr/lib/alternc/install.d
|
||||||
|
usr/lib/alternc/reload.d
|
||||||
usr/lib/alternc/safe_mode_exec_dir
|
usr/lib/alternc/safe_mode_exec_dir
|
||||||
usr/sbin
|
usr/sbin
|
||||||
usr/share/alternc/install
|
usr/share/alternc/install
|
||||||
|
|
|
@ -69,9 +69,6 @@ if [ ! -z "$RELOAD_ZONES" ]; then
|
||||||
$sudo rndc reload || echo "Cannot reload bind"
|
$sudo rndc reload || echo "Cannot reload bind"
|
||||||
apache_reload # keep for compatibility
|
apache_reload # keep for compatibility
|
||||||
;;
|
;;
|
||||||
"dns_daemon")
|
|
||||||
dns_restart
|
|
||||||
;;
|
|
||||||
"apache")
|
"apache")
|
||||||
apache_reload
|
apache_reload
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
ZONE_TEMPLATE="/etc/alternc/templates/bind/templates/zone.template"
|
ZONE_TEMPLATE="/etc/alternc/templates/bind/templates/zone.template"
|
||||||
NAMED_TEMPLATE="/etc/alternc/templates/bind/templates/named.template"
|
NAMED_TEMPLATE="/etc/alternc/templates/bind/templates/named.template"
|
||||||
NAMED_CONF="/var/lib/alternc/bind/automatic.conf"
|
NAMED_CONF="/var/lib/alternc/bind/automatic.conf"
|
||||||
|
RNDC="/usr/sbin/rndc"
|
||||||
|
|
||||||
dns_zone_file() {
|
dns_zone_file() {
|
||||||
echo "/var/lib/alternc/bind/zones/$1"
|
echo "/var/lib/alternc/bind/zones/$1"
|
||||||
|
@ -56,18 +57,21 @@ dns_named_conf() {
|
||||||
tempo=${tempo/@@DOMAINE@@/$domain}
|
tempo=${tempo/@@DOMAINE@@/$domain}
|
||||||
tempo=${tempo/@@ZONE_FILE@@/$(dns_zone_file $domain)}
|
tempo=${tempo/@@ZONE_FILE@@/$(dns_zone_file $domain)}
|
||||||
echo $tempo >> "$NAMED_CONF"
|
echo $tempo >> "$NAMED_CONF"
|
||||||
|
# Kindly ask Bind to reload his configuration
|
||||||
|
# (the zone file is allready created and populate)
|
||||||
|
$RNDC reconfig
|
||||||
|
# Hook it !
|
||||||
|
run-parts --arg=dns_reconfig /usr/lib/alternc/reload.d
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ask for restart of dns server
|
|
||||||
touch "$DNS_DO_RESTART"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_delete() {
|
dns_delete() {
|
||||||
local domain=$1
|
local domain=$1
|
||||||
|
|
||||||
# Delete the zone file
|
# Delete the zone file
|
||||||
if [ -w $(dns_zone_file $domain) ] ; then
|
if [ -w "$(dns_zone_file $domain)" ] ; then
|
||||||
rm -f $(dns_zone_file $domain)
|
rm -f "$(dns_zone_file $domain)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove from the named conf
|
# Remove from the named conf
|
||||||
|
@ -75,7 +79,9 @@ dns_delete() {
|
||||||
echo -e "$file" |grep -v "\"$domain\"" > "$NAMED_CONF"
|
echo -e "$file" |grep -v "\"$domain\"" > "$NAMED_CONF"
|
||||||
|
|
||||||
# Ask for restart of dns server
|
# Ask for restart of dns server
|
||||||
touch "$DNS_DO_RESTART"
|
$RNDC reconfig
|
||||||
|
# Hook it !
|
||||||
|
run-parts --arg=dns_reconfig /usr/lib/alternc/reload.d
|
||||||
}
|
}
|
||||||
|
|
||||||
# DNS regenerate
|
# DNS regenerate
|
||||||
|
@ -142,4 +148,9 @@ dns_regenerate() {
|
||||||
dns_chmod $domain
|
dns_chmod $domain
|
||||||
# Add it to named conf
|
# Add it to named conf
|
||||||
dns_named_conf $domain
|
dns_named_conf $domain
|
||||||
|
|
||||||
|
# Kindly bind to reload the zone
|
||||||
|
$RNDC reload $domain
|
||||||
|
# Hook it !
|
||||||
|
run-parts --arg=dns_reload_zone --arg="$domain" /usr/lib/alternc/reload.d
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,9 @@ LOCK_FILE="/usr/share/alternc/panel/cron.lock" # FIXME doesn't seem clean to be
|
||||||
OLDIFS="$IFS"
|
OLDIFS="$IFS"
|
||||||
NEWIFS=" "
|
NEWIFS=" "
|
||||||
LOGFORMAT_FILE="/etc/alternc/apache_logformat.conf"
|
LOGFORMAT_FILE="/etc/alternc/apache_logformat.conf"
|
||||||
RELOAD_ZONES="$(mktemp /tmp/alternc_reload_zones.XXXX)"
|
|
||||||
RELOAD_WEB="$(mktemp /tmp/alternc_reload_web.XXXX)"
|
RELOAD_WEB="$(mktemp /tmp/alternc_reload_web.XXXX)"
|
||||||
DNS_DO_RESTART="/tmp/alternc.do_do_restart.$$"
|
|
||||||
B="µµ§§" # Strange letters to make split in query
|
B="µµ§§" # Strange letters to make split in query
|
||||||
|
|
||||||
echo "" > "$RELOAD_ZONES"
|
|
||||||
echo "" > "$RELOAD_WEB"
|
echo "" > "$RELOAD_WEB"
|
||||||
|
|
||||||
# Somes check before start operations
|
# Somes check before start operations
|
||||||
|
@ -95,7 +92,6 @@ for dom in `mysql_query "select domaine from domaines where dns_action = 'UPDATE
|
||||||
do
|
do
|
||||||
dns_delete $dom
|
dns_delete $dom
|
||||||
mysql_query "update domaines set dns_action = 'OK', dns_result = '$?' where domaine = '$dom'"
|
mysql_query "update domaines set dns_action = 'OK', dns_result = '$?' where domaine = '$dom'"
|
||||||
echo -n " $dom " >> "$RELOAD_ZONES"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Domains we have to update the dns :
|
# Domains we have to update the dns :
|
||||||
|
@ -105,7 +101,6 @@ do
|
||||||
echo "dns_regenerate : domain=/$dom/"
|
echo "dns_regenerate : domain=/$dom/"
|
||||||
dns_regenerate $dom
|
dns_regenerate $dom
|
||||||
mysql_query "update domaines set dns_action = 'OK', dns_result = '$?' where domaine = '$dom'"
|
mysql_query "update domaines set dns_action = 'OK', dns_result = '$?' where domaine = '$dom'"
|
||||||
echo -n " $dom " >> "$RELOAD_ZONES"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Domains we want to delete completely, now we do it
|
# Domains we want to delete completely, now we do it
|
||||||
|
@ -115,11 +110,9 @@ do
|
||||||
dns_delete $dom
|
dns_delete $dom
|
||||||
# Web configurations have already bean cleaned previously
|
# Web configurations have already bean cleaned previously
|
||||||
mysql_query "delete from sub_domaines where domaine='$dom'; delete from domaines where domaine='$dom';"
|
mysql_query "delete from sub_domaines where domaine='$dom'; delete from domaines where domaine='$dom';"
|
||||||
echo -n " $dom " >> "$RELOAD_ZONES"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ! -z "$(cat "$RELOAD_WEB")" ] ; then
|
if [ ! -z "$(cat "$RELOAD_WEB")" ] ; then
|
||||||
echo " apache " >> "$RELOAD_ZONES"
|
|
||||||
|
|
||||||
# Just to encourage user to use THIS directory and not another one
|
# Just to encourage user to use THIS directory and not another one
|
||||||
test -d "$VHOST_MANUALCONF" || mkdir -p "$VHOST_MANUALCONF"
|
test -d "$VHOST_MANUALCONF" || mkdir -p "$VHOST_MANUALCONF"
|
||||||
|
@ -150,23 +143,21 @@ if [ ! -z "$(cat "$RELOAD_WEB")" ] ; then
|
||||||
fi
|
fi
|
||||||
mv "$tempo" "$VHOST_FILE"
|
mv "$tempo" "$VHOST_FILE"
|
||||||
|
|
||||||
|
# We must reload apache
|
||||||
|
# we assume we run apache on the master
|
||||||
|
/usr/bin/alternc_reload apache || true
|
||||||
|
# Launch hooks for apache reload
|
||||||
|
run-parts --arg=web_reload /usr/lib/alternc/reload.d
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# What do we reload ?
|
## FIXME : move the slave part into the /usr/lib/alternc/reload.d directory to be an hook
|
||||||
lst_zones=$(cat "$RELOAD_ZONES"|tr '\n' ' ')
|
#for slave in $ALTERNC_SLAVES; do
|
||||||
if [ -e "$DNS_DO_RESTART" ] ; then
|
# if [ "$slave" != "localhost" ]; then
|
||||||
lst_zones="dns_daemon $lst_zones"
|
# ssh alternc@$slave alternc_reload 'apache' || true
|
||||||
fi
|
# fi
|
||||||
|
#done
|
||||||
|
|
||||||
# we assume we run apache and bind on the master
|
rm -f "$LOCK_FILE" "$RELOAD_ZONES" "$RELOAD_WEB" "$INOTIFY_UPDATE_DOMAIN"
|
||||||
/usr/bin/alternc_reload $lst_zones || true
|
|
||||||
for slave in $ALTERNC_SLAVES; do
|
|
||||||
if [ "$slave" != "localhost" ]; then
|
|
||||||
ssh alternc@$slave alternc_reload $lst_zones || true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
rm -f "$LOCK_FILE" "$RELOAD_ZONES" "$RELOAD_WEB" "$DNS_DO_RESTART" "$INOTIFY_UPDATE_DOMAIN"
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue