Fix bug where typo in rc file would cause zone owners to be incorrectly assigned
This commit is contained in:
parent
df44244176
commit
3f3dbaa977
38
aircon.sh
38
aircon.sh
|
@ -134,6 +134,10 @@ function getzoneaction() { # populates zproblem[] and zaction[]
|
||||||
fi
|
fi
|
||||||
fv=$(getforcevent ${zname[$idx]})
|
fv=$(getforcevent ${zname[$idx]})
|
||||||
|
|
||||||
|
if [[ $robtest -eq 1 ]]; then
|
||||||
|
echo "canping zone ${zname[$idx]} is: $pingok"
|
||||||
|
fi
|
||||||
|
|
||||||
donearby=0
|
donearby=0
|
||||||
|
|
||||||
if [[ -n $fv && ${zstate[$idx]} == $(getoppositestate ${fv}) ]]; then
|
if [[ -n $fv && ${zstate[$idx]} == $(getoppositestate ${fv}) ]]; then
|
||||||
|
@ -274,11 +278,16 @@ function getzoneaction() { # populates zproblem[] and zaction[]
|
||||||
|
|
||||||
function getidxfromname() { # name
|
function getidxfromname() { # name
|
||||||
local x
|
local x
|
||||||
|
#echo "==== getidxfromname($1)" >/dev/stderr
|
||||||
for x in ${!zname[@]}; do
|
for x in ${!zname[@]}; do
|
||||||
if [[ ${zname[$x]} == $1 ]]; then
|
#echo "==== idx $x comparing zname ('${zname[$x]}') to \$1 ('$1')" >/dev/stderr
|
||||||
|
if [[ ${zname[$x]} == "$1" ]]; then
|
||||||
|
#echo " ==== matched. returning ${x}" >/dev/stderr
|
||||||
echo "${x}"
|
echo "${x}"
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
echo "-1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function getnamefromid() { # id
|
function getnamefromid() { # id
|
||||||
|
@ -802,6 +811,7 @@ function addperson() {
|
||||||
|
|
||||||
function addowner() { # zone "host1 host2 ..."
|
function addowner() { # zone "host1 host2 ..."
|
||||||
local z h local x idx db doset=0
|
local z h local x idx db doset=0
|
||||||
|
local zidx
|
||||||
db=0
|
db=0
|
||||||
if [[ $1 == "-s" ]]; then
|
if [[ $1 == "-s" ]]; then
|
||||||
doset=1
|
doset=1
|
||||||
|
@ -812,6 +822,13 @@ function addowner() { # zone "host1 host2 ..."
|
||||||
shift
|
shift
|
||||||
h="$*"
|
h="$*"
|
||||||
|
|
||||||
|
|
||||||
|
zidx=$(getidxfromname "$z") # get the index into the zname[] etc arrays
|
||||||
|
if [[ $zidx -eq -1 ]]; then
|
||||||
|
error "Failed to set owner of zone '$z' to '$h' - zone doesn't exist. "
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
[[ $db -eq 1 ]] && info "addowner() zone $z host(s) [$h]"
|
[[ $db -eq 1 ]] && info "addowner() zone $z host(s) [$h]"
|
||||||
|
|
||||||
idx=$nowners
|
idx=$nowners
|
||||||
|
@ -830,9 +847,9 @@ function addowner() { # zone "host1 host2 ..."
|
||||||
[[ $idx == $nowners ]] && nowners=$((nowners + 1))
|
[[ $idx == $nowners ]] && nowners=$((nowners + 1))
|
||||||
|
|
||||||
if [[ $doset -eq 1 ]]; then
|
if [[ $doset -eq 1 ]]; then
|
||||||
local zidx
|
|
||||||
zidx=$(getidxfromname "$z")
|
|
||||||
zowner[$zidx]="${ownerhost[$idx]}";
|
zowner[$zidx]="${ownerhost[$idx]}";
|
||||||
|
|
||||||
|
[[ $db -eq 1 ]] && info " doing set of zowner[$zidx] (${zname[$zidx]}} to [${ownerhost[$idx]}]"
|
||||||
#zownerperson[$zidx]=$(getownerperson "$z"); # may be overwritten later
|
#zownerperson[$zidx]=$(getownerperson "$z"); # may be overwritten later
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -852,7 +869,7 @@ function addowner() { # zone "host1 host2 ..."
|
||||||
#}
|
#}
|
||||||
|
|
||||||
# getowner zone_name
|
# getowner zone_name
|
||||||
# returns devices associated woth zone
|
# returns devices associated with zone
|
||||||
function getowner() {
|
function getowner() {
|
||||||
local x retval
|
local x retval
|
||||||
retval=""
|
retval=""
|
||||||
|
@ -1706,6 +1723,7 @@ profiler=0
|
||||||
csvfile="$DEFAULT_CSVFILE"
|
csvfile="$DEFAULT_CSVFILE"
|
||||||
sanitycheck=0
|
sanitycheck=0
|
||||||
RULEFORMAT=ansi
|
RULEFORMAT=ansi
|
||||||
|
robtest=0
|
||||||
|
|
||||||
# check for config file option first
|
# check for config file option first
|
||||||
if [[ $* == *-f\ * ]]; then
|
if [[ $* == *-f\ * ]]; then
|
||||||
|
@ -1723,7 +1741,7 @@ fi
|
||||||
|
|
||||||
ALLARGS="$ALLARGS $*"
|
ALLARGS="$ALLARGS $*"
|
||||||
|
|
||||||
optstring="A:cD:f:hHi:I:k:l:Lo:pmsSt:T:wWx:y"
|
optstring="A:cD:f:hHi:I:k:l:Lo:pmRsSt:T:wWx:y"
|
||||||
while getopts "$optstring" i $ALLARGS; do
|
while getopts "$optstring" i $ALLARGS; do
|
||||||
case "$i" in
|
case "$i" in
|
||||||
h)
|
h)
|
||||||
|
@ -1767,6 +1785,9 @@ while getopts "$optstring" i $ALLARGS; do
|
||||||
T)
|
T)
|
||||||
tolerance_h=${OPTARG}
|
tolerance_h=${OPTARG}
|
||||||
;;
|
;;
|
||||||
|
R)
|
||||||
|
robtest=1
|
||||||
|
;;
|
||||||
c)
|
c)
|
||||||
enable_cronmode
|
enable_cronmode
|
||||||
;;
|
;;
|
||||||
|
@ -1862,6 +1883,13 @@ for x in ${devices}; do
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
|
|
||||||
|
if [[ $robtest -eq 1 ]]; then
|
||||||
|
for x in ${!zname[@]}; do
|
||||||
|
echo "zone ${zname[$x]} owner is [${zowner[$x]}]"
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $showwho -eq 1 ]]; then
|
if [[ $showwho -eq 1 ]]; then
|
||||||
# get max phone name length
|
# get max phone name length
|
||||||
maxlen=1
|
maxlen=1
|
||||||
|
|
Loading…
Reference in New Issue