]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
url-lib: clean up output
authorWill Woods <wwoods@redhat.com>
Thu, 8 Mar 2012 23:03:39 +0000 (18:03 -0500)
committerHarald Hoyer <harald@redhat.com>
Fri, 9 Mar 2012 10:13:08 +0000 (11:13 +0100)
For curl_fetch_url (http/https/ftp):
- use --progress-bar (the output is less messy)
- print the URL we're fetching so the user know's what's happening

For curl and nfs:
- don't echo the filename if it was provided by the user

modules.d/45url-lib/url-lib.sh

index 043a700ffc1b4d59ce96a86a738a61c04aa9ab22..e305a68a550c17d3545f5152b5862f2964cb3fd5 100755 (executable)
@@ -53,9 +53,10 @@ add_url_handler() {
 
 export CURL_HOME="/run/initramfs/url-lib"
 mkdir -p $CURL_HOME
-curl_args="--location --retry 3 --fail --show-error"
+curl_args="--location --retry 3 --fail --show-error --progress-bar"
 curl_fetch_url() {
     local url="$1" outloc="$2"
+    echo "$url" > /proc/self/fd/0
     if [ -n "$outloc" ]; then
         curl $curl_args --output "$outloc" "$url" || return $?
     else
@@ -64,7 +65,7 @@ curl_fetch_url() {
         outloc="$outdir/$(ls -A $outdir)"
     fi
     [ -f "$outloc" ] || return 253
-    echo "$outloc"
+    if [ -z "$2" ]; then echo "$outloc" ; fi
 }
 add_url_handler curl_fetch_url http https ftp
 
@@ -110,6 +111,6 @@ nfs_fetch_url() {
         cp -f "$mntdir/$filename" "$outloc" || return $?
     fi
     [ -f "$outloc" ] || return 253
-    echo "$outloc"
+    if [ -z "$2" ]; then echo "$outloc" ; fi
 }
 command -v nfs_to_var >/dev/null && add_url_handler nfs_fetch_url nfs nfs4