Merge branch 'feature-iso-extract-from-url' into develop
This commit is contained in:
commit
83d8ace4e5
20
src/func/check_url
Normal file
20
src/func/check_url
Normal 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 $@
|
||||
}
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user