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

23
conn.sh
View File

@ -1,5 +1,11 @@
#!/bin/bash
version=19
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 "Options:"
@ -11,6 +17,7 @@ while [ ! -n "$1" ]; do
echo " -n/--no -- dont portscan"
echo " -p/--portscan -- same as -y"
echo " -w/--wait -- wait for active connection"
echo " -u/--update -- update the script to the newest version"
exit
done
while [ ! -z "$1" ]; do
@ -25,6 +32,7 @@ while [ ! -z "$1" ]; do
echo " -n/--no -- dont portscan"
echo " -p/--portscan -- same as -y"
echo " -w/--wait -- wait for active connection"
echo " -u/--update -- update the script to the newest version"
exit
elif [[ $1 == "-m" ]] || [[ "$1" == "--multi" ]];then
echo "multi-ip mode, portscan disabled"
@ -73,6 +81,19 @@ while [ ! -z "$1" ]; do
fping -6 -c 4 $2
echo "------------------------------------------------"
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
echo "-w used, waiting for active connection"
echo "checking connection status for $2"