From ea68158b9718ccb87e516abcc5276cde8c2dccf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Nussbaumer?= Date: Thu, 12 Aug 2021 14:26:15 +0200 Subject: [PATCH] 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) --- cloudflare-template.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cloudflare-template.sh b/cloudflare-template.sh index f0f1e59..e05f973 100644 --- a/cloudflare-template.sh +++ b/cloudflare-template.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh 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 @@ -46,7 +46,7 @@ fi ########################################### ## 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 if [[ $ip == $old_ip ]]; then logger "DDNS Updater: IP ($ip) for ${record_name} has not changed." @@ -56,7 +56,7 @@ fi ########################################### ## 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