forked from emerose/flint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage-vm
executable file
·50 lines (41 loc) · 1.05 KB
/
package-vm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
VMDIR=/var/lib/vmware/vms
VMNAME=$1
TDIR=$VMDIR/$VMNAME
SEEDVM=Playbook-JeOS
OVFTOOL=/usr/local/lib/vmware/ovftool/ovftool
function scrub_vmdir
{
rm -rf $TDIR/Ubuntu.*
rm -rf $TDIR/*JeOS*
rm -rf nvram
(cd $TDIR;
mv $VMNAME.vmx $VMNAME.vmx.off;
vmware-vdiskmanager -d root.vmdk;
vmware-vdiskmanager -k root.vmdk;
mv $VMNAME.vmx.off $VMNAME.vmx)
rm -rf $TDIR/*.log
}
function tar_vm
{
(cd $VMDIR; rm -f $VMNAME.tbz; tar cjvf $VMNAME.tbz $VMNAME)
}
function zip_vm
{
echo "Making zip archive $VMNAME.zip"
(cd $VMDIR; rm -f $VMNAME.zip; 7z a -xr\!*.vmsd -xr\!*nvram -tzip $VMNAME.zip $VMNAME)
}
function ovf_vm
{
echo "Making OVF distribution in $VMNAME.ovf.zip"
rm -f $VMDIR/$VMNAME.ovf.zip;
rm $VMDIR/$VMNAME.ovf
$OVFTOOL $VMDIR/$VMNAME/$VMNAME.vmx $VMDIR/$VMNAME/$VMNAME.ovf
(cd $VMDIR; 7z a -xr\!*.vmsd -xr\!*nvram -tzip $VMNAME.ovf.zip $VMNAME/$VMNAME-disk?.vmdk $VMNAME/$VMNAME.ovf)
}
scrub_vmdir
#tar_vm
zip_vm
ovf_vm
mv $VMDIR/$VMNAME.zip .
mv $VMDIR/$VMNAME.ovf.zip .