diff --git a/src/func/check_url b/src/func/check_url new file mode 100644 index 0000000..53b23e0 --- /dev/null +++ b/src/func/check_url @@ -0,0 +1,20 @@ +#!/bin/bash +#remaster lib +[ -d "" ] || { 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 $@ +} diff --git a/src/func/iso_extract b/src/func/iso_extract index ab6c6df..d89ff28 100755 --- a/src/func/iso_extract +++ b/src/func/iso_extract @@ -15,18 +15,26 @@ function iso_extract() { return 10 } - iso_source="$1" - [ -f "$iso_source" ] || { - echo "### ERROR ### iso_extract: ISO \"$iso_source\" not exist!" - return 11 - } - iso_extr_dir="$2" [ -d "$iso_extr_dir" ] || { echo "### ERROR ### iso_extract: aim directory not exist!" return 12 } + iso_source="$1" + [ -f "$iso_source" ] || { + #if it is an url... + if [ "`check_url $iso_source`" == "true" ]; then + #dl to tmp + set iso_source + iso_tmp="`mktemp --suffix=.iso`"; rm "$iso_tmp" + wget -O "$iso_tmp" "$iso_source" + else + echo "### ERROR ### iso_extract: ISO \"$iso_source\" not exist!" + return 11 + fi + } + + #mace tmp mountpoint tmpdir="`mktemp -d`" [ -d "$iso_extr_dir" ] && { @@ -41,6 +49,7 @@ function iso_extract() { #clear tmp mountpoint umount "$iso_source" rm -r "$tmpdir" + [ -n "$iso_tmp" ] && rm "$iso_tmp" tmpdir= echo "done"