aiccu: Issue aiccu stop only when aiccu is running
authorOndřej Caletka <ondrej@caletka.cz>
Sun, 30 Nov 2014 17:55:28 +0000 (18:55 +0100)
committerOndřej Caletka <ondrej@caletka.cz>
Mon, 1 Dec 2014 14:15:35 +0000 (15:15 +0100)
When AICCU is not running, running 'aiccu stop' results in unnecessary
communications with SixXS servers.

Signed-off-by: Ondrej Caletka <Ondrej@Caletka.cz>
ipv6/aiccu/files/aiccu.sh

index 89c812219969877bca75da43d63a86077a06e1cc..38d8191f502fdc3ab9e3e1508238532081c874c3 100755 (executable)
@@ -89,8 +89,12 @@ proto_aiccu_teardown() {
        local cfg="$1"
        local link="aiccu-$cfg"
        CFGFILE="/var/etc/${link}.conf"
-
-       aiccu stop "$CFGFILE"
+       PIDFILE="/var/run/${link}.pid"
+       [ -f "$CFGFILE" -a -f "$PIDFILE" ] && {
+               local pid="$(cat "$PIDFILE")"
+               [ -d /proc/$pid -a $(cat /proc/$pid/comm) = "aiccu" ] && \
+               aiccu stop "$CFGFILE"
+       }
 }
 
 proto_aiccu_init_config() {