Verbose option for freedns

This commit is contained in:
Bob Mottram 2017-06-21 22:01:15 +01:00
parent bf025a037b
commit cfae58f30f
1 changed files with 10 additions and 2 deletions

View File

@ -13,7 +13,7 @@
# License # License
# ======= # =======
# #
# Copyright (C) 2016 Bob Mottram <bob@freedombone.net> # Copyright (C) 2016-2017 Bob Mottram <bob@freedombone.net>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
@ -33,9 +33,14 @@ PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-freedns export TEXTDOMAIN=${PROJECT_NAME}-freedns
export TEXTDOMAINDIR="/usr/share/locale" export TEXTDOMAINDIR="/usr/share/locale"
VERBOSE=
CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg
FREEDNS_WGET='wget -q --read-timeout=0.0 --waitretry=5 --tries=4 https://freedns.afraid.org/dynamic/update.php?' FREEDNS_WGET='wget -q --read-timeout=0.0 --waitretry=5 --tries=4 https://freedns.afraid.org/dynamic/update.php?'
if [[ "$1" == "--verbose" || "$1" == "-v" ]]; then
VERBOSE=1
fi
if [ ! -f $CONFIGURATION_FILE ]; then if [ ! -f $CONFIGURATION_FILE ]; then
exit 0 exit 0
fi fi
@ -47,10 +52,13 @@ function item_in_array {
} }
detected_codes=() detected_codes=()
codelines=($(grep "_CODE=" $CONFIGURATION_FILE | uniq)) codelines=$(grep "_CODE=" $CONFIGURATION_FILE | uniq)
for line in "${codelines[@]}" for line in "${codelines[@]}"
do do
code=$(echo "$line" | awk -F '=' '{print $2}') code=$(echo "$line" | awk -F '=' '{print $2}')
if [ $VERBOSE ]; then
echo $"freedns code $code"
fi
item_in_array "$code" "${detected_codes[@]}" item_in_array "$code" "${detected_codes[@]}"
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
detected_codes+=("$code") detected_codes+=("$code")