3 # Runtime provisioning script for Vagrant-based training lab setup
5 # runtime type - arm32 (default) or arm64
7 if [ "$RUNTIME"x = ""x ]; then
13 # Location of the runtime files. MANIFEST must exist there, and
14 # describes what else needs to be downloaded: in the format:
15 # <FILENAME>:<MODE>:<BYTES>:<SHA256>
16 # Apart from the MANIFEST itself, all files should be compressed with
17 # gzip. In each case, the script will download $FILENAME.gz,
18 # decompress it and then validate the checksum
19 if [ "$OPTS"x = "localtest"x ]; then
20 RUNTIME_DL=http://www.einval.org/share/arm-security/$RUNTIME/
22 RUNTIME_DL=https://www.einval.com/arm/training-lab/$RUNTIME/
29 # Make sure we have updates applied, and all our needed packages. Kill
30 # inattended-upgrades if it's running, as it will clash here
31 killall unattended-upgrade unattended-upgrades || true
33 apt-get dist-upgrade -y
34 apt-get install -y qemu-system-arm gcc-aarch64-linux-gnu
35 echo "Toolchain VM running!"
37 # Now grab the emulated runtime and start that
39 if [ ! -d runtime ]; then
44 echo "Checking / downloading files needed for the emulated runtime VM"
45 # Grab all the files we need, and check they're valid
46 echo " Downloading MANIFEST"
47 wget -nv -O MANIFEST $RUNTIME_DL/MANIFEST
48 for LINE in $(cat MANIFEST); do
49 FILENAME=$(echo $LINE | awk -F: '{print $1}')
50 MODE=$(echo $LINE | awk -F: '{print $2}')
51 BYTES=$(echo $LINE | awk -F: '{print $3}')
52 SHA=$(echo $LINE | awk -F: '{print $4}')
55 # Quick and dirty - if the file exists and is the right size,
56 # we'll believe it's OK. This will save us downloading a 2G test
57 # image every time, but make sure we delete it if people are
59 echo " Checking $FILENAME.gz"
60 if [ -f $FILENAME ]; then
61 SIZE=$(stat -c%s $FILENAME)
62 if [ $SIZE = $BYTES ]; then
67 if [ "$OPTS"x = "nodownload"x ]; then
68 "IGNORING DOWNLOAD FOR $FILENAME"
71 if [ $DL_NEEDED = 1 ]; then
72 # Grab a compressed version of the file, and extract it as we
74 echo " Downloading $FILENAME.gz"
75 wget -nv -O- $RUNTIME_DL/$FILENAME.gz | gzip -cd > $FILENAME
76 SHA_FILE=$(sha256sum $FILENAME | awk '{print $1}')
77 if [ $SHA_FILE != $SHA ]; then
78 echo "Failed to download $FILENAME.gz correctly. Abort"
85 echo "Starting emulated runtime VM next"
86 MACH=$RUNTIME ./start_runtime