Skip to content

Commit

Permalink
Add function 'string_to_lower'
Browse files Browse the repository at this point in the history
  • Loading branch information
rfuehrer committed Nov 10, 2019
1 parent 299698b commit d4ba3c1
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions autoshutdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,16 @@ MAXLOOP_COUNTER=0


# -------------------------------------------

get_hostname_from_ip(){
RET=`arp -a|grep $1|awk '{print $1}'|cut -d. -f1`
echo "$RET"
}

string_to_lower(){
RET=`echo "$1" | tr '[:upper:]' '[:lower:]'`
echo $RET
}

read_config() {
MD5_HASH_SAVED=($(cat $HASHFILE))
MD5_HASH_CONFIG=($(md5sum $CONFIGFILE| cut -d ' ' -f 1))
Expand All @@ -97,6 +106,7 @@ read_config() {
writelog "I" "(Re-)Reading config file..."
CHECKHOSTS=`cat $CONFIGFILE | grep "^CHECKHOSTS" | cut -d= -f2`
CHECKHOSTS="$CHECKHOSTS "
CHECKHOSTS=`string_to_lower "$CHECKHOSTS"`
writelog "I" "Set CHECKHOSTS to value $CHECKHOSTS"

MYNAME=`cat $CONFIGFILE | grep "^MYNAME" | cut -d= -f2`
Expand Down Expand Up @@ -199,10 +209,6 @@ read_config() {
fi
}

get_hostname_from_ip(){
RET=`arp -a|grep $1|awk '{print $1}'|cut -d. -f1`
echo "$RET"
}

check_pidhash(){
MD5_HASHSCRIPT=($(md5sum $SCRIPTFILE| cut -d ' ' -f 1))
Expand Down Expand Up @@ -445,6 +451,8 @@ while true; do
# match marker systems with online systems (IP translated in hostname)
#
FOUND_SYS=$(nslookup $FOUND_IP | awk '/name/ {split ($4,elems,"."); print elems[1]}')
FOUND_SYS=`string_to_lower "$FOUND_SYS"`
writelog "D" "FOUND_SYS (lower)=$FOUND_SYS"
# find multi hostname systems (e.g. fritzbox)
FOUND_SYS_LINES=$(nslookup $FOUND_IP | awk '/name/ {split ($4,elems,"."); print elems[1]}'| wc -l)
# check valid ip address (vs. multiple hostnames)
Expand Down

0 comments on commit d4ba3c1

Please sign in to comment.