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..40d86ad --- /dev/null +++ b/build-yocto-genivi/run-gocd-agent.sh @@ -0,0 +1,41 @@ +#!/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 + +# 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 +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_SERVER}/g" go-agent.ORIG >/etc/default/go-agent +service go-agent start + +# EOF