1
0
mirror of https://github.com/byReqz/conn.git synced 2024-11-22 00:53:14 +00:00

Add files via upload

- fix notification not displaying sometimes when using -w
- changed windows detection
This commit is contained in:
Nils 2021-01-22 13:59:50 +00:00 committed by GitHub
parent bb347b7b33
commit 6a4d8d7e8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

13
conn.sh
View File

@ -62,7 +62,7 @@ fi
fping=$(fping -a $2) fping=$(fping -a $2)
p135=$(nping -q1 -c1 -p135 $2) p135=$(nping -q1 -c1 -p135 $2)
p3389=$(nping -q1 -c1 -p3389 $2) p3389=$(nping -q1 -c1 -p3389 $2)
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]] || [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
echo "note: this seems to be a windows machine which does not respond to ICMP" echo "note: this seems to be a windows machine which does not respond to ICMP"
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
@ -91,7 +91,7 @@ fi
fping=$(fping -a $2) fping=$(fping -a $2)
p135=$(nping -q1 -c1 -p135 $2) p135=$(nping -q1 -c1 -p135 $2)
p3389=$(nping -q1 -c1 -p3389 $2) p3389=$(nping -q1 -c1 -p3389 $2)
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]] || [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
echo "note: this seems to be a windows machine which does not respond to ICMP" echo "note: this seems to be a windows machine which does not respond to ICMP"
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
@ -117,7 +117,7 @@ fi
fping=$(fping -6 -a $2) fping=$(fping -6 -a $2)
p135=$(nping -6 -q1 -c1 -p135 $2) p135=$(nping -6 -q1 -c1 -p135 $2)
p3389=$(nping -6 -q1 -c1 -p3389 $2) p3389=$(nping -6 -q1 -c1 -p3389 $2)
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]] || [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
echo "note: this seems to be a windows machine which does not respond to ICMP" echo "note: this seems to be a windows machine which does not respond to ICMP"
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
@ -148,7 +148,7 @@ fi
fping=$(fping -4 -a $2) fping=$(fping -4 -a $2)
p135=$(nping -4 -q1 -c1 -p135 $2) p135=$(nping -4 -q1 -c1 -p135 $2)
p3389=$(nping -4 -q1 -c1 -p3389 $2) p3389=$(nping -4 -q1 -c1 -p3389 $2)
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]] || [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
echo "note: this seems to be a windows machine which does not respond to ICMP" echo "note: this seems to be a windows machine which does not respond to ICMP"
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
@ -192,7 +192,7 @@ fi
fping=$(fping -a $2) fping=$(fping -a $2)
p135=$(nping -q1 -c1 -p135 $2) p135=$(nping -q1 -c1 -p135 $2)
p3389=$(nping -q1 -c1 -p3389 $2) p3389=$(nping -q1 -c1 -p3389 $2)
if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]];then if [[ $fping != "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]] || [[ $fping != "$2" ]] && [[ -n $(echo $p3389 | grep "Successful connections: 1") ]] || [[ $fping = "$2" ]] && [[ -n $(echo $p135 | grep "Successful connections: 1") ]];then
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
echo "note: this seems to be a windows machine which does not respond to ICMP" echo "note: this seems to be a windows machine which does not respond to ICMP"
notify-send "$2 is now reachable" "and seems to be a windows machine" -u normal -t 15000 -a conn notify-send "$2 is now reachable" "and seems to be a windows machine" -u normal -t 15000 -a conn
@ -200,7 +200,6 @@ fi
else else
while [[ "$(fping -m -q -u $2)" == "$2" ]]; do : while [[ "$(fping -m -q -u $2)" == "$2" ]]; do :
done done
# notify-send "$2 is now reachable" -u normal -t 15000 -a conn
echo "-------------------Availability----------------------" echo "-------------------Availability----------------------"
fping -e $2 fping -e $2
rescue=$(nping -q1 -c1 -p22,222 $2) rescue=$(nping -q1 -c1 -p22,222 $2)
@ -210,6 +209,8 @@ fi
elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then elif [[ -n $(echo $rescue | grep "Successful connections: 2") ]];then
echo "note: this machine seems to be in the rescue system" echo "note: this machine seems to be in the rescue system"
notify-send "$2 is now reachable" "and seems to be in the rescue system" -u normal -t 15000 -a conn notify-send "$2 is now reachable" "and seems to be in the rescue system" -u normal -t 15000 -a conn
else
notify-send "$2 is now reachable" -u normal -t 15000 -a conn
fi fi
echo "-----------------------------------------------------" echo "-----------------------------------------------------"
fi fi