Not only does the original suffer from re-computing the same value over
and over despite 'tmpfile' having been defined. This makes a maintenance
headache.

Worse, downloading files into /usr/lib* is VERBOTEN!! Options like
/var/{tmp,lib} are at least proper but it makes vastly more sense to put
the downloads in the TLD of the path we're installing to.

Even better would be a command line argument to specify the tmpfile location.

--- cloud-install-sys-tmplt.orig        2012-08-03 13:26:44.568709050 -0400
+++ cloud-install-sys-tmplt     2012-08-03 14:07:11.333716996 -0400
@@ -161,20 +161,20 @@
   failed 5
 fi

-tmpfile=$(dirname $0)/$localfile
+tmpfile=$mntpoint/$localfile

 touch $tmpfile
 if [ $? -ne 0 ]
 then
-  printf "Failed to create temporary file in directory $(dirname $0) --
is it read-only or full?\n"
+  printf "Failed to create temporary file in directory $(dirname
$tmpfile) -- is it read-only or full?\n"
   failed 4
 fi

 destcap=$(df -P $destdir | awk '{print $4}' | tail -1 )
 [ $destcap -lt $DISKSPACE ] && echo "Insufficient free disk space for
target folder $destdir: avail=${destcap}k req=${DISKSPACE}k" && failed 4

-localcap=$(df -P $(dirname $0) | awk '{print $4}' | tail -1 )
-[ $localcap -lt $DISKSPACE ] && echo "Insufficient free disk space for
local temporary folder $(dirname $0): avail=${localcap}k
req=${DISKSPACE}k" && failed 4
+localcap=$(df -P $(dirname $tmpfile) | awk '{print $4}' | tail -1 )
+[ $localcap -lt $DISKSPACE ] && echo "Insufficient free disk space for
local temporary folder $(dirname $tmpfile): avail=${localcap}k
req=${DISKSPACE}k" && failed 4

 if [ "$uflag" == "1" ]
 then
@@ -192,7 +192,7 @@
   cp $tmpltimg $tmpfile
   if [ $? -ne 0 ]
   then
-    printf "Failed to create temporary file in directory $(dirname $0) --
is it read-only or full?\n"
+    printf "Failed to create temporary file in directory $(dirname
$tmpfile) -- is it read-only or full?\n"
     failed 6
   fi
 fi


Reply via email to