Check if curl is installed
This commit is contained in:
parent
b319536c23
commit
1d782a374d
|
@ -4,6 +4,15 @@
|
||||||
base=""
|
base=""
|
||||||
exchangeTo=""
|
exchangeTo=""
|
||||||
currentVersion="1.2.0"
|
currentVersion="1.2.0"
|
||||||
|
|
||||||
|
checkCurl()
|
||||||
|
{
|
||||||
|
if ! command -v curl &>/dev/null ; then
|
||||||
|
echo "Error: this tool requires 'curl', please install it."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
## Grabs the base currency from the user and validates it with all the possible currency
|
## Grabs the base currency from the user and validates it with all the possible currency
|
||||||
## types available on the API and guides user through input (doesnt take in arguments)
|
## types available on the API and guides user through input (doesnt take in arguments)
|
||||||
getBase()
|
getBase()
|
||||||
|
@ -184,6 +193,7 @@ usage()
|
||||||
echo " -v Get the tool version"
|
echo " -v Get the tool version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkCurl || exit 1
|
||||||
checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here
|
checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here
|
||||||
|
|
||||||
while getopts "uvh" opt; do
|
while getopts "uvh" opt; do
|
||||||
|
|
|
@ -3,6 +3,15 @@
|
||||||
|
|
||||||
currentVersion="1.2.0"
|
currentVersion="1.2.0"
|
||||||
|
|
||||||
|
|
||||||
|
checkCurl()
|
||||||
|
{
|
||||||
|
if ! command -v curl &>/dev/null ; then
|
||||||
|
echo "Error: this tool requires 'curl', please install it."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
checkInternet()
|
checkInternet()
|
||||||
{
|
{
|
||||||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
||||||
|
@ -103,6 +112,7 @@ usage()
|
||||||
echo " -v Get the tool version"
|
echo " -v Get the tool version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkCurl || exit 1
|
||||||
checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here
|
checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here
|
||||||
|
|
||||||
while getopts "uvh" opt; do
|
while getopts "uvh" opt; do
|
||||||
|
|
|
@ -3,6 +3,14 @@
|
||||||
|
|
||||||
currentVersion="1.2.0"
|
currentVersion="1.2.0"
|
||||||
|
|
||||||
|
checkCurl()
|
||||||
|
{
|
||||||
|
if ! command -v curl &>/dev/null ; then
|
||||||
|
echo "Error: this tool requires 'curl', please install it."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
checkInternet()
|
checkInternet()
|
||||||
{
|
{
|
||||||
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 # query google with a get request
|
||||||
|
@ -116,6 +124,7 @@ usage()
|
||||||
echo " -v Get the tool version"
|
echo " -v Get the tool version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkCurl || exit 1
|
||||||
checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here
|
checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,15 @@
|
||||||
currentVersion="1.2.0" #This version variable should not have a v but should contain all other characters ex Github release tag is v1.2.4 currentVersion is 1.2.4
|
currentVersion="1.2.0" #This version variable should not have a v but should contain all other characters ex Github release tag is v1.2.4 currentVersion is 1.2.4
|
||||||
locale=$(echo $LANG | cut -c1-2)
|
locale=$(echo $LANG | cut -c1-2)
|
||||||
|
|
||||||
|
|
||||||
|
checkCurl()
|
||||||
|
{
|
||||||
|
if ! command -v curl &>/dev/null ; then
|
||||||
|
echo "Error: this tool requires 'curl', please install it."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
getIPWeather()
|
getIPWeather()
|
||||||
{
|
{
|
||||||
country=$(curl -s ipinfo.io/country) > /dev/null ## grab the country
|
country=$(curl -s ipinfo.io/country) > /dev/null ## grab the country
|
||||||
|
@ -87,7 +96,7 @@ usage()
|
||||||
echo " -v Get the tool version"
|
echo " -v Get the tool version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkCurl || exit 1
|
||||||
checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here
|
checkInternet || exit 1 # check if we have a valid internet connection if this isnt true the rest of the script will not work so stop here
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue