Skip to content

Commit 15f5fa5

Browse files
author
Kelven Yang
committed
Make installrtng.sh support vmware template
1 parent 3dd6bec commit 15f5fa5

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

‎scripts/storage/secondary/installrtng.sh‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#!/bin/bash
22
# $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 $
33
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
55
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
77
}
88

99
mflag=
1010
fflag=
11-
while getopts 'm:f:u:F' OPTION
11+
ext="vhd"
12+
templateId=1
13+
while getopts 'm:f:u:Ft:e:' OPTION
1214
do
1315
case $OPTION in
1416
m) mflag=1
@@ -21,6 +23,10 @@ do
2123
url="$OPTARG"
2224
;;
2325
F) Fflag=1 ;;
26+
t) templateId="$OPTARG"
27+
;;
28+
e) ext="$OPTARG"
29+
;;
2430
?) usage
2531
exit 2
2632
;;
@@ -39,7 +45,7 @@ then
3945
exit 3
4046
fi
4147

42-
localfile=$(uuidgen).vhd
48+
localfile=$(uuidgen).$ext
4349

4450
if [ ! -d $mntpoint ]
4551
then
@@ -49,7 +55,7 @@ fi
4955

5056
mntpoint=`echo "$mntpoint" | sed 's|/*$||'`
5157

52-
destdir=$mntpoint/template/tmpl/1/1/
58+
destdir=$mntpoint/template/tmpl/1/$templateId/
5359

5460
mkdir -p $destdir
5561
if [ $? -ne 0 ]
@@ -73,7 +79,7 @@ then
7379
exit 4
7480
fi
7581

76-
destvhdfiles=$(find $destdir -name \*.vhd)
82+
destvhdfiles=$(find $destdir -name \*.$ext)
7783
if [ "$destvhdfiles" != "" ]
7884
then
7985
echo "Data already exists at destination $destdir -- use -F to force cleanup of old template"
@@ -116,16 +122,21 @@ then
116122
echo "Failed to install system vm template $tmpltimg to $destdir"
117123
fi
118124

125+
if [ "$ext" == "ova" ]
126+
then
127+
tar xvf $destdir/$tmpfile -C $destdir &> /dev/null
128+
fi
129+
119130
tmpltfile=$destdir/$localfile
120131
tmpltsize=$(ls -l $tmpltfile| awk -F" " '{print $5}')
121132

122-
echo "vhd=true" >> $destdir/template.properties
133+
echo "$ext=true" >> $destdir/template.properties
123134
echo "id=1" >> $destdir/template.properties
124135
echo "public=true" >> $destdir/template.properties
125-
echo "vhd.filename=$localfile" >> $destdir/template.properties
136+
echo "$ext.filename=$localfile" >> $destdir/template.properties
126137
echo "uniquename=routing" >> $destdir/template.properties
127-
echo "vhd.virtualsize=$tmpltsize" >> $destdir/template.properties
138+
echo "$ext.virtualsize=$tmpltsize" >> $destdir/template.properties
128139
echo "virtualsize=$tmpltsize" >> $destdir/template.properties
129-
echo "vhd.size=$tmpltsize" >> $destdir/template.properties
140+
echo "$ext.size=$tmpltsize" >> $destdir/template.properties
130141

131142
echo "Successfully installed system VM template $tmpltimg to $destdir"

0 commit comments

Comments
 (0)