Skip to content

Commit 8ca5028

Browse files
author
Chiradeep Vittal
committed
bug 3981: Add more logs for long running operations
1 parent 1d8ece0 commit 8ca5028

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

scripts/storage/secondary/createtmplt.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# createtmplt.sh -- install a template
44

55
usage() {
6-
printf "Usage: %s: -t <template-fs> -n <templatename> -f <root disk file> -c <md5 cksum> -d <descr> -h [-u]\n" $(basename $0) >&2
6+
printf "Usage: %s: -t <template-fs> -n <templatename> -f <root disk file> -c <md5 cksum> -d <descr> -h [-u] \n" $(basename $0) >&2
77
}
88

99

@@ -45,6 +45,25 @@ untar() {
4545

4646
}
4747

48+
is_compressed() {
49+
local ft=$(file $1| awk -F" " '{print $2}')
50+
local tmpfile=${1}.tmp
51+
52+
case $ft in
53+
gzip) ctype="gzip"
54+
;;
55+
bzip2) ctype="bz2"
56+
;;
57+
ZIP) ctype="zip"
58+
;;
59+
*) echo "File $1 does not appear to be compressed" >&2
60+
return 1
61+
;;
62+
esac
63+
echo "Uncompressing to $tmpfile (type $ctype)...could take a long time" >&2
64+
return 0
65+
}
66+
4867
uncompress() {
4968
local ft=$(file $1| awk -F" " '{print $2}')
5069
local tmpfile=${1}.tmp
@@ -56,8 +75,8 @@ uncompress() {
5675
;;
5776
ZIP) unzip -q -p $1 | cat > $tmpfile
5877
;;
59-
*) printf "$1"
60-
return 0
78+
*) printf "$1"
79+
return 0
6180
;;
6281
esac
6382

@@ -78,7 +97,7 @@ create_from_file() {
7897
local tmpltimg=$2
7998
local tmpltname=$3
8099

81-
#copy the file to the disk
100+
echo "Moving to /$tmpltfs/$tmpltname...could take a while" >&2
82101
mv $tmpltimg /$tmpltfs/$tmpltname
83102

84103
}
@@ -147,6 +166,7 @@ if [ -n "$cksum" ]
147166
then
148167
verify_cksum $cksum $tmpltimg
149168
fi
169+
is_compressed $tmpltimg
150170
tmpltimg2=$(uncompress $tmpltimg)
151171
rollback_if_needed $tmpltfs $? "failed to uncompress $tmpltimg\n"
152172

0 commit comments

Comments
 (0)