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

add waiting for connection

This commit is contained in:
Nils 2021-01-16 17:07:39 +00:00 committed by GitHub
parent dad3bf062f
commit 19d9801807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

23
conn.sh
View File

@ -9,6 +9,7 @@ while [ ! -n "$1" ]; do
echo " -y/--yes -- portscan without asking"
echo " -n/--no -- dont portscan"
echo " -p/--portscan -- same as -y"
echo " -w/--wait -- wait for active connection"
exit
done
while [ ! -z "$1" ]; do
@ -21,6 +22,7 @@ while [ ! -z "$1" ]; do
echo " -y/--yes -- portscan without asking"
echo " -n/--no -- dont portscan"
echo " -p/--portscan -- same as -y"
echo " -w/--wait -- wait for active connection"
exit
elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then
echo "multi-ip mode, portscan disabled"
@ -55,6 +57,27 @@ while [ ! -z "$1" ]; do
fping -6 -c 4 -A $2
echo "------------------------------------------------"
exit
elif [[ "$1" == "-w" ]] || [[ "$1" == "--wait" ]];then
echo "-w used, waiting for active connection"
echo "checking connection status for $2"
while [[ "$(fping -q -u $2)" == "$2" ]]; do :
done
notify-send "$2 is now reachable" -u normal -t 8000 -a conn
echo "-------------------Availability----------------------"
fping -e $2
echo "-----------------------------------------------------"
echo "portscan? (y/n) (default: y)"
read portscan
if [[ "$portscan" = "y" ]] || [[ -z "$portscan" ]]; then
echo "-------------------Portscan---------------------"
nmap -Pn $2
fping -c 4 -A $2
echo "------------------------------------------------"
exit
elif [[ "$portscan" = "n" ]]; then
exit
fi
exit
#this checks if the ip is (not) ipv4 and then checks if it includes a :
elif [[ ! "$1" =~ [0-9]{1,3}(\.[0-9]{1,3}){3} ]] && [[ "$1" =~ [:] ]];then
echo "noticed IPv6 adress -> using -6"