-
Notifications
You must be signed in to change notification settings - Fork 3
/
arm-run.sh
executable file
·54 lines (42 loc) · 1.2 KB
/
arm-run.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
#!/usr/bin/env bash
set -e
cwd=`pwd`
if [ "$(basename $cwd)" != "packer-builder-arm-image" ]; then
echo "Expecting to be run from packer-builder-arm-image checkout" 1>&2
exit 1
fi
source=$(dirname $0)
usage="Usage: $0
or
$0 packerfile.json
or
$0 packerfile.json packerfile.jsonnet"
case $# in
2) PACKERFILE="$1"
jsonnet -o $PACKERFILE $source/`basename "$PACKERFILE" .json`.jsonnet
;;
1) PACKERFILE="$1"
;;
0) PACKERFILE="packer-arm.json"
;;
*) echo "$usage" 1>&2
exit 1
;;
esac
if [ ! -f "$PACKERFILE" ]; then
echo "$usage" 1>&2
exit 1
fi
# don't assume jq is installed, use grep/sed instead
# iso_url=$(jq -r .builders[0].iso_url < $PACKERFILE)
iso_url=$(grep '"iso_url":' < $PACKERFILE |sed -e 's/"iso_url": "//' -e 's/",//')
iso_base=$(basename "$iso_url")
if [ ! -f "$iso_base" ]; then
echo "Downloading ARM OS image $iso_base"
curl -s -o "$iso_base" "https://downloads.raspberrypi.org/raspbian_lite/images/${iso_base}"
fi
echo "Copying ~/.ssh/id_rsa.pub to target authorized_keys"
cp ~/.ssh/id_rsa.pub ./authorized_keys
mkdir -p packages
cp -a $source/packages/{all,arm*} packages/
PACKERFILE=$PACKERFILE vagrant provision --provision-with build-image