File tree Expand file tree Collapse file tree
scripts/storage/secondary Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33# createtmplt.sh -- install a template
44
55usage () {
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+
4867uncompress () {
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" ]
147166then
148167 verify_cksum $cksum $tmpltimg
149168fi
169+ is_compressed $tmpltimg
150170tmpltimg2=$( uncompress $tmpltimg )
151171rollback_if_needed $tmpltfs $? " failed to uncompress $tmpltimg \n"
152172
You can’t perform that action at this time.
0 commit comments