|
1 | 1 | #!/bin/bash
|
| 2 | +set -e |
2 | 3 | pushd $(dirname $0)
|
3 | 4 |
|
4 | 5 | function build_greengrass_patched() {
|
5 | 6 | pushd examples/greengrass/parsec-greengrass-run-config/docker/
|
6 |
| -docker build . --tag parallaxsecond/greengrass_patched:latest |
| 7 | +docker build . --tag parallaxsecond/greengrass_patched:latest --progress plain |
7 | 8 | popd
|
8 | 9 | }
|
| 10 | +function copy_deps_from_greengrass_patched_to_local() { |
| 11 | + docker run -v ~/.m2/repository:/host_m2_repository parallaxsecond/greengrass_patched:latest \ |
| 12 | + /bin/bash -c "cp -r ~/.m2/repository/* /host_m2_repository" |
| 13 | +} |
9 | 14 |
|
10 | 15 | function build_parsec_containers() {
|
11 | 16 | pushd ./parsec-testcontainers/
|
|
14 | 19 | }
|
15 | 20 |
|
16 | 21 | function build_greengrass_with_provider() {
|
17 |
| - docker build . -f greengrass_demo/Dockerfile --tag parallaxsecond/greengrass_demo:latest |
| 22 | + docker build . -f greengrass_demo/Dockerfile --tag parallaxsecond/greengrass_demo:latest --progress plain |
18 | 23 | }
|
19 | 24 |
|
20 |
| -build_greengrass_patched |
21 |
| -build_parsec_containers |
22 |
| -build_greengrass_with_provider |
23 |
| - |
24 |
| - |
25 |
| -docker rm -f parsec_docker_run > /dev/null |
26 |
| -docker run -d --name parsec_docker_run \ |
27 |
| - -ti \ |
28 |
| - -v GG_PARSEC_STORE:/var/lib/parsec/mappings \ |
29 |
| - -v GG_PARSEC_SOCK:/run/parsec \ |
30 |
| - parallaxsecond/parsec:0.8.1 |
31 |
| - |
32 |
| - |
33 |
| -GG_THING_NAME=$(id -un)-gg-test |
34 |
| - |
35 |
| -source secrets.env |
36 |
| - |
| 25 | +function dirty_build_on_new_comits() { |
| 26 | + for repo in \ |
| 27 | + awslabs/aws-crt-java \ |
| 28 | + aws/aws-iot-device-sdk-java-v2 \ |
| 29 | + revaultch/aws-greengrass-nucleus; do |
| 30 | + curl -s https://api.github.com/repos/${repo}/commits/key-op-prototype |
| 31 | + done | md5 > greengrass_demo/dirty_repo.txt |
| 32 | + touch -t 190001010000 greengrass_demo/dirty_repo.txt |
| 33 | +} |
| 34 | +function parsec_run() { |
| 35 | + docker rm -f parsec_docker_run > /dev/null |
| 36 | + docker run -d --name parsec_docker_run \ |
| 37 | + -ti \ |
| 38 | + -v GG_PARSEC_STORE:/var/lib/parsec/mappings \ |
| 39 | + -v GG_PARSEC_SOCK:/run/parsec \ |
| 40 | + parallaxsecond/parsec:0.8.1 |
| 41 | +} |
37 | 42 | function gg_run() {
|
38 |
| -docker rm -f "${1}" >/dev/null |
39 |
| -# shellcheck disable=SC2086 |
40 |
| -docker run ${3} --name "${1}" \ |
41 |
| - -e GG_THING_NAME="${GG_THING_NAME}" \ |
42 |
| - -e GG_ADDITIONAL_CMD_ARGS="--trusted-plugin /provider.jar" \ |
43 |
| - -e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \ |
44 |
| - -e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \ |
45 |
| - -e AWS_REGION="${AWS_REGION}" \ |
46 |
| - -v GG_PARSEC_SOCK:/run/parsec \ |
47 |
| - -v GG_HOME:/home/ggc_user \ |
48 |
| - parallaxsecond/greengrass_demo:latest "${2}" |
| 43 | + docker rm -f "${1}" >/dev/null |
| 44 | + # shellcheck disable=SC2086 |
| 45 | + docker run ${3} --name "${1}" \ |
| 46 | + -e GG_THING_NAME="${GG_THING_NAME}" \ |
| 47 | + -e GG_ADDITIONAL_CMD_ARGS="--trusted-plugin /provider.jar" \ |
| 48 | + -e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \ |
| 49 | + -e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \ |
| 50 | + -e AWS_REGION="${AWS_REGION}" \ |
| 51 | + -v GG_PARSEC_SOCK:/run/parsec \ |
| 52 | + -v GG_HOME:/home/ggc_user \ |
| 53 | + parallaxsecond/greengrass_demo:latest "${2}" |
| 54 | +} |
| 55 | +function run_demo() { |
| 56 | + parsec_run |
| 57 | + GG_THING_NAME=$(id -un)-gg-test |
| 58 | + source secrets.env |
| 59 | + gg_run greengrass_demo_provisioning provision |
| 60 | + gg_run greengrass_demo_run run -d |
49 | 61 | }
|
50 | 62 |
|
51 |
| -gg_run greengrass_demo_provisioning provision |
52 |
| -gg_run greengrass_demo_run run -d |
53 |
| - |
| 63 | +function build() { |
| 64 | + echo "Starting build ..." |
| 65 | + dirty_build_on_new_comits |
| 66 | + build_greengrass_patched |
| 67 | + copy_deps_from_greengrass_patched_to_local |
| 68 | + build_parsec_containers |
| 69 | + build_greengrass_with_provider |
| 70 | + echo "Build Done." |
| 71 | +} |
| 72 | +if [ "${1}" == "" ]; then |
| 73 | + build |
| 74 | + run_demo |
| 75 | +else |
| 76 | + ${1} |
| 77 | +fi |
0 commit comments