From 8f1c4e4107b2552d546181289020375c25982176 Mon Sep 17 00:00:00 2001 From: Gianpaolo Macario Date: Sun, 24 Jan 2016 09:38:38 +0100 Subject: [PATCH 1/6] Add support for implementing a gocd agent Signed-off-by: Gianpaolo Macario --- build-yocto-genivi/Dockerfile | 1 + build-yocto-genivi/run-gocd-agent.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100755 build-yocto-genivi/run-gocd-agent.sh diff --git a/build-yocto-genivi/Dockerfile b/build-yocto-genivi/Dockerfile index 67f2fa6..3f37d8d 100644 --- a/build-yocto-genivi/Dockerfile +++ b/build-yocto-genivi/Dockerfile @@ -66,6 +66,7 @@ RUN id build >/dev/null || useradd --create-home --shell /bin/bash build RUN mkdir -p /usr/local/bin COPY clone-and-build-gdp.sh /usr/local/bin/ +COPY run-gocd-agent.sh /usr/local/bin/ RUN dos2unix /usr/local/bin/*.sh && chmod 755 /usr/local/bin/*.sh # Expose sshd port diff --git a/build-yocto-genivi/run-gocd-agent.sh b/build-yocto-genivi/run-gocd-agent.sh new file mode 100755 index 0000000..1391336 --- /dev/null +++ b/build-yocto-genivi/run-gocd-agent.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Run as a GoCD Agent + +set -x +set -e + +# TODO + +git config --global user.name "easy-build" +git config --global user.email "$(whoami)@$(hostname)" + +# TODO + +# EOF From 7b384f4b8be8c0f8f089e76c2e54f49a5b2600c4 Mon Sep 17 00:00:00 2001 From: Gianpaolo Macario Date: Tue, 26 Jan 2016 11:16:24 +0100 Subject: [PATCH 2/6] Configure and start go-agent Signed-off-by: Gianpaolo Macario --- build-yocto-genivi/run-gocd-agent.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/build-yocto-genivi/run-gocd-agent.sh b/build-yocto-genivi/run-gocd-agent.sh index 1391336..4838e88 100755 --- a/build-yocto-genivi/run-gocd-agent.sh +++ b/build-yocto-genivi/run-gocd-agent.sh @@ -1,15 +1,14 @@ #!/bin/bash - # Run as a GoCD Agent set -x set -e -# TODO - git config --global user.name "easy-build" git config --global user.email "$(whoami)@$(hostname)" -# TODO +cp /etc/default/go-agent go-agent.ORIG +sed 's/^GO_SERVER=.*$/GO_SERVER=go.genivi.org/g' go-agent.ORIG >/etc/default/go-agent +service go-agent start # EOF From 2ca543e038f98586b076f00925a7bfe3a281049d Mon Sep 17 00:00:00 2001 From: Gianpaolo Macario Date: Tue, 26 Jan 2016 11:28:56 +0100 Subject: [PATCH 3/6] Add sanity checks Signed-off-by: Gianpaolo Macario --- build-yocto-genivi/run-gocd-agent.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build-yocto-genivi/run-gocd-agent.sh b/build-yocto-genivi/run-gocd-agent.sh index 4838e88..d632b96 100755 --- a/build-yocto-genivi/run-gocd-agent.sh +++ b/build-yocto-genivi/run-gocd-agent.sh @@ -4,6 +4,17 @@ set -x set -e +# Sanity checks + +if [ $(whoami) != 'go' ]; then + echo "Please specify docker run --user go" + exit 1 +fi +if [ $(pwd) != '/var/lib/go-agent' ]; then + echo "Please specify docker run --workdir /var/lib/go-agent" + exit 1 +fi + git config --global user.name "easy-build" git config --global user.email "$(whoami)@$(hostname)" From 25770f42e4c9128556beb9529ffc33cb4a4f02ca Mon Sep 17 00:00:00 2001 From: Gianpaolo Macario Date: Tue, 26 Jan 2016 11:29:33 +0100 Subject: [PATCH 4/6] Comment script debugging flag Signed-off-by: Gianpaolo Macario --- build-yocto-genivi/run-gocd-agent.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-yocto-genivi/run-gocd-agent.sh b/build-yocto-genivi/run-gocd-agent.sh index d632b96..2a0a3db 100755 --- a/build-yocto-genivi/run-gocd-agent.sh +++ b/build-yocto-genivi/run-gocd-agent.sh @@ -1,7 +1,7 @@ #!/bin/bash # Run as a GoCD Agent -set -x +# set -x set -e # Sanity checks From bbd25b6367ae8d3ee873f9491be384a169990d91 Mon Sep 17 00:00:00 2001 From: Gianpaolo Macario Date: Tue, 26 Jan 2016 11:59:47 +0100 Subject: [PATCH 5/6] Enable GO_SERVER configuration via envvars Signed-off-by: Gianpaolo Macario --- build-yocto-genivi/run-gocd-agent.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build-yocto-genivi/run-gocd-agent.sh b/build-yocto-genivi/run-gocd-agent.sh index 2a0a3db..e7991f7 100755 --- a/build-yocto-genivi/run-gocd-agent.sh +++ b/build-yocto-genivi/run-gocd-agent.sh @@ -14,12 +14,16 @@ if [ $(pwd) != '/var/lib/go-agent' ]; then echo "Please specify docker run --workdir /var/lib/go-agent" exit 1 fi +if [ "${GO_SERVER}" == "" ]; then + export GO_SERVER=go.genivi.org + echo "GO_SERVER was not defined - setting to ${GO_SERVER}" +fi git config --global user.name "easy-build" git config --global user.email "$(whoami)@$(hostname)" cp /etc/default/go-agent go-agent.ORIG -sed 's/^GO_SERVER=.*$/GO_SERVER=go.genivi.org/g' go-agent.ORIG >/etc/default/go-agent +sed "s/^GO_SERVER=.*$/GO_SERVER=${GO_SERVER}/g" go-agent.ORIG >/etc/default/go-agent service go-agent start # EOF From b687a67cfb6c3a409c3e4ecf437049e6390078b9 Mon Sep 17 00:00:00 2001 From: Gianpaolo Macario Date: Tue, 26 Jan 2016 12:04:06 +0100 Subject: [PATCH 6/6] Add example of usage Signed-off-by: Gianpaolo Macario --- build-yocto-genivi/run-gocd-agent.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/build-yocto-genivi/run-gocd-agent.sh b/build-yocto-genivi/run-gocd-agent.sh index e7991f7..40d86ad 100755 --- a/build-yocto-genivi/run-gocd-agent.sh +++ b/build-yocto-genivi/run-gocd-agent.sh @@ -1,5 +1,17 @@ #!/bin/bash + +# =========================================================================== +# Project: gmacario/easy-build +# # Run as a GoCD Agent +# +# Example of usage +# +# $ docker run -d --user=go \ +# --hostname my-genivigo-testagent \ +# --workdir /var/lib/go-agent \ +# gmacario/build-yocto-genivi /usr/local/bin/run-gocd-agent.sh +# =========================================================================== # set -x set -e