-
Notifications
You must be signed in to change notification settings - Fork 1
/
createXO.bash
99 lines (71 loc) · 3.78 KB
/
createXO.bash
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
yum upgrade -y && yum autoremove -y
mkdir install-tmp
mv createXO.bash install-tmp
cd install-tmp
defaultSR=$(xe sr-list name-label="Local storage" | grep uuid | awk -F ': ' {'print $2'})
defaultNET=$(xe network-list bridge=xenbr0 | grep uuid | awk -F ': ' {'print $2'})
combustion-ISO () {
mkdir -p /var/opt/xen/ISO_Store
isoSR=$(xe sr-create name-label=LocalISO type=iso device-config:location=/var/opt/xen/ISO_Store device-config:legacy_mode=true content-type=iso)
curl -O https://raw.githubusercontent.com/HPPinata/Xen-Orchestra-Install/main/combustion.bash
while [ -z "$hashed_password" ]; do echo "Password previously unset or input inconsistent."; \
hashed_password="$(python3 -c 'import crypt; import getpass; \
tin = getpass.getpass(); tin2 = getpass.getpass(); print(crypt.crypt(tin)) if (tin == tin2) else ""')"; done
sed -i "s+HASHchangeME+$hashed_password+g" combustion.bash
mkdir -p disk/combustion
mv combustion.bash disk/combustion/script
yum install -y genisoimage
mkisofs -l -o orchestra_combustion.iso -V combustion disk
yum remove -y genisoimage && yum autoremove -y
cp orchestra_combustion.iso /var/opt/xen/ISO_Store
xe sr-scan uuid=$isoSR
}
disk-IMAGE () {
curl -O https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-kvm-and-xen.qcow2
yum install -y qemu-img --enablerepo base
qemu-img convert -O vpc openSUSE-MicroOS.x86_64-kvm-and-xen.qcow2 SUSE-MicroOS.vhd
vhd-util repair -n SUSE-MicroOS.vhd
vhd-util check -n SUSE-MicroOS.vhd
yum remove -y qemu-img && yum autoremove -y
}
create-TEMPLATE () {
clUID=$(xe vm-clone new-name-label=orchestra_clone new-name-description="Xen-Orchestra management VM clone pre install" uuid=$vmUID)
vdiUID=$(xe vm-disk-list uuid=$clUID | grep -A 1 VDI | grep uuid | awk -F ': ' {'print $2'})
xe vdi-param-set uuid=$vdiUID name-label=microos
snUID=$(xe vm-snapshot new-name-label=orchestra_preinstall new-name-description="Xen-Orchestra management VM clone pre install" uuid=$clUID)
xe snapshot-clone new-name-label=MicroOS_Template uuid=$snUID new-name-description="VM Template for an unconfigured MicroOS"
xe vm-uninstall uuid=$clUID force=true
}
create-VM () {
vmUID=$(xe vm-install new-name-label=orchestra new-name-description="Xen-Orchestra management VM" template-name-label="Other install media")
xe vm-memory-limits-set static-min=1GiB static-max=2GiB dynamic-min=1GiB dynamic-max=2GiB uuid=$vmUID
xe vm-param-set uuid=$vmUID HVM-boot-params:firmware=uefi
xe vif-create network-uuid=$defaultNET vm-uuid=$vmUID device=0
xe vm-disk-add disk-size=25GiB device=0 uuid=$vmUID
vdiUID=$(xe vm-disk-list uuid=$vmUID | grep -A 1 VDI | grep uuid | awk -F ': ' {'print $2'})
xe vdi-param-set uuid=$vdiUID name-label=orchestra
xe vdi-import uuid=$vdiUID filename=SUSE-MicroOS.vhd format=vhd --progress
create-TEMPLATE
xe vm-cd-add cd-name=orchestra_combustion.iso device=1 uuid=$vmUID
xe vm-cd-add cd-name=guest-tools.iso device=2 uuid=$vmUID
xe pool-param-set uuid=$(xe pool-list | grep uuid | awk -F ': ' {'print $2'}) other-config:auto_poweron=true
xe vm-param-set uuid=$vmUID other-config:auto_poweron=true
xe vm-snapshot new-name-label=orchestra_preinstall new-name-description="Xen-Orchestra management VM pre install" uuid=$vmUID
}
cleanup () {
cd .. && rm -rf install-tmp
yum install -y pv --enablerepo epel
yes | pv -SpeL1 -s 300 > /dev/null
yum remove -y pv && yum autoremove -y
xe vm-shutdown uuid=$vmUID
xe vm-cd-remove cd-name=orchestra_combustion.iso uuid=$vmUID
xe vm-cd-remove cd-name=guest-tools.iso uuid=$vmUID
xe vm-snapshot new-name-label=orchestra_postinstall new-name-description="Xen-Orchestra management VM post install" uuid=$vmUID
}
combustion-ISO
disk-IMAGE
create-VM
xe vm-start uuid=$vmUID
cleanup
reboot