add new sub func

This commit is contained in:
6543 2018-05-22 01:38:30 +02:00
parent 2a081ad517
commit 05bf2a4cdf
1 changed files with 20 additions and 0 deletions

20
src/func/check_url Normal file
View File

@ -0,0 +1,20 @@
#!/bin/bash
#remaster lib
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }

#check_url [URL]
function check_url() {
URL="$1"
if [[ `wget -S --spider "$URL" 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then
echo "true"
return 0
else
echo "false"
return 1
fi
}

#this func is standalone executable
[ -n "$1" ] && {
check_url $@
}