-
Notifications
You must be signed in to change notification settings - Fork 4
/
vmware2vbox.sh
executable file
·55 lines (46 loc) · 1.55 KB
/
vmware2vbox.sh
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
50
51
52
53
54
55
#!/bin/bash
set -e
set -u
PATCHBIN=${PATCHBIN:='/usr/bin/patch'}
OSSLBIN=${OSSLBIN:='/opt/local/bin/openssl'}
SEDBIN=${SEDBIN:='/usr/bin/sed'}
OVFTOOL=${OVFTOOL:='/opt/vmware/ovftool/ovftool'}
OVFOPS=${OVFOPS:='-dm=monolithicSparse'}
OSVER=${OSVER:='5.5'}
OSDIST=${OSDIST:='centos'}
PUPPETVER=${PUPPETVER:='2.6.1'}
PATCH='--- CentOS-min.ovf 2010-08-27 12:11:48.000000000 -0700
+++ CentOS-min-edit.ovf 2010-08-27 12:14:38.000000000 -0700
@@ -14,11 +14,12 @@
<Description>The nat network</Description>
</Network>
</NetworkSection>
- <VirtualSystem ovf:id="vm">
+ <VirtualSystem ovf:id="Puppet Training">
<Info>A virtual machine</Info>
<Name>Puppet Training</Name>
- <OperatingSystemSection ovf:id="36" vmw:osType="centosGuest">
+ <OperatingSystemSection ovf:id="79">
<Info>The kind of installed guest operating system</Info>
+ <Description>RedHat</Description>
</OperatingSystemSection>
<VirtualHardwareSection>
<Info>Virtual hardware requirements</Info>
@@ -72,4 +73,4 @@
</Item>
</VirtualHardwareSection>
</VirtualSystem>
-</Envelope>
\ No newline at end of file
+</Envelope>'
${OVFTOOL} ${OVFOPS} ../${OSDIST}-${OSVER}-${PUPPETVER}/CentOS-min.vmx ${PWD}/CentOS-min.ovf
OVFFILE=`ls ${PWD} | grep \.ovf$`
MFFILE=`ls ${PWD} | grep \.mf$`
${PATCHBIN} ${OVFFILE} --posix --silent -u -i - <<PATCH_EOF
${PATCH}
PATCH_EOF
rm -f ${OVFFILE}.rej
rm -f ${OVFFILE}.orig
NEWSHA=`${OSSLBIN} sha1 ${OVFFILE}`
${SEDBIN} s/"SHA1(CentOS-min.ovf.*"/"${NEWSHA}"/ ${MFFILE} > ${MFFILE}.tmp
mv ${MFFILE}.tmp ${MFFILE}