Harald Hoyer 9e9f8f
From 7e60091c6b1aefb52581066d9dc04fa0ecc0e5fc Mon Sep 17 00:00:00 2001
Harald Hoyer 9e9f8f
From: Will Woods <wwoods@redhat.com>
Harald Hoyer 9e9f8f
Date: Thu, 8 Mar 2012 18:03:39 -0500
Harald Hoyer 9e9f8f
Subject: [PATCH] url-lib: clean up output
Harald Hoyer 9e9f8f
Harald Hoyer 9e9f8f
For curl_fetch_url (http/https/ftp):
Harald Hoyer 9e9f8f
- use --progress-bar (the output is less messy)
Harald Hoyer 9e9f8f
- print the URL we're fetching so the user know's what's happening
Harald Hoyer 9e9f8f
Harald Hoyer 9e9f8f
For curl and nfs:
Harald Hoyer 9e9f8f
- don't echo the filename if it was provided by the user
Harald Hoyer 9e9f8f
---
Harald Hoyer 9e9f8f
 modules.d/45url-lib/url-lib.sh |    7 ++++---
Harald Hoyer 9e9f8f
 1 file changed, 4 insertions(+), 3 deletions(-)
Harald Hoyer 9e9f8f
Harald Hoyer 9e9f8f
diff --git a/modules.d/45url-lib/url-lib.sh b/modules.d/45url-lib/url-lib.sh
Harald Hoyer 9e9f8f
index 043a700..e305a68 100755
Harald Hoyer 9e9f8f
--- a/modules.d/45url-lib/url-lib.sh
Harald Hoyer 9e9f8f
+++ b/modules.d/45url-lib/url-lib.sh
Harald Hoyer 9e9f8f
@@ -53,9 +53,10 @@ add_url_handler() {
Harald Hoyer 9e9f8f
 
Harald Hoyer 9e9f8f
 export CURL_HOME="/run/initramfs/url-lib"
Harald Hoyer 9e9f8f
 mkdir -p $CURL_HOME
Harald Hoyer 9e9f8f
-curl_args="--location --retry 3 --fail --show-error"
Harald Hoyer 9e9f8f
+curl_args="--location --retry 3 --fail --show-error --progress-bar"
Harald Hoyer 9e9f8f
 curl_fetch_url() {
Harald Hoyer 9e9f8f
     local url="$1" outloc="$2"
Harald Hoyer 9e9f8f
+    echo "$url" > /proc/self/fd/0
Harald Hoyer 9e9f8f
     if [ -n "$outloc" ]; then
Harald Hoyer 9e9f8f
         curl $curl_args --output "$outloc" "$url" || return $?
Harald Hoyer 9e9f8f
     else
Harald Hoyer 9e9f8f
@@ -64,7 +65,7 @@ curl_fetch_url() {
Harald Hoyer 9e9f8f
         outloc="$outdir/$(ls -A $outdir)"
Harald Hoyer 9e9f8f
     fi
Harald Hoyer 9e9f8f
     [ -f "$outloc" ] || return 253
Harald Hoyer 9e9f8f
-    echo "$outloc"
Harald Hoyer 9e9f8f
+    if [ -z "$2" ]; then echo "$outloc" ; fi
Harald Hoyer 9e9f8f
 }
Harald Hoyer 9e9f8f
 add_url_handler curl_fetch_url http https ftp
Harald Hoyer 9e9f8f
 
Harald Hoyer 9e9f8f
@@ -110,6 +111,6 @@ nfs_fetch_url() {
Harald Hoyer 9e9f8f
         cp -f "$mntdir/$filename" "$outloc" || return $?
Harald Hoyer 9e9f8f
     fi
Harald Hoyer 9e9f8f
     [ -f "$outloc" ] || return 253
Harald Hoyer 9e9f8f
-    echo "$outloc"
Harald Hoyer 9e9f8f
+    if [ -z "$2" ]; then echo "$outloc" ; fi
Harald Hoyer 9e9f8f
 }
Harald Hoyer 9e9f8f
 command -v nfs_to_var >/dev/null && add_url_handler nfs_fetch_url nfs nfs4