forked from bitcraze/bitcraze-vm
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createBitcrazeVM.sh
executable file
·89 lines (73 loc) · 2.66 KB
/
createBitcrazeVM.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
ISO_FILE="xubuntu-14.04.4-desktop-i386.iso"
ISO_URL="http://se.archive.ubuntu.com/mirror/cdimage.ubuntu.com/xubuntu/releases/14.04/release/$ISO_FILE"
PACKER_FILE="bitcrazeVM_xubuntu-14.04.4-desktop.json"
PACKER_URL="https://releases.hashicorp.com/packer/0.8.6/packer_0.8.6_linux_386.zip"
PACKER_FILE1=bitcrazeVM_xubuntu-14.04.4-desktop_createVM.json
PACKER_FILE2=bitcrazeVM_xubuntu-14.04.4-desktop_provisionVM.json
GCC_ARM_FILE="gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2"
GCC_ARM_URL="https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/$GCC_ARM_FILE"
PYCHARM_FILE="pycharm-community-5.0.4.tar.gz"
PYCHARM_URL="https://download.jetbrains.com/python/$PYCHARM_FILE"
ECLIPSE_FILE="eclipse-cpp-mars-1-linux-gtk.tar.gz"
ECLIPSE_URL="http://saimei.acc.umu.se/mirror/eclipse.org/technology/epp/downloads/release/mars/1/$ECLIPSE_FILE"
CONTENT_DIR="contentForVM/"
#TODO: use wildcard
OVA_FILE=BitcrazeVM_0.9.ova
#Download ISO image (only if it's not already downloaded)
if [ -f "$ISO_FILE" ]
then
echo "$ISO_FILE found. Continuing..."
else
echo "$ISO_FILE not found. Starting download..."
wget $ISO_URL
fi
#Install packer (only if it's not already installed)
if type "packer" > /dev/null
then
echo "Packer already installed. Continuing..."
else
echo "Packer is not installed. Installing..."
wget $PACKER_URL
unzip packer*.zip $HOME/packer
sudo ln -s $HOME/packer/packer /usr/bin/packer
fi
#Download GCC ARM (63MB) (only if it's not already downloaded)
if [ -f "$CONTENT_DIR$GCC_ARM_FILE" ]
then
echo "$CONTENT_DIR$GCC_ARM_FILE found. Continuing..."
else
echo "$CONTENT_DIR$GCC_ARM_FILE not found. Starting download..."
wget -P $CONTENT_DIR $GCC_ARM_URL
fi
#Download Pycharm (130MB) (only if it's not already downloaded)
if [ -f "$CONTENT_DIR$PYCHARM_FILE" ]
then
echo "$CONTENT_DIR$PYCHARM_FILE found. Continuing..."
else
echo "$CONTENT_DIR$PYCHARM_FILE not found. Starting download..."
wget -P $CONTENT_DIR $PYCHARM_URL
fi
#Download Eclipse (182MB) (only if it's not already downloaded)
if [ -f "$CONTENT_DIR$ECLIPSE_FILE" ]
then
echo "$CONTENT_DIR$ECLIPSE_FILE found. Continuing..."
else
echo "$CONTENT_DIR$ECLIPSE_FILE not found. Starting download..."
wget -P $CONTENT_DIR $ECLIPSE_URL
fi
#Run packer
echo "Running packer..."
export PACKER_LOG=1
#If OVA already exists, skip VM creation step
if [ -f "output-virtualbox-iso/$OVA_FILE" ]
then
echo "OVA file found. Skipping VM creation..."
else
echo "OVA file not found. Starting VM creation..."
export PACKER_LOG_PATH="packerlog_create.txt"
packer build $PACKER_FILE1
fi
echo "Starting VM provisioning..."
export PACKER_LOG_PATH="packerlog_provision.txt"
packer build $PACKER_FILE2