-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild_demo.sh
executable file
·94 lines (86 loc) · 2.66 KB
/
build_demo.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
88
89
90
91
92
93
94
#!/bin/bash
set -e
pushd $(dirname $0)
md5_cmd=md5
if ! test -x /sbin/md5; then
md5_cmd=md5sum
fi
GG_THING_NAME=$(id -un)-greengrass-parsec
if test -e /etc/hostname; then
GG_THING_NAME=$(cat /etc/hostname)-greengrass-parsec
fi
function dirty_build_on_new_comits() {
for repo in \
awslabs/aws-crt-java \
aws/aws-iot-device-sdk-java-v2 \
revaultch/aws-greengrass-nucleus; do
curl -S https://api.github.com/repos/${repo}/commits/key-op-prototype
done | ${md5_cmd} | cut -d" " -f1 > greengrass_demo/dirty_repo.txt
touch -t 190001010000 greengrass_demo/dirty_repo.txt
export DIRTY_TS=$(cat greengrass_demo/dirty_repo.txt)
}
function build_greengrass_patched() {
pushd examples/greengrass/parsec-greengrass-run-config/docker/
docker build . \
--build-arg BUILD_TS=${DIRTY_TS} \
--tag parallaxsecond/greengrass_patched:latest \
--progress plain
popd
}
function copy_deps_from_greengrass_patched_to_local() {
docker run -v ~/.m2/repository:/host_m2_repository parallaxsecond/greengrass_patched:latest \
/bin/bash -c "cp -r ~/.m2/repository/* /host_m2_repository"
}
function build_parsec_containers() {
pushd ./parsec-testcontainers/
./build.sh
popd
}
function build_greengrass_with_provider() {
docker build . -f greengrass_demo/Dockerfile --tag parallaxsecond/greengrass_demo:latest --progress plain
}
function parsec_run() {
docker rm -f parsec_docker_run 2> /dev/null
docker run -d --name parsec_docker_run \
-ti \
-v GG_PARSEC_STORE:/var/lib/parsec/mappings \
-v GG_PARSEC_SOCK:/run/parsec \
parallaxsecond/parsec:0.8.1
}
function gg_run() {
docker rm -f "${1}" 2> /dev/null
# shellcheck disable=SC2086
docker run ${3} \
--name "${1}" \
-e GG_THING_NAME="${GG_THING_NAME}" \
-e GG_ADDITIONAL_CMD_ARGS="--trusted-plugin /provider.jar" \
-e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
-e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
-e AWS_REGION="${AWS_REGION}" \
-e AWS_SESSION_TOKEN="${AWS_SESSION_TOKEN}" \
-v GG_PARSEC_SOCK:/run/parsec \
-v GG_HOME:/home/ggc_user \
parallaxsecond/greengrass_demo:latest "${2}"
}
function run_demo() {
parsec_run
source secrets.env
gg_run greengrass_demo_provisioning provision
gg_run greengrass_demo_run run "-d -p 1441:1441 -p 1442:1442"
docker logs -f greengrass_demo_run
}
function build() {
echo "Starting build ..."
dirty_build_on_new_comits
build_greengrass_patched
copy_deps_from_greengrass_patched_to_local
build_parsec_containers
build_greengrass_with_provider
echo "Build Done."
}
if [ "${1}" == "" ]; then
build
run_demo
else
${1}
fi