ddns-scripts: refactor update_url checks to avoid echo|grep sub-shells
authorPaul Donald <[email protected]>
Wed, 27 Nov 2024 19:39:00 +0000 (20:39 +0100)
committerFlorian Eckert <[email protected]>
Thu, 10 Apr 2025 07:34:38 +0000 (09:34 +0200)
Signed-off-by: Paul Donald <[email protected]>
net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh

index e6f91e8ee08f58250b89410ab4dcc7cf2c57394e..53099aae5c7bfcc1dbc231f4d19a55e492fba8be 100644 (file)
@@ -266,16 +266,16 @@ esac
 
 [ -n "$update_url" ] && {
        # only check if update_url is given, update_scripts have to check themselves
-       [ -z "$domain" ] && $(echo "$update_url" | grep "\[DOMAIN\]" >/dev/null 2>&1) && \
-               write_log 14 "Service section not configured correctly! Missing 'domain'"
-       [ -z "$username" ] && $(echo "$update_url" | grep "\[USERNAME\]" >/dev/null 2>&1) && \
-               write_log 14 "Service section not configured correctly! Missing 'username'"
-       [ -z "$password" ] && $(echo "$update_url" | grep "\[PASSWORD\]" >/dev/null 2>&1) && \
-               write_log 14 "Service section not configured correctly! Missing 'password'"
-       [ -z "$param_enc" ] && $(echo "$update_url" | grep "\[PARAMENC\]" >/dev/null 2>&1) && \
-               write_log 14 "Service section not configured correctly! Missing 'param_enc'"
-       [ -z "$param_opt" ] && $(echo "$update_url" | grep "\[PARAMOPT\]" >/dev/null 2>&1) && \
-               write_log 14 "Service section not configured correctly! Missing 'param_opt'"
+       [ -z "$domain" ] && [ "${update_url##*'[DOMAIN]'}" != "$update_url" ] && \
+               write_log 14 "Service section missing 'domain'"
+       [ -z "$username" ] && [ "${update_url##*'[USERNAME]'}" != "$update_url" ] && \
+               write_log 14 "Service section missing 'username'"
+       [ -z "$password" ] && [ "${update_url##*'[PASSWORD]'}" != "$update_url" ] && \
+               write_log 14 "Service section missing 'password'"
+       [ -z "$param_enc" ] && [ "${update_url##*'[PARAMENC]'}" != "$update_url" ] && \
+               write_log 14 "Service section missing 'param_enc'"
+       [ -z "$param_opt" ] && [ "${update_url##*'[PARAMOPT]'}" != "$update_url" ] && \
+               write_log 14 "Service section missing 'param_opt'"
 }
 
 # verify ip_source 'script' if script is configured and executable