forked from metabrainz/musicbrainz-vm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·66 lines (55 loc) · 1.65 KB
/
install.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
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
#FTP_SERVER=ftp.musicbrainz.org
FTP_SERVER=ftp.eu.metabrainz.org
VMSIZE=50000
PG_DATA_FILE=./pg-data.vdi
vagrant up --no-provision
if [[ $? != "0" ]]; then
echo "creating the VM failed."
exit
fi
VMID=`vboxmanage showvminfo musicbrainz-vm --machinereadable | grep ^UUID | grep -o '[a-fA-F0-9]\{8\}-[a-fA-F0-9]\{4\}-[a-fA-F0-9]\{4\}-[a-fA-F0-9]\{4\}-[a-fA-F0-9]\{12\}'`
echo "VM UUID is $VMID"
if [[ $VMID == "" ]]; then
echo "Unable to detect the VM UUID"
exit
fi
# if not exists, vboxmanage closemedium ad26ad5c-b19e-46ba-bee6-88c4e82d7ec7 --delete
echo "Creating disk for VM $MVID"
VBoxManage createmedium disk --filename $PG_DATA_FILE --format VDI --size $VMSIZE
ERR=$?
if [[ $ERR != "0" ]]; then
echo "creating postgres medium failed. Error $ERR"
exit
fi
vagrant halt
if [[ $? != "0" ]]; then
echo "stopping the VM to attach a new disk failed"
exit
fi
VBoxManage storageattach $VMID --storagectl 'SATAController' --port 1 --device 0 --type hdd --medium $PG_DATA_FILE
if [[ $? != "0" ]]; then
echo "attaching postgres medium failed."
exit
fi
vagrant up --provision
if [[ $? != "0" ]]; then
echo "provisioning the VM failed."
exit
fi
echo "Create partitions and filesystem for postgres drive"
vagrant ssh -- sudo /vagrant/make-pg-fs.sh
if [[ $? != "0" ]]; then
echo "create partition and filesystem for postgres data failed"
exit
fi
vagrant ssh -- /vagrant/install-musicbrainz.sh
if [[ $? != "0" ]]; then
echo "installing the MusicBrainz software failed."
exit
fi
vagrant ssh -- /vagrant/load-data.sh $FTP_SERVER
if [[ $? != "0" ]]; then
echo "Loading the MusicBrainz data failed."
exit
fi