From 2cf8e6a4f8f539253a4dbf0ea259b8738aec5390 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Sun, 28 Oct 2018 09:58:25 +0000
Subject: [PATCH] The whole thing can be way less complicated

---
 src/freedombone-freedns | 63 +++++------------------------------------
 1 file changed, 7 insertions(+), 56 deletions(-)

diff --git a/src/freedombone-freedns b/src/freedombone-freedns
index 0666f0fee..d4ce0f44b 100755
--- a/src/freedombone-freedns
+++ b/src/freedombone-freedns
@@ -7,7 +7,7 @@
 #                              Freedom in the Cloud
 #
 # freedns update command for use in cron or a daemon
-
+#
 # License
 # =======
 #
@@ -33,9 +33,6 @@ export TEXTDOMAINDIR="/usr/share/locale"
 
 VERBOSE=
 CONFIGURATION_FILE=/root/${PROJECT_NAME}.cfg
-#FREEDNS_WGET='wget --read-timeout=0.0 --waitretry=5 --tries=4 https://freedns.afraid.org/dynamic/update.php?'
-FREEDNS_WGET='wget --no-check-certificate -O - https://freedns.afraid.org/dynamic/update.php?'
-
 
 if [[ "$1" == "--verbose" || "$1" == "-v" ]]; then
     VERBOSE=1
@@ -45,63 +42,17 @@ if [ ! -f "$CONFIGURATION_FILE" ]; then
     exit 0
 fi
 
-function item_in_array {
-    local e
-    for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
-    return 1
-}
-
-detected_codes=()
-detected_codes_ctr=0
-codelines=$(grep "_CODE=" "$CONFIGURATION_FILE" | uniq)
-while read -r line; do
-    if [[ "$line" != '#'* ]]; then
-        code=$(echo "$line" | awk -F '=' '{print $2}')
-        # shellcheck disable=SC2068
-        if ! item_in_array "$code" ${detected_codes[@]}; then
-            detected_codes+=("$code")
-            detected_codes_ctr=$((detected_codes_ctr+1))
-        fi
-    fi
-done <<< "$codelines"
-
-if [ $detected_codes_ctr -eq 0 ]; then
-    exit 0
-fi
+code=$(grep 'DEFAULT_DOMAIN_CODE' "$CONFIGURATION_FILE" | awk -F '=' '{print $2}')
 
-if [ ! -d "$HOME/.freedns-update" ]; then
-    mkdir "$HOME/.freedns-update"
+if [ $VERBOSE ]; then
+    echo $"wget --no-check-certificate -O - https://freedns.afraid.org/dynamic/update.php?${code}= >> /tmp/freedns 2>&1 &"
 fi
-cd "$HOME/.freedns-update" || exit 2467824684
-# shellcheck disable=SC2068
-for code in ${detected_codes[@]}
-do
-    if [ $VERBOSE ]; then
-        echo $"command: $FREEDNS_WGET${code}= /tmp/freedns 2>&1 &"
-    fi
-
-    if [ -f /tmp/freedns ]; then
-        rm /tmp/freedns
-    fi
-
-    # shellcheck disable=SC1066,SC1067,SC1007
-    $FREEDNS_WGET${code}= >> /tmp/freedns 2>&1 &
-
-    if [ $VERBOSE ]; then
-        if [ -f /tmp/freedns ]; then
-            cat /tmp/freedns
-        fi
-    fi
-
-    # if your subdomains are linked on the freedns site
-    # then we only need to update one entry for them
-    # all to be changed
-    # see "Link updates of the same IP together"
-    break
-done
 
 if [ -f /tmp/freedns ]; then
     rm /tmp/freedns
 fi
 
+# shellcheck disable=SC2086
+wget --no-check-certificate -O - https://freedns.afraid.org/dynamic/update.php?${code}= >> /tmp/freedns 2>&1 &
+
 exit 0
-- 
GitLab