Merge branch 'feature-iso-extract-from-url' into develop

This commit is contained in:
6543 2018-05-22 01:47:46 +02:00
commit 83d8ace4e5
2 changed files with 35 additions and 6 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 $@
}

View File

@ -15,18 +15,26 @@ function iso_extract() {
return 10 return 10
} }


iso_source="$1"
[ -f "$iso_source" ] || {
echo "### ERROR ### iso_extract: ISO \"$iso_source\" not exist!"
return 11
}

iso_extr_dir="$2" iso_extr_dir="$2"
[ -d "$iso_extr_dir" ] || { [ -d "$iso_extr_dir" ] || {
echo "### ERROR ### iso_extract: aim directory not exist!" echo "### ERROR ### iso_extract: aim directory not exist!"
return 12 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 #mace tmp mountpoint
tmpdir="`mktemp -d`" tmpdir="`mktemp -d`"
[ -d "$iso_extr_dir" ] && { [ -d "$iso_extr_dir" ] && {
@ -41,6 +49,7 @@ function iso_extract() {
#clear tmp mountpoint #clear tmp mountpoint
umount "$iso_source" umount "$iso_source"
rm -r "$tmpdir" rm -r "$tmpdir"
[ -n "$iso_tmp" ] && rm "$iso_tmp"
tmpdir= tmpdir=


echo "done" echo "done"