From 9209aae0d180a6d61a552b52572f0c83b2ef4cb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20S?= Date: Thu, 21 Mar 2019 17:08:54 +0100 Subject: [PATCH] bind-add-ng: grep -E is not working for tabulations We need to use grep -P, to use pcrepattern(3). --- scripts/bind-add-ng.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/bind-add-ng.sh b/scripts/bind-add-ng.sh index 7ab6ad6..001fc42 100755 --- a/scripts/bind-add-ng.sh +++ b/scripts/bind-add-ng.sh @@ -43,7 +43,7 @@ add_mx () { return 0 fi - if ! grep -q -E "^$mx_subdomain[ \t]+IN[ \t]+MX[ \t]+[[:digit:]]+[ \t]+$mx$" $zonefile; then + if ! grep -q -P "^$mx_subdomain[ \t]+IN[ \t]+MX[ \t]+[[:digit:]]+[ \t]+$mx$" $zonefile; then echo "$mx_subdomain IN MX $mx_priority $mx" >>$zonefile else log ERR "MX Record $mx already exists." @@ -58,7 +58,7 @@ add_subdomain () { zonefile="$BINDROOT/db.$domain" - if ! grep -q -E "^$subdomain[ \t]+IN[ \t]+(CNAME|A)[ \t]+" $zonefile; then + if ! grep -q -P "^$subdomain[ \t]+IN[ \t]+(CNAME|A)[ \t]+" $zonefile; then echo "$subdomain IN CNAME @" >>$zonefile else log ERR "CNAME or A record for $subdomain already exists." @@ -73,7 +73,7 @@ inc_and_reload () { zonefile="$BINDROOT/db.$domain" # Set the date for serial (only if greater than actual serial) - serial=$(grep -E '^[ \t]*[0-9]{10}[ \t]*; serial' $zonefile | sed "s/^[ \t]*\([0-9]\{10\}\)[ \t]*; serial/\1/") + serial=$(grep -P '^[ \t]*[0-9]{10}[ \t]*; serial' $zonefile | sed "s/^[ \t]*\([0-9]\{10\}\)[ \t]*; serial/\1/") if [ `date "+%Y%m%d%H"` -gt $serial ]; then serial=$(date "+%Y%m%d%H"); else serial=$(( $serial + 1 )); fi sed -i "s/^\([ \t]*\)[0-9]\{10\}\([ \t]*; serial\)/\1$serial\2/" \ $zonefile