Newer
Older
#!/bin/bash
set -e
# This script installs a MS/worker/campus-manager/cache/MV through envsetup on a machine
# Prérequis
# 1/ create DNS entries
# alpha-auto.ubicast.net
# cm-alpha-auto.ubicast.net
# monitor-alpha-auto.ubicast.net
# 2/ create machine in panel
# 3/ envsetup-launcher.sh
# If you need any help filling the parameters, see
# https://git.ubicast.net/jallary/envsetup-launcher
# log
LOGFILE=/root/$(date +%F)_envsetup.log
exec > >(tee -i ${LOGFILE})
## envsetup integration
init() {
python3 /root/envsetup/envsetup.py 1
python3 /root/envsetup/envsetup.py 2
python3 /root/envsetup/envsetup.py 21
python3 /root/envsetup/envsetup.py 22
python3 /root/envsetup/envsetup.py 23
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
}
monitor() {
python3 /root/envsetup/envsetup.py 3
python3 /root/envsetup/envsetup.py 7
python3 /root/envsetup/envsetup.py 31
python3 /root/envsetup/envsetup.py 32
}
mediaserver() {
python3 /root/envsetup/envsetup.py 3
python3 /root/envsetup/envsetup.py 5
python3 /root/envsetup/envsetup.py 6
python3 /root/envsetup/envsetup.py 8
python3 /root/envsetup/envsetup.py 61
python3 /root/envsetup/envsetup.py 7
python3 /root/envsetup/envsetup.py 41
python3 /root/envsetup/envsetup.py 42
python3 /root/envsetup/envsetup.py 7
}
worker() {
python3 /root/envsetup/envsetup.py 62
}
campusmanager() {
python3 /root/envsetup/envsetup.py 3
python3 /root/envsetup/envsetup.py 7
python3 /root/envsetup/envsetup.py 51
python3 /root/envsetup/envsetup.py 7
}
cache() {
python3 /root/envsetup/envsetup.py 71
python3 /root/envsetup/envsetup.py 72
python3 /root/envsetup/envsetup.py 73
python3 /root/envsetup/envsetup.py 42
}
tests() {
python3 /root/envsetup/envsetup.py t
}
backup_server() {
python3 /root/envsetup/envsetup.py 81
}
reconf_default() {
python3 /root/envsetup/envsetup.py 104
}
reconf_client() {
python3 /root/envsetup/envsetup.py 101
}
reconf_recette() {
python3 /root/envsetup/envsetup.py 102
}
reconf_smtp() {
python3 /root/envsetup/envsetup.py 103
}
python3 /root/envsetup/envsetup.py 105
}
exportvm() {
KEY=~/.ssh/ubicast_support
VM_HYPER=$(grep VM_HYPER ${CONF} | awk -F "=" '{print$2}')
VM_STORE=$(grep VM_STORE ${CONF} | head -1 | awk -F "=" '{print$2}')
VM_STORE_LOCAL=$(grep VM_STORE_LOCAL ${CONF} | awk -F "=" '{print$2}')
if ( test -z $VM_NAME ); then
VM_NAME=$(cat ${CONF} | egrep ^ETC_HOSTNAME | head -1 | awk -F "=" '{print$2}')
VM_NAME=$(grep VM ${CONF} | awk -F "=" '{print$2}')
ssh -i ${KEY} -o User=root ${VM_HYPER} "VBoxManage export ${VM_NAME} -o ${VM_STORE}/${VM_NAME}.ovf --ovf10"
# vbox conf file created
# generating vmware conf file
cp ${VM_STORE_LOCAL}/${VM_NAME}.ovf ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf
sed -i "s@<vssd:VirtualSystemType>virtualbox-2.2</vssd:VirtualSystemType>@<vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>@" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf
sed -i "s@<rasd:Caption>sataController0</rasd:Caption>@<rasd:Caption>SCSIController</rasd:Caption>@" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf
sed -i "s@<rasd:Description>SATA Controller</rasd:Description>@<rasd:Description>SCSIController</rasd:Description>@" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf
sed -i "s@<rasd:ElementName>sataController0</rasd:ElementName>@<rasd:ElementName>SCSIController</rasd:ElementName>@" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf
sed -i "s@<rasd:ResourceSubType>AHCI</rasd:ResourceSubType>@<rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>@" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf
sed -i "s@<rasd:ResourceType>20</rasd:ResourceType>@<rasd:ResourceType>6</rasd:ResourceType>@" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf
LIG=$(grep -n '<rasd:AddressOnParent>3</rasd:AddressOnParent>' ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf | awk -F ":" '{print$1}')
sed -i "${LIG0},${LIG1}d" ${VM_STORE_LOCAL}/${VM_NAME}_vmware.ovf
qemu-img convert -c -O qcow2 ${VM_STORE_LOCAL}/${VM_NAME}-disk1.vmdk ${VM_STORE_LOCAL}/${VM_NAME}.qcow2
echo -e "${CYAN}Files are available at ${VM_STORE_LOCAL}${NC}"
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
}
case "$1" in
"ms")
init
monitor
campusmanager
mediaserver
tests
;;
"w")
init
worker
tests
;;
"cm")
init
monitor
campusmanager
tests
;;
"cache")
init
cache
;;
"mv")
init
backup_server
;;
"reconf")
reconf_default
;;
"client")
reconf_client
reconf_recette
reconf_smtp
;;
"recette")
reconf_recette
;;
"wrecette")
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
reconf_recette
;;
"exportvm")
CONF=$(echo "$2")
exportvm
;;
*)
echo "
Usage: $0 [arg]
ms build a MediaServer & CM
w build a Worker
cm build a Campus-Manager
cache build a Cache server (munin needs manual configuration on master AND node)
mv build a MediaVault
--------------------------------------
reconf install a tool for post-shipping configuration
client deploy client configuration
--------------------------------------
recette run tests
wrecette deploy wowza license key and run tests
After usage a log file will be generated under /root/$(date +%F)_envsetup.log
From admin machine :
Usage: $0 exportvm [conf_file]
exportvm export VM"
;;
esac