keepalived: suppress reloads when config md5 has no change
authorBen Kelly <ben@benjii.net>
Tue, 30 Aug 2016 08:54:49 +0000 (11:54 +0300)
committerAlexandru Ardelean <ardeleanalex@gmail.com>
Sat, 31 Dec 2016 10:39:05 +0000 (12:39 +0200)
Signed-off-by: Ben Kelly <ben@benjii.net>
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
net/keepalived/files/keepalived.init

index 125c0872179a6d60708a486e667f94aeb7b6f098..6e850f02d8f5c80f3b39ae7e742dd1e2877ab363 100644 (file)
@@ -366,9 +366,20 @@ service_running() {
        pgrep -x /usr/sbin/keepalived &> /dev/null
 }
 
+conf_md5() {
+       echo "$(md5sum $KEEPALIVED_CONF | awk '{print $1}')"
+}
+
 reload_service() {
+       local cur_md5="$(conf_md5)"
        running && {
                process_config
+
+               # Return without performing the reload if config
+               # file md5sum has not changed
+               local new_md5="$(conf_md5)"
+               [ "$new_md5" == "$cur_md5" ] && return 0;
+
                # SIGHUP is used by keepalived to do init.d reload
                # Get the oldest process (assumption is that it's the parent process)
                PID=$(pgrep -o /usr/sbin/keepalived)