2
0
Fork 0
mirror of https://github.com/alexanderepstein/Bash-Snippets synced 2018-11-08 02:59:35 +01:00

Check if curl is installed

This commit is contained in:
Alex Epstein 2017-06-29 16:39:36 -04:00
parent b319536c23
commit 1d782a374d
4 changed files with 39 additions and 1 deletions

View file

@ -4,6 +4,15 @@
base=""
exchangeTo=""
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
## types available on the API and guides user through input (doesnt take in arguments)
getBase()
@ -184,6 +193,7 @@ usage()
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
while getopts "uvh" opt; do

View file

@ -3,6 +3,15 @@
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()
{
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"
}
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
while getopts "uvh" opt; do

View file

@ -3,6 +3,14 @@
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()
{
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"
}
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

View file

@ -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
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()
{
country=$(curl -s ipinfo.io/country) > /dev/null ## grab the country
@ -87,7 +96,7 @@ usage()
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