ctdb-scripts: filter out comments in public_addresses file
authorRalph Boehme <slow@samba.org>
Wed, 8 Sep 2021 14:53:12 +0000 (16:53 +0200)
committerMartin Schwenke <martins@samba.org>
Tue, 12 Oct 2021 22:38:32 +0000 (22:38 +0000)
Note that order of sed expressions matters: the expression to delete
comment lines must come first as the second expression would transform

  # comment

to

  comment

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14826

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/config/events/legacy/10.interface.script
ctdb/config/functions

index 72e0c101d472c65105ffce7859cc74692653ddde..d87f6c52c5873af1af5aa64861ba709352d86172 100755 (executable)
@@ -25,7 +25,8 @@ fi
 get_all_interfaces ()
 {
     # Get all the interfaces listed in the public_addresses file
-    all_interfaces=$(sed -e 's/^[^\t ]*[\t ]*//' \
+    all_interfaces=$(sed -e '/^#.*/d' \
+                        -e 's/^[^\t ]*[\t ]*//' \
                         -e 's/,/ /g' \
                         -e 's/[\t ]*$//' "$ctdb_public_addresses")
 
index 2395d8d4dc85fb64e0b14faf2259e34cc7997db5..a4e73ad05943be161334572366bc5b8b1d3c1ec1 100755 (executable)
@@ -611,6 +611,9 @@ drop_all_public_ips ()
        # _x is intentionally ignored
        # shellcheck disable=SC2034
        while read _ip _x ; do
+               case "$_ip" in
+               \#*) continue ;;
+               esac
                drop_ip "$_ip"
        done <"${CTDB_BASE}/public_addresses"
 }