Bläddra i källkod

Verbose option for freedns

Bob Mottram 8 år sedan
förälder
incheckning
cfae58f30f
1 ändrade filer med 10 tillägg och 2 borttagningar
  1. 10
    2
      src/freedombone-freedns

+ 10
- 2
src/freedombone-freedns Visa fil

13
 # License
13
 # License
14
 # =======
14
 # =======
15
 #
15
 #
16
-# Copyright (C) 2016 Bob Mottram <bob@freedombone.net>
16
+# Copyright (C) 2016-2017 Bob Mottram <bob@freedombone.net>
17
 #
17
 #
18
 # This program is free software: you can redistribute it and/or modify
18
 # This program is free software: you can redistribute it and/or modify
19
 # it under the terms of the GNU Affero General Public License as published by
19
 # it under the terms of the GNU Affero General Public License as published by
33
 export TEXTDOMAIN=${PROJECT_NAME}-freedns
33
 export TEXTDOMAIN=${PROJECT_NAME}-freedns
34
 export TEXTDOMAINDIR="/usr/share/locale"
34
 export TEXTDOMAINDIR="/usr/share/locale"
35
 
35
 
36
+VERBOSE=
36
 CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg
37
 CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg
37
 FREEDNS_WGET='wget -q --read-timeout=0.0 --waitretry=5 --tries=4 https://freedns.afraid.org/dynamic/update.php?'
38
 FREEDNS_WGET='wget -q --read-timeout=0.0 --waitretry=5 --tries=4 https://freedns.afraid.org/dynamic/update.php?'
38
 
39
 
40
+if [[ "$1" == "--verbose" || "$1" == "-v" ]]; then
41
+    VERBOSE=1
42
+fi
43
+
39
 if [ ! -f $CONFIGURATION_FILE ]; then
44
 if [ ! -f $CONFIGURATION_FILE ]; then
40
     exit 0
45
     exit 0
41
 fi
46
 fi
47
 }
52
 }
48
 
53
 
49
 detected_codes=()
54
 detected_codes=()
50
-codelines=($(grep "_CODE=" $CONFIGURATION_FILE | uniq))
55
+codelines=$(grep "_CODE=" $CONFIGURATION_FILE | uniq)
51
 for line in "${codelines[@]}"
56
 for line in "${codelines[@]}"
52
 do
57
 do
53
     code=$(echo "$line" | awk -F '=' '{print $2}')
58
     code=$(echo "$line" | awk -F '=' '{print $2}')
59
+    if [ $VERBOSE ]; then
60
+        echo $"freedns code $code"
61
+    fi
54
     item_in_array "$code" "${detected_codes[@]}"
62
     item_in_array "$code" "${detected_codes[@]}"
55
     if [[ $? != 0 ]]; then
63
     if [[ $? != 0 ]]; then
56
         detected_codes+=("$code")
64
         detected_codes+=("$code")