|
1 | 1 | #!/bin/bash |
2 | 2 | # $Id: installrtng.sh 11251 2010-07-23 23:40:44Z abhishek $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/installrtng.sh $ |
3 | 3 | usage() { |
4 | | - printf "Usage: %s: -m <secondary storage mount point> -f <system vm template file> [-F]\n" $(basename $0) >&2 |
| 4 | + printf "Usage: %s: -m <secondary storage mount point> -f <system vm template file> [-F] [-t <template id>] [-e <template extention name>]\n" $(basename $0) >&2 |
5 | 5 | printf "or\n" >&2 |
6 | | - printf "%s: -m <secondary storage mount point> -u <http url for system vm template> [-F]\n" $(basename $0) >&2 |
| 6 | + printf "%s: -m <secondary storage mount point> -u <http url for system vm template> [-F] [-t <template id>] [-e <template extention name>]\n" $(basename $0) >&2 |
7 | 7 | } |
8 | 8 |
|
9 | 9 | mflag= |
10 | 10 | fflag= |
11 | | -while getopts 'm:f:u:F' OPTION |
| 11 | +ext="vhd" |
| 12 | +templateId=1 |
| 13 | +while getopts 'm:f:u:Ft:e:' OPTION |
12 | 14 | do |
13 | 15 | case $OPTION in |
14 | 16 | m) mflag=1 |
|
21 | 23 | url="$OPTARG" |
22 | 24 | ;; |
23 | 25 | F) Fflag=1 ;; |
| 26 | + t) templateId="$OPTARG" |
| 27 | + ;; |
| 28 | + e) ext="$OPTARG" |
| 29 | + ;; |
24 | 30 | ?) usage |
25 | 31 | exit 2 |
26 | 32 | ;; |
|
39 | 45 | exit 3 |
40 | 46 | fi |
41 | 47 |
|
42 | | -localfile=$(uuidgen).vhd |
| 48 | +localfile=$(uuidgen).$ext |
43 | 49 |
|
44 | 50 | if [ ! -d $mntpoint ] |
45 | 51 | then |
|
49 | 55 |
|
50 | 56 | mntpoint=`echo "$mntpoint" | sed 's|/*$||'` |
51 | 57 |
|
52 | | -destdir=$mntpoint/template/tmpl/1/1/ |
| 58 | +destdir=$mntpoint/template/tmpl/1/$templateId/ |
53 | 59 |
|
54 | 60 | mkdir -p $destdir |
55 | 61 | if [ $? -ne 0 ] |
|
73 | 79 | exit 4 |
74 | 80 | fi |
75 | 81 |
|
76 | | -destvhdfiles=$(find $destdir -name \*.vhd) |
| 82 | +destvhdfiles=$(find $destdir -name \*.$ext) |
77 | 83 | if [ "$destvhdfiles" != "" ] |
78 | 84 | then |
79 | 85 | echo "Data already exists at destination $destdir -- use -F to force cleanup of old template" |
@@ -116,16 +122,21 @@ then |
116 | 122 | echo "Failed to install system vm template $tmpltimg to $destdir" |
117 | 123 | fi |
118 | 124 |
|
| 125 | +if [ "$ext" == "ova" ] |
| 126 | +then |
| 127 | + tar xvf $destdir/$tmpfile -C $destdir &> /dev/null |
| 128 | +fi |
| 129 | + |
119 | 130 | tmpltfile=$destdir/$localfile |
120 | 131 | tmpltsize=$(ls -l $tmpltfile| awk -F" " '{print $5}') |
121 | 132 |
|
122 | | -echo "vhd=true" >> $destdir/template.properties |
| 133 | +echo "$ext=true" >> $destdir/template.properties |
123 | 134 | echo "id=1" >> $destdir/template.properties |
124 | 135 | echo "public=true" >> $destdir/template.properties |
125 | | -echo "vhd.filename=$localfile" >> $destdir/template.properties |
| 136 | +echo "$ext.filename=$localfile" >> $destdir/template.properties |
126 | 137 | echo "uniquename=routing" >> $destdir/template.properties |
127 | | -echo "vhd.virtualsize=$tmpltsize" >> $destdir/template.properties |
| 138 | +echo "$ext.virtualsize=$tmpltsize" >> $destdir/template.properties |
128 | 139 | echo "virtualsize=$tmpltsize" >> $destdir/template.properties |
129 | | -echo "vhd.size=$tmpltsize" >> $destdir/template.properties |
| 140 | +echo "$ext.size=$tmpltsize" >> $destdir/template.properties |
130 | 141 |
|
131 | 142 | echo "Successfully installed system VM template $tmpltimg to $destdir" |
0 commit comments