Bläddra i källkod

Verbose option for freedns

Bob Mottram 7 å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,7 +13,7 @@
13 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 18
 # This program is free software: you can redistribute it and/or modify
19 19
 # it under the terms of the GNU Affero General Public License as published by
@@ -33,9 +33,14 @@ PROJECT_NAME='freedombone'
33 33
 export TEXTDOMAIN=${PROJECT_NAME}-freedns
34 34
 export TEXTDOMAINDIR="/usr/share/locale"
35 35
 
36
+VERBOSE=
36 37
 CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg
37 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 44
 if [ ! -f $CONFIGURATION_FILE ]; then
40 45
     exit 0
41 46
 fi
@@ -47,10 +52,13 @@ function item_in_array {
47 52
 }
48 53
 
49 54
 detected_codes=()
50
-codelines=($(grep "_CODE=" $CONFIGURATION_FILE | uniq))
55
+codelines=$(grep "_CODE=" $CONFIGURATION_FILE | uniq)
51 56
 for line in "${codelines[@]}"
52 57
 do
53 58
     code=$(echo "$line" | awk -F '=' '{print $2}')
59
+    if [ $VERBOSE ]; then
60
+        echo $"freedns code $code"
61
+    fi
54 62
     item_in_array "$code" "${detected_codes[@]}"
55 63
     if [[ $? != 0 ]]; then
56 64
         detected_codes+=("$code")