From d7e5c860412d0fe9904288235bbe6f209b267f51 Mon Sep 17 00:00:00 2001 From: David Pendray Date: Wed, 6 Mar 2019 00:03:27 +0000 Subject: [PATCH 1/2] Fix node-token path not resolving for root user in agent scripts --- scripts/dev-agent.sh | 4 +++- scripts/dev-docker-agent.sh | 4 +++- scripts/setup-rancher-path.sh | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100755 scripts/setup-rancher-path.sh diff --git a/scripts/dev-agent.sh b/scripts/dev-agent.sh index d14cb6daec..0d0a0d8943 100755 --- a/scripts/dev-agent.sh +++ b/scripts/dev-agent.sh @@ -1,6 +1,8 @@ #!/bin/bash set -e +. setup-rancher-path.sh + cd $(dirname $0)/.. # Prime sudo @@ -15,4 +17,4 @@ else fi echo Starting agent -sudo env "PATH=$(pwd)/bin:$PATH" ./bin/k3s-agent --debug agent -s https://localhost:6443 -t $(<${HOME}/.rancher/k3s/server/node-token) "$@" +sudo env "PATH=$(pwd)/bin:$PATH" ./bin/k3s-agent --debug agent -s https://localhost:6443 -t $(<${RANCHER_PATH}/k3s/server/node-token) "$@" diff --git a/scripts/dev-docker-agent.sh b/scripts/dev-docker-agent.sh index c9d8d47c46..bdde6d9795 100755 --- a/scripts/dev-docker-agent.sh +++ b/scripts/dev-docker-agent.sh @@ -1,5 +1,7 @@ #!/bin/bash +. setup-rancher-path.sh + cd $(dirname $0)/.. IP=$(ip addr show dev docker0 | grep -w inet | awk '{print $2}' | cut -f1 -d/) docker run \ @@ -16,4 +18,4 @@ docker run \ -v /var/lib/cni \ -v /usr/lib/x86_64-linux-gnu/libsqlite3.so.0:/usr/lib/x86_64-linux-gnu/libsqlite3.so.0:ro \ --privileged \ - ubuntu:18.04 /usr/bin/k3s-agent agent -t $(<~/.rancher/k3s/server/node-token) -s https://${IP}:6443 + ubuntu:18.04 /usr/bin/k3s-agent agent -t $(<${RANCHER_PATH}/k3s/server/node-token) -s https://${IP}:6443 diff --git a/scripts/setup-rancher-path.sh b/scripts/setup-rancher-path.sh new file mode 100755 index 0000000000..cb0a6468b7 --- /dev/null +++ b/scripts/setup-rancher-path.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [ $(id -u) = 0 ]; then + RANCHER_PATH="/var/lib/rancher" +else + RANCHER_PATH="$HOME/.rancher" +fi From c7b2548f66f7f15a3458bacd2c32381a3ef380af Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 7 Mar 2019 09:32:33 -0700 Subject: [PATCH 2/2] Fixup pr165 --- scripts/dev-agent.sh | 4 ++-- scripts/dev-docker-agent.sh | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/dev-agent.sh b/scripts/dev-agent.sh index 0d0a0d8943..e860519c7d 100755 --- a/scripts/dev-agent.sh +++ b/scripts/dev-agent.sh @@ -1,10 +1,10 @@ #!/bin/bash set -e -. setup-rancher-path.sh - cd $(dirname $0)/.. +. ./scripts/setup-rancher-path.sh + # Prime sudo sudo echo Compiling diff --git a/scripts/dev-docker-agent.sh b/scripts/dev-docker-agent.sh index bdde6d9795..c6d155c80f 100755 --- a/scripts/dev-docker-agent.sh +++ b/scripts/dev-docker-agent.sh @@ -1,8 +1,10 @@ #!/bin/bash - -. setup-rancher-path.sh +set -e cd $(dirname $0)/.. + +. ./scripts/setup-rancher-path.sh + IP=$(ip addr show dev docker0 | grep -w inet | awk '{print $2}' | cut -f1 -d/) docker run \ --read-only \