replace PCRE regexp with standard regexp

Permits to run the script on simpler/lighter Linux distributions,
e.g. OpenWRT, where the grep utility available does not permit to use
Perl extended regexp (the `grep -P` option)
This commit is contained in:
Clément Nussbaumer 2021-08-12 14:26:15 +02:00
parent ee49627f08
commit ea68158b97
1 changed files with 3 additions and 3 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
auth_email="" # The email used to login 'https://dash.cloudflare.com' auth_email="" # The email used to login 'https://dash.cloudflare.com'
auth_method="token" # Set to "global" for Global API Key or "token" for Scoped API Token auth_method="token" # Set to "global" for Global API Key or "token" for Scoped API Token
@ -46,7 +46,7 @@ fi
########################################### ###########################################
## Get existing IP ## Get existing IP
########################################### ###########################################
old_ip=$(echo "$record" | grep -Po '(?<="content":")[^"]*' | head -1) old_ip=$(echo "$record" | sed -E 's/.*"content":"(([0-9]{1,3}\.){3}[0-9]{1,3})".*/\1/')
# Compare if they're the same # Compare if they're the same
if [[ $ip == $old_ip ]]; then if [[ $ip == $old_ip ]]; then
logger "DDNS Updater: IP ($ip) for ${record_name} has not changed." logger "DDNS Updater: IP ($ip) for ${record_name} has not changed."
@ -56,7 +56,7 @@ fi
########################################### ###########################################
## Set the record identifier from result ## Set the record identifier from result
########################################### ###########################################
record_identifier=$(echo "$record" | grep -Po '(?<="id":")[^"]*' | head -1) record_identifier=$(echo "$record" | sed -E 's/.*"id":"(\w+)".*/\1/')
########################################### ###########################################
## Change the IP@Cloudflare using the API ## Change the IP@Cloudflare using the API