diff --git a/jobs/k3s-agent/spec b/jobs/k3s-agent/spec index b2d2d5e2..d32a6e5b 100644 --- a/jobs/k3s-agent/spec +++ b/jobs/k3s-agent/spec @@ -14,10 +14,11 @@ templates: bin/post-deploy.erb: bin/post-deploy bin/drain.erb: bin/drain bin/ctl.erb: bin/ctl + bin/envrc: bin/envrc + bin/setup-user-env.erb: bin/setup-user-env bin/k3s-killall.sh: bin/k3s-killall.sh - config/registries.yaml.erb: config/registries.yaml config/registry.ca.erb: config/registry.ca config/registry.cert.erb: config/registry.cert diff --git a/jobs/k3s-agent/templates/bin/envrc b/jobs/k3s-agent/templates/bin/envrc new file mode 100644 index 00000000..4841c567 --- /dev/null +++ b/jobs/k3s-agent/templates/bin/envrc @@ -0,0 +1,4 @@ +#!/bin/bash + +export PATH=$PATH:/var/vcap/packages/k3s +alias crictl="k3s crictl" \ No newline at end of file diff --git a/jobs/k3s-agent/templates/bin/setup-user-env.erb b/jobs/k3s-agent/templates/bin/setup-user-env.erb new file mode 100644 index 00000000..d6ac5f81 --- /dev/null +++ b/jobs/k3s-agent/templates/bin/setup-user-env.erb @@ -0,0 +1,15 @@ +#!/bin/bash + +checkenv() { + trap "exit 0" INT TERM QUIT + + command=". ${JOB_DIR}/bin/envrc" + for profile in /root/.profile /etc/skel/.profile; do + # toolbelt.auto is disabled; stripping envrc from .profiles + if ! grep -q "^${command}\$" ${profile} >/dev/null 2>&1; then + echo "${command}" >> ${profile} + fi + done +} + +checkenv \ No newline at end of file