mirror of
https://github.com/byReqz/conn.git
synced 2024-11-01 01:03:14 +00:00
add os check
This commit is contained in:
parent
fbfe7cba16
commit
c72d5ab03f
54
conn.sh
54
conn.sh
@ -42,6 +42,13 @@ fi
|
|||||||
exit
|
exit
|
||||||
elif [[ $1 == "-y" ]] || [[ $1 == "-p" ]] || [[ "$1" == "--portscan" ]] || [[ "$1" == "--yes" ]];then
|
elif [[ $1 == "-y" ]] || [[ $1 == "-p" ]] || [[ "$1" == "--portscan" ]] || [[ "$1" == "--yes" ]];then
|
||||||
echo "checking connection status for $2"
|
echo "checking connection status for $2"
|
||||||
|
if [[ -n $(nmap -p22 $1 | grep open) ]] && [[ -z $(nmap -p222 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a linux machine"
|
||||||
|
echo ""
|
||||||
|
elif [[ -n $(nmap -p3389 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a windows server machine"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -e $2
|
fping -e $2
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
@ -53,6 +60,13 @@ fi
|
|||||||
exit
|
exit
|
||||||
elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then
|
elif [[ $1 == "-n" ]] || [[ "$1" == "--no" ]];then
|
||||||
echo "checking connection status for $2"
|
echo "checking connection status for $2"
|
||||||
|
if [[ -n $(nmap -p22 $1 | grep open) ]] && [[ -z $(nmap -p222 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a linux machine"
|
||||||
|
echo ""
|
||||||
|
elif [[ -n $(nmap -p3389 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a windows server machine"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -e $2
|
fping -e $2
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
@ -60,6 +74,13 @@ fi
|
|||||||
elif [[ $1 == "-6" ]] || [[ "$1" == "--force-ipv6" ]];then
|
elif [[ $1 == "-6" ]] || [[ "$1" == "--force-ipv6" ]];then
|
||||||
echo "-6 used, forcing IPv6 portscanning"
|
echo "-6 used, forcing IPv6 portscanning"
|
||||||
echo "checking connection status for $2"
|
echo "checking connection status for $2"
|
||||||
|
if [[ -n $(nmap -6 -p22 $1 | grep open) ]] && [[ -z $(nmap -6 -p222 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a linux machine"
|
||||||
|
echo ""
|
||||||
|
elif [[ -n $(nmap -6 -p3389 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a windows server machine"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -6 -e $2
|
fping -6 -e $2
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
@ -72,6 +93,13 @@ fi
|
|||||||
elif [[ $1 == "-4" ]] || [[ "$1" == "--force-ipv4" ]];then
|
elif [[ $1 == "-4" ]] || [[ "$1" == "--force-ipv4" ]];then
|
||||||
echo "-4 used, forcing IPv4 portscanning"
|
echo "-4 used, forcing IPv4 portscanning"
|
||||||
echo "checking connection status for $2"
|
echo "checking connection status for $2"
|
||||||
|
if [[ -n $(nmap -p22 $1 | grep open) ]] && [[ -z $(nmap -p222 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a linux machine"
|
||||||
|
echo ""
|
||||||
|
elif [[ -n $(nmap -p3389 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a windows server machine"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -4 -e $2
|
fping -4 -e $2
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
@ -97,9 +125,21 @@ fi
|
|||||||
elif [[ "$1" == "-w" ]] || [[ "$1" == "--wait" ]];then
|
elif [[ "$1" == "-w" ]] || [[ "$1" == "--wait" ]];then
|
||||||
echo "-w used, waiting for active connection"
|
echo "-w used, waiting for active connection"
|
||||||
echo "checking connection status for $2"
|
echo "checking connection status for $2"
|
||||||
|
if [[ -n $(nmap -p22 $1 | grep open) ]] && [[ -z $(nmap -p222 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a linux machine"
|
||||||
|
echo ""
|
||||||
|
elif [[ -n $(nmap -p3389 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a windows server machine, it might not respond to icmp"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
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
|
notify-send "$2 is now reachable" -u normal -t 15000 -a conn
|
||||||
|
if [[ -n $(nmap -p22 $1 | grep open) ]] && [[ -z $(nmap -p222 $1 | grep open) ]];then
|
||||||
|
notify-send "$2 seems to be booted into a linux install" -t 15000 -a conn -u normal
|
||||||
|
elif [[ -n $(nmap -p3389 $1 | grep open) ]];then
|
||||||
|
notify-send "$2 seems to be booted into a windows install" -t 15000 -a conn -u normal
|
||||||
|
fi
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -e $2
|
fping -e $2
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
@ -119,6 +159,13 @@ fi
|
|||||||
elif [[ ! "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$1" =~ [:] ]] && [[ ! "$2" =~ [:] ]] && [[ -z "$3" ]];then
|
elif [[ ! "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$1" =~ [:] ]] && [[ ! "$2" =~ [:] ]] && [[ -z "$3" ]];then
|
||||||
echo "detected IPv6 adress -> using -6"
|
echo "detected IPv6 adress -> using -6"
|
||||||
echo "checking connection status for $1"
|
echo "checking connection status for $1"
|
||||||
|
if [[ -n $(nmap -6 -p22 $1 | grep open) ]] && [[ -z $(nmap -6 -p222 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a linux machine"
|
||||||
|
echo ""
|
||||||
|
elif [[ -n $(nmap -6 -p3389 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a windows server machine"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -6 -e $1
|
fping -6 -e $1
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
@ -148,6 +195,13 @@ fi
|
|||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
echo "checking connection status for $1"
|
echo "checking connection status for $1"
|
||||||
|
if [[ -n $(nmap -p22 $1 | grep open) ]] && [[ -z $(nmap -p222 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a linux machine"
|
||||||
|
echo ""
|
||||||
|
elif [[ -n $(nmap -p3389 $1 | grep open) ]];then
|
||||||
|
echo "note: system seems to be a windows server machine"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
echo "-------------------Availability----------------------"
|
echo "-------------------Availability----------------------"
|
||||||
fping -e $1
|
fping -e $1
|
||||||
echo "-----------------------------------------------------"
|
echo "-----------------------------------------------------"
|
||||||
|
Loading…
Reference in New Issue
Block a user