Browse Source

Fix node-token path not resolving for root user in agent scripts

pull/165/head
David Pendray 6 years ago
parent
commit
d7e5c86041
  1. 4
      scripts/dev-agent.sh
  2. 4
      scripts/dev-docker-agent.sh
  3. 7
      scripts/setup-rancher-path.sh

4
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) "$@"

4
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

7
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
Loading…
Cancel
Save