From 751ed5bf4d47a7d4af1ba6d46a23881abd7d5a8a Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Tue, 18 Oct 2011 18:38:24 +0000 Subject: [PATCH] Merged changesets 3086, 3090, 3104 from trunk to branch stable-1.0 --- debian/alternc.cron.d | 5 +++++ src/alternc_reload | 16 +++++++++++++--- src/functions_dns.sh | 9 ++++++++- src/update_domains.sh | 14 ++++++++++---- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/debian/alternc.cron.d b/debian/alternc.cron.d index 93d8383a..1dbb4588 100644 --- a/debian/alternc.cron.d +++ b/debian/alternc.cron.d @@ -17,3 +17,8 @@ # Once a week at 7am, optimise the AlternC database 0 1 * * 7 root /usr/lib/alternc/alternc-dboptimize + +# We change the session directory... debian's patch modified : +# Look for and purge old sessions every 30 minutes +09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/alternc/sessions/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete + diff --git a/src/alternc_reload b/src/alternc_reload index c665b3ec..0122cb2a 100755 --- a/src/alternc_reload +++ b/src/alternc_reload @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # $Id: update_domaines.sh,v 1.31 2005/08/29 19:21:31 anarcat Exp $ # ---------------------------------------------------------------------- @@ -53,20 +53,30 @@ apache_reload() { fi } +dns_restart() { + if [ -x /etc/init.d/bind9 ]; then + $sudo /etc/init.d/bind9 restart || echo "Cannot restart dns daemon (bind9)" + fi +} + RELOAD_ZONES="$*" +echo $RELOAD_ZONES if [ ! -z "$RELOAD_ZONES" ]; then for zone in $RELOAD_ZONES; do case $zone in "all") - $sudo rndc reload || echo "Cannot reload bind" + $sudo rndc reload || echo "Cannot reload bind" apache_reload # keep for compatibility ;; + "dns_daemon") + dns_restart + ;; "apache") apache_reload ;; *) - $sudo rndc reload "$zone" || echo "Cannot reload bind for zone $zone" + $sudo rndc reload "$zone" || echo "Cannot reload bind for zone $zone" ;; esac done diff --git a/src/functions_dns.sh b/src/functions_dns.sh index ef0aebca..104e6096 100755 --- a/src/functions_dns.sh +++ b/src/functions_dns.sh @@ -49,13 +49,17 @@ dns_named_conf() { return 1 fi - grep -q "$domain" "$NAMED_CONF" + # Add the entry + grep -q "\"$domain\"" "$NAMED_CONF" if [ $? -ne 0 ] ; then local tempo=$(cat "$NAMED_TEMPLATE") tempo=${tempo/@@DOMAINE@@/$domain} tempo=${tempo/@@ZONE_FILE@@/$(dns_zone_file $domain)} echo $tempo >> "$NAMED_CONF" fi + + # Ask for restart of dns server + touch "$DNS_DO_RESTART" } dns_delete() { @@ -69,6 +73,9 @@ dns_delete() { # Remove from the named conf local file=$(cat "$NAMED_CONF") echo -e "$file" |grep -v "\"$domain\"" > "$NAMED_CONF" + + # Ask for restart of dns server + touch "$DNS_DO_RESTART" } # DNS regenerate diff --git a/src/update_domains.sh b/src/update_domains.sh index a5bc1044..fc1f32c8 100644 --- a/src/update_domains.sh +++ b/src/update_domains.sh @@ -21,6 +21,7 @@ OLDIFS="$IFS" NEWIFS=" " RELOAD_ZONES="$(mktemp /tmp/alternc_reload_zones.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 echo "" > "$RELOAD_ZONES" @@ -134,16 +135,21 @@ if [ ! -z "$(cat "$RELOAD_WEB")" ] ; then fi +# What do we reload ? +lst_zones=$(cat "$RELOAD_ZONES"|tr '\n' ' ') +if [ -e "$DNS_DO_RESTART" ] ; then + lst_zones="dns_daemon $lst_zones" +fi + # we assume we run apache and bind on the master -tempo=$(cat "$RELOAD_ZONES"|tr '\n' ' ') -/usr/bin/alternc_reload $tempo || true +/usr/bin/alternc_reload $lst_zones || true for slave in $ALTERNC_SLAVES; do if [ "$slave" != "localhost" ]; then - ssh alternc@$slave alternc_reload $tempo || true + ssh alternc@$slave alternc_reload $lst_zones || true fi done -rm -f "$LOCK_FILE" "$RELOAD_ZONES" "$RELOAD_WEB" +rm -f "$LOCK_FILE" "$RELOAD_ZONES" "$RELOAD_WEB" "$DNS_DO_RESTART" exit 0