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

adding updater

This commit is contained in:
Nils 2021-01-19 19:03:11 +00:00 committed by GitHub
parent 256a92ebdc
commit c287d5ec65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

33
conn.sh
View File

@ -1,6 +1,12 @@
#!/bin/bash #!/bin/bash
version=19
while [ ! -n "$1" ]; do if [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/version) > "$version" ]] && [[ -z $1 ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/version) > "$version" ]] && [[ $1 != "--update" ]] || [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/version) > "$version" ]] && [[ $1 != "-u" ]];then
echo "#############################################"
echo -e "\e[4mnote: newer version detected, use -u to update\e[0m"
echo "#############################################"
echo ""
fi
while [ ! -n "$1" ]; do
echo "Usage: $0 (options) <ip>" echo "Usage: $0 (options) <ip>"
echo "Options:" echo "Options:"
echo " -m/--multi -- test multiple ips / disable portscan" echo " -m/--multi -- test multiple ips / disable portscan"
@ -11,9 +17,10 @@ while [ ! -n "$1" ]; do
echo " -n/--no -- dont portscan" echo " -n/--no -- dont portscan"
echo " -p/--portscan -- same as -y" echo " -p/--portscan -- same as -y"
echo " -w/--wait -- wait for active connection" echo " -w/--wait -- wait for active connection"
echo " -u/--update -- update the script to the newest version"
exit exit
done done
while [ ! -z "$1" ]; do while [ ! -z "$1" ]; do
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]];then if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]];then
echo "Usage: $0 (options) <ip> (y/n)" echo "Usage: $0 (options) <ip> (y/n)"
echo "Options:" echo "Options:"
@ -25,6 +32,7 @@ while [ ! -z "$1" ]; do
echo " -n/--no -- dont portscan" echo " -n/--no -- dont portscan"
echo " -p/--portscan -- same as -y" echo " -p/--portscan -- same as -y"
echo " -w/--wait -- wait for active connection" echo " -w/--wait -- wait for active connection"
echo " -u/--update -- update the script to the newest version"
exit exit
elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then
echo "multi-ip mode, portscan disabled" echo "multi-ip mode, portscan disabled"
@ -73,6 +81,19 @@ while [ ! -z "$1" ]; do
fping -6 -c 4 $2 fping -6 -c 4 $2
echo "------------------------------------------------" echo "------------------------------------------------"
exit exit
elif [[ $1 == "-u" ]] || [[ "$1" == "--update" ]];then
if [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/version) > "$version" ]];then
wget -O $0 --quiet "https://raw.githubusercontent.com/byReqz/conn/main/conn.sh"
echo "#############################################"
echo -e "\e[4mscript has been updated to the newest version\e[0m"
echo "#############################################"
exit
elif [[ $(curl -s https://raw.githubusercontent.com/byReqz/conn/main/version) < "$version" ]];then
echo "#############################################"
echo "no newer version found"
echo "#############################################"
exit
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"
@ -142,5 +163,5 @@ while [ ! -z "$1" ]; do
else else
exit exit
fi fi
fi fi
done done