3 # Runtime provisioning script for Vagrant-based training lab setup
5 # Location of the runtime files. MANIFEST must exist there, and
6 # describes what else needs to be downloaded: in the format:
7 # <FILENAME>:<BYTES>:<SHA256>
8 # Apart from the MANIFEST itself, all files should be compressed with
9 # gzip. In each case, the script will download $FILENAME.gz,
10 # decompress it and then validate the checksum
11 RUNTIME_DL=http://www.einval.org/share/arm-security/
17 # Make sure we have updates applied, and all our needed packages
19 apt-get dist-upgrade -y
20 apt-get install -y qemu-system-arm gcc-aarch64-linux-gnu
21 echo "Toolchain VM running!"
23 # Now grab the emulated runtime and start that
25 if [ ! -d runtime ]; then
30 echo "Checking / downloading files needed for the emulated runtime VM"
31 # Grab all the files we need, and check they're valid
32 echo " Downloading MANIFEST"
33 wget -nv -O MANIFEST $RUNTIME_DL/MANIFEST
34 for LINE in $(cat MANIFEST); do
35 FILENAME=$(echo $LINE | awk -F: '{print $1}')
36 MODE=$(echo $LINE | awk -F: '{print $2}')
37 BYTES=$(echo $LINE | awk -F: '{print $3}')
38 SHA=$(echo $LINE | awk -F: '{print $4}')
41 # Quick and dirty - if the file exists and is the right size,
43 echo " Checking $FILENAME.gz"
44 if [ -f $FILENAME ]; then
45 SIZE=$(stat -c%s $FILENAME)
46 if [ $SIZE = $BYTES ]; then
51 if [ $DL_NEEDED = 1 ]; then
52 # Grab a compressed version of the file, and extract it as we
54 echo " Downloading $FILENAME.gz"
55 wget -nv -O- $RUNTIME_DL/$FILENAME.gz | gzip -cd > $FILENAME
56 SHA_FILE=$(sha256sum $FILENAME | awk '{print $1}')
57 if [ $SHA_FILE != $SHA ]; then
58 echo "Failed to download $FILENAME.gz correctly. Abort"
65 echo "Starting emulated runtime VM next"